You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
yolov5 - unable to do inference on custom model. Works fine on cli command line. But would like to run interactive.
This works :
from yolov5 subforlder.
python detect.py --weights best.pt --source image1.jpg --data data.yaml --img 320 --conf 0.7 ---- WORKS!!!
detect.py will use ./data/coco128.yaml by detault.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
yolov5 - unable to do inference on custom model. Works fine on cli command line. But would like to run interactive.
This works :
from yolov5 subforlder.
python detect.py --weights best.pt --source image1.jpg --data data.yaml --img 320 --conf 0.7 ---- WORKS!!!
detect.py will use ./data/coco128.yaml by detault.
Output from detect.py:
(tensorflow39) PS D:\tensorflow39\license_driver_v2_f\yolov5> python detect.py --weights best.pt --source image1.jpg --data data.yaml --img 320 --conf 0.7
detect: weights=['best.pt'], source=image1.jpg, data=data.yaml, imgsz=[320, 320], conf_thres=0.7, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_csv=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs\detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1
YOLOv5 v7.0-227-ge4df1ec Python-3.9.18 torch-2.1.0+cu118 CUDA:0 (Quadro P620, 4096MiB)
Fusing layers...
custom_YOLOv5s summary: 157 layers, 7012822 parameters, 0 gradients, 15.8 GFLOPs
image 1/1 D:\tensorflow39\license_driver_v2_f\yolov5\image1.jpg: 320x320 1 driverlicense, 18.5ms
Speed: 0.0ms pre-process, 18.5ms inference, 2.2ms NMS per image at shape (1, 3, 320, 320)
Results saved to runs\detect\exp3
model = torch.hub.load('./yolov5', 'custom', path='./yolov5/best.pt', source='local', force_reload=True, autoshape=True)
What does this custom mean. When i trained the model I used --cfg custom_yolov5s.yaml
Result:
YOLOv5 v7.0-227-ge4df1ec Python-3.9.18 torch-2.1.0+cu118 CUDA:0 (Quadro P620, 4096MiB)
Fusing layers...
custom_YOLOv5s summary: 157 layers, 7012822 parameters, 0 gradients, 15.8 GFLOPs
Adding AutoShape...
from PIL import Image
img = Image.open('./yolov5/image1.jpg')
new_image = img.resize((320, 320))
results = model(new_image)
print(f'prediction: { results.pred}')
result:prediction: [tensor([], device='cuda:0', size=(0, 6))]
image 1/1: 320x320 (no detections)
Speed: 18.5ms pre-process, 132.3ms inference, 0.0ms NMS per image at shape (1, 3, 640, 640)
Beta Was this translation helpful? Give feedback.
All reactions