Object Detection
YOLO
YOLOv9
BootsofLagrangian commited on
Commit
3577bdb
1 Parent(s): 3f82598

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +6 -6
README.md CHANGED
@@ -69,13 +69,13 @@ import PIL.Image
69
  def predict(image_path, weights='ultima_yolov9-e.pt', imgsz=640, conf_thres=0.1, iou_thres=0.45):
70
  # Initialize
71
  device = select_device('0')
72
- model = DetectMultiBackend(weights=weights, device="0", fp16=False, data='data/coco.yaml')
73
  stride, names, pt = model.stride, model.names, model.pt
74
 
75
  # Load image
76
- image = np.array(PIL.Image.open(image_path))
77
- img = letterbox(img0, imgsz, stride=stride, auto=True)[0]
78
- img = img[:, :, ::-1].transpose(2, 0, 1)
79
  img = np.ascontiguousarray(img)
80
  img = torch.from_numpy(img).to(device).float()
81
  img /= 255.0
@@ -88,10 +88,10 @@ def predict(image_path, weights='ultima_yolov9-e.pt', imgsz=640, conf_thres=0.1,
88
  # Apply NMS
89
  pred = non_max_suppression(pred[0][0], conf_thres, iou_thres, classes=None, max_det=1000)
90
  ```
91
- or use `detect_dual.py` in yolov9 repo.
92
 
93
  ```bash
94
- python ./detect_dual.py --source [image_path] --device 0 --img 1280 --weights './ultima_yolov9.pt' --name ultima_yolov9_1280_detect
95
  ```
96
 
97
  # Training Infomation
 
69
  def predict(image_path, weights='ultima_yolov9-e.pt', imgsz=640, conf_thres=0.1, iou_thres=0.45):
70
  # Initialize
71
  device = select_device('0')
72
+ model = DetectMultiBackend(weights=weights, device=device, fp16=False)
73
  stride, names, pt = model.stride, model.names, model.pt
74
 
75
  # Load image
76
+ image = np.array(PIL.Image.open(image_path).convert("RGB"))
77
+ img = letterbox(image, imgsz, stride=stride, auto=True)[0]
78
+ img = img.transpose(2, 0, 1)
79
  img = np.ascontiguousarray(img)
80
  img = torch.from_numpy(img).to(device).float()
81
  img /= 255.0
 
88
  # Apply NMS
89
  pred = non_max_suppression(pred[0][0], conf_thres, iou_thres, classes=None, max_det=1000)
90
  ```
91
+ or use `detect.py` in yolov9 repo.
92
 
93
  ```bash
94
+ python ./detect.py --source [image_path] --device 0 --img 1280 --weights './ultima_yolov9-e.pt' --name ultima_yolov9_1280_detect
95
  ```
96
 
97
  # Training Infomation