nielsr HF staff commited on
Commit
fc0d7df
·
verified ·
1 Parent(s): a2baf5a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +75 -2
README.md CHANGED
@@ -6,5 +6,78 @@ tags:
6
  ---
7
 
8
  This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
9
- - Library: [More Information Needed]
10
- - Docs: [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  ---
7
 
8
  This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
9
+ - Library: https://github.com/THU-MIG/yolov10
10
+
11
+ ## Installation
12
+
13
+ First install the YOLOv10 Github repository along with supervision which provides some nice utilities for bounding box processing.
14
+
15
+ ```
16
+ pip install git+https://github.com/THU-MIG/yolov10.git supervision
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ One can perform inference as follows:
22
+
23
+ ```python
24
+ from ultralytics import YOLOv10
25
+ import supervision as sv
26
+ from PIL import Image
27
+ import requests
28
+
29
+ # load model
30
+ model = YOLOv10.from_pretrained("nielsr/yolov10n")
31
+
32
+ # load image
33
+ url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
34
+ image = Image.open(requests.get(url, stream=True).raw)
35
+ image = np.array(image)
36
+
37
+ # perform inference
38
+ results = model(source=image, conf=0.25, verbose=False)[0]
39
+ detections = sv.Detections.from_ultralytics(results)
40
+ box_annotator = sv.BoxAnnotator()
41
+
42
+ category_dict = {
43
+ 0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 4: 'airplane', 5: 'bus',
44
+ 6: 'train', 7: 'truck', 8: 'boat', 9: 'traffic light', 10: 'fire hydrant',
45
+ 11: 'stop sign', 12: 'parking meter', 13: 'bench', 14: 'bird', 15: 'cat',
46
+ 16: 'dog', 17: 'horse', 18: 'sheep', 19: 'cow', 20: 'elephant', 21: 'bear',
47
+ 22: 'zebra', 23: 'giraffe', 24: 'backpack', 25: 'umbrella', 26: 'handbag',
48
+ 27: 'tie', 28: 'suitcase', 29: 'frisbee', 30: 'skis', 31: 'snowboard',
49
+ 32: 'sports ball', 33: 'kite', 34: 'baseball bat', 35: 'baseball glove',
50
+ 36: 'skateboard', 37: 'surfboard', 38: 'tennis racket', 39: 'bottle',
51
+ 40: 'wine glass', 41: 'cup', 42: 'fork', 43: 'knife', 44: 'spoon', 45: 'bowl',
52
+ 46: 'banana', 47: 'apple', 48: 'sandwich', 49: 'orange', 50: 'broccoli',
53
+ 51: 'carrot', 52: 'hot dog', 53: 'pizza', 54: 'donut', 55: 'cake',
54
+ 56: 'chair', 57: 'couch', 58: 'potted plant', 59: 'bed', 60: 'dining table',
55
+ 61: 'toilet', 62: 'tv', 63: 'laptop', 64: 'mouse', 65: 'remote', 66: 'keyboard',
56
+ 67: 'cell phone', 68: 'microwave', 69: 'oven', 70: 'toaster', 71: 'sink',
57
+ 72: 'refrigerator', 73: 'book', 74: 'clock', 75: 'vase', 76: 'scissors',
58
+ 77: 'teddy bear', 78: 'hair drier', 79: 'toothbrush'
59
+ }
60
+
61
+ labels = [
62
+ f"{category_dict[class_id]} {confidence:.2f}"
63
+ for class_id, confidence in zip(detections.class_id, detections.confidence)
64
+ ]
65
+ annotated_image = box_annotator.annotate(
66
+ image.copy(), detections=detections, labels=labels
67
+ )
68
+
69
+ Image.fromarray(annotated_image)
70
+ ```
71
+
72
+ ### BibTeX Entry and Citation Info
73
+ ```
74
+ @misc{wang2024yolov10,
75
+ title={YOLOv10: Real-Time End-to-End Object Detection},
76
+ author={Ao Wang and Hui Chen and Lihao Liu and Kai Chen and Zijia Lin and Jungong Han and Guiguang Ding},
77
+ year={2024},
78
+ eprint={2405.14458},
79
+ archivePrefix={arXiv},
80
+ primaryClass={cs.CV}
81
+ }
82
+ ```
83
+