Question: I ' m currently learning how to do custom dataset object detection by using Yolov 5 . This is my current code and I am
Im currently learning how to do custom dataset object detection by using Yolov This is my current code and I am using PyCharm. It does not show any bounding box or identification when I run an mp video. But when I use the terminal by using python detect.py weights best.pt conf imgsize source CustomDatatridaxnewmp it brings me the results I want. However, if I do it in the python script, it just shows the video of it but it does not show any bounding box and identification. I did this so I can check if the yoloV detection works in realtime when i use my webcam.
This is my code in main.py Please show me how to fix it and explain the changes in the code.
import torch
from matplotlib import pyplot as plt
import numpy as np
import cv
model torch.hub.loadultralyticsyolov 'custom', path'yolovbestptforcereloadTrue
#real time detections
cap cvVideoCapturetridaxnewmp #This video should have bounding box and identification but it is not
while cap.isOpened:
ret, frame cap.read
#make detections
results modelframe
cvimshowObjectDetection npsqueezeresultsrender
if cvwaitKey & xFF ordq:
break
cap.release
cvdestroyAllWindows
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
