SakshiRathi77 commited on
Commit
499263d
1 Parent(s): e031631

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +52 -7
README.md CHANGED
@@ -1,9 +1,54 @@
 
1
  ---
2
- license: apache-2.0
3
- language:
4
- - en
5
  pipeline_tag: object-detection
6
- tags:
7
- - void
8
- - yolov9
9
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
  ---
 
 
 
3
  pipeline_tag: object-detection
4
+ ---
5
+ # YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information
6
+
7
+ This is the model repository for YOLOv9, containing the following checkpoints:
8
+
9
+ -best.pt
10
+
11
+
12
+
13
+ Download the weights using `hf_hub_download` and use the loading function in helpers of YOLOv9.
14
+
15
+ ```python
16
+ from huggingface_hub import hf_hub_download
17
+ hf_hub_download("SakshiRathi77/void-150-epoch", filename="best.pt", local_dir="./")
18
+ ```
19
+
20
+ Load the model.
21
+
22
+ ```python
23
+ # make sure you have the following dependencies
24
+ import torch
25
+ import numpy as np
26
+ from models.common import DetectMultiBackend
27
+ from utils.general import non_max_suppression, scale_boxes
28
+ from utils.torch_utils import select_device, smart_inference_mode
29
+ from utils.augmentations import letterbox
30
+ import PIL.Image
31
+
32
+ @smart_inference_mode()
33
+ def predict(image_path, weights='best.pt', imgsz=640, conf_thres=0.1, iou_thres=0.45):
34
+ # Initialize
35
+ device = select_device('0')
36
+ model = DetectMultiBackend(weights='best.pt', device="0", fp16=False, data='data/coco.yaml')
37
+ stride, names, pt = model.stride, model.names, model.pt
38
+
39
+ # Load image
40
+ image = np.array(PIL.Image.open(image_path))
41
+ img = letterbox(img0, imgsz, stride=stride, auto=True)[0]
42
+ img = img[:, :, ::-1].transpose(2, 0, 1)
43
+ img = np.ascontiguousarray(img)
44
+ img = torch.from_numpy(img).to(device).float()
45
+ img /= 255.0
46
+ if img.ndimension() == 3:
47
+ img = img.unsqueeze(0)
48
+
49
+ # Inference
50
+ pred = model(img, augment=False, visualize=False)
51
+
52
+ # Apply NMS
53
+ pred = non_max_suppression(pred[0][0], conf_thres, iou_thres, classes=None, max_det=1000)
54
+ ```