Coder Social home page Coder Social logo

Check FPS about yolov5 HOT 5 CLOSED

AbhishekPSI7042 avatar AbhishekPSI7042 commented on September 8, 2024
Check FPS

from yolov5.

Comments (5)

glenn-jocher avatar glenn-jocher commented on September 8, 2024 1

@AbhishekPSI7042 you can calculate FPS by adding the following code to your detect.py after im0 = annotator.result():

fps_text = f"FPS: {1 / dt[1].dt:.2f}"
cv2.putText(im0, fps_text, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2, cv2.LINE_AA)

Your implementation looks correct! This will display the FPS on the output image. Remember to import cv2 if you haven't already. For more details, refer to the documentation at https://docs.ultralytics.com/yolov5/. Keep up the great work!

from yolov5.

AbhishekPSI7042 avatar AbhishekPSI7042 commented on September 8, 2024

@glenn-jocher hey, thanks I have another question I wan to save my model into fp16 in pytorch format how can do that. And can we improve the fps on cpu currently I'm getting 27fps on my cpu with image size 360 is there any other way to increase fps?

from yolov5.

glenn-jocher avatar glenn-jocher commented on September 8, 2024

@AbhishekPSI7042 you can save the model in fp16 format using PyTorch's torch.save function with torch.half dtype. To increase FPS on CPU, try reducing the image size or using a smaller model variant like YOLOv5s. Keep in mind, increasing FPS on CPU may sacrifice accuracy or vice versa. Always refer to the YOLOv5 documentation at https://docs.ultralytics.com/yolov5/ for best practices. Good luck!

from yolov5.

AbhishekPSI7042 avatar AbhishekPSI7042 commented on September 8, 2024

@glenn-jocher how can I save the model in pytorch because when I use export.py there is no way to save model in .pt format in fp16.

from yolov5.

glenn-jocher avatar glenn-jocher commented on September 8, 2024

@AbhishekPSI7042 To save the model in PyTorch's .pt format with fp16 precision, you can directly use PyTorch's torch.save function and specify the dtype as torch.half for the model's state dict. For example:

model.half()  # Convert model to half precision
torch.save(model.state_dict(), 'model_fp16.pt')  # Save model with fp16 precision

This will save the model with fp16 precision in .pt format. For more details, refer to the YOLOv5 documentation at https://docs.ultralytics.com/yolov5/. Keep exploring and feel free to reach out with any more questions!

from yolov5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.