Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera tracking seems to be very slow #2

Closed
Bloctans opened this issue Jan 31, 2023 · 7 comments
Closed

Camera tracking seems to be very slow #2

Bloctans opened this issue Jan 31, 2023 · 7 comments

Comments

@Bloctans
Copy link

I don't know if I'm having a moment where I'm stupid or something but for some reason this seems very slow

Here is my code:

from yolov7_package import Yolov7Detector
import cv2

if __name__ == '__main__':
    cap = cv2.VideoCapture(0)
    det = Yolov7Detector(traced=False)
    while cap.isOpened():
        success, img = cap.read()
        if not success:
            print("Ignoring empty camera frame.")
            continue

        classes, boxes, scores = det.detect(img)
        img = det.draw_on_image(img, boxes[0], scores[0], classes[0])

        cv2.imshow('MediaPipe Pose', cv2.flip(img, 1))
        if cv2.waitKey(5) & 0xFF == 27:
            break

    cap.release()
@maxwolf8852
Copy link
Owner

  • Which version of pytorch are you using (cpu/cuda)? [you can check it with "torch.cuda.is_available()"]
  • If you are trying to perform camera tracking without gpu, you can try setting the 'tiny' parameter to use a smaller model with less accuracy but faster execution speed, e.g. det = Yolov7Detector(traced=False, weights='yolov7-tiny.pt')

@Bloctans
Copy link
Author

i dont know if i have cuda

@Bloctans
Copy link
Author

nope, no cuda

@Bloctans
Copy link
Author

tiny is still pretty slow i have an i5-9300H with a gtx 1650 and intel uhd 630

@maxwolf8852
Copy link
Owner

Try to install pytorch with cuda enabled, it will greatly increase your performance. To do this, you need to install the СUDA toolkit and CUDNN library from the NVidia official website.Then, reinstall pytorch to achieve torch.cuda.is_available() == True

@maxwolf8852
Copy link
Owner

How long does it take to perform image processing with det.detect(img) call? E.g. in Apple M1 Pro cpu it takes ~150 ms, that is not realtime. If you want to have fast processing, use CUDA support.

@maxwolf8852
Copy link
Owner

Also, you can try python mpire/multiprocessing library to parallel processing task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants