nielsr HF staff commited on
Commit
60a763b
1 Parent(s): cfcb097

Update README.md

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