Duplicate from kadirnar/yolov6
Browse filesCo-authored-by: Kadir Nar <[email protected]>
- .gitattributes +34 -0
- Arial.ttf +0 -0
- README.md +14 -0
- app.py +72 -0
- coco.yaml +20 -0
- requirements.txt +2 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
Arial.ttf
ADDED
Binary file (773 kB). View file
|
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Yolov6
|
3 |
+
emoji: 📈
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: indigo
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.14.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: gpl-3.0
|
11 |
+
duplicated_from: kadirnar/yolov6
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from yolov6 import YOLOV6
|
4 |
+
|
5 |
+
# Images
|
6 |
+
torch.hub.download_url_to_file('https://raw.githubusercontent.com/kadirnar/dethub/main/data/images/highway.jpg', 'highway.jpg')
|
7 |
+
torch.hub.download_url_to_file('https://user-images.githubusercontent.com/34196005/142742872-1fefcc4d-d7e6-4c43-bbb7-6b5982f7e4ba.jpg', 'highway1.jpg')
|
8 |
+
|
9 |
+
|
10 |
+
def yolov6_inference(
|
11 |
+
image: gr.inputs.Image = None,
|
12 |
+
model_path: gr.inputs.Dropdown = None,
|
13 |
+
image_size: gr.inputs.Slider = 640,
|
14 |
+
conf_threshold: gr.inputs.Slider = 0.25,
|
15 |
+
iou_threshold: gr.inputs.Slider = 0.45,
|
16 |
+
):
|
17 |
+
"""
|
18 |
+
YOLOv6 inference function
|
19 |
+
Args:
|
20 |
+
image: Input image
|
21 |
+
model_path: Path to the model
|
22 |
+
image_size: Image size
|
23 |
+
conf_threshold: Confidence threshold
|
24 |
+
iou_threshold: IOU threshold
|
25 |
+
Returns:
|
26 |
+
Rendered image
|
27 |
+
"""
|
28 |
+
|
29 |
+
model = YOLOV6(model_path, device="cpu", hf_model=True)
|
30 |
+
model.conf_thres = conf_threshold
|
31 |
+
model.iou_thresh = iou_threshold
|
32 |
+
model.save_img = True
|
33 |
+
model.font_path = "Arial.ttf"
|
34 |
+
pred = model.predict(source=image, img_size=image_size, yaml="coco.yaml")
|
35 |
+
return pred
|
36 |
+
|
37 |
+
|
38 |
+
inputs = [
|
39 |
+
gr.inputs.Image(type="filepath", label="Input Image"),
|
40 |
+
gr.inputs.Dropdown(
|
41 |
+
label="Model",
|
42 |
+
choices=[
|
43 |
+
"kadirnar/yolov6n-v3.0",
|
44 |
+
"kadirnar/yolov6s-v3.0",
|
45 |
+
"kadirnar/yolov6m-v3.0",
|
46 |
+
"kadirnar/yolov6l-v3.0",
|
47 |
+
"kadirnar/yolov6s6-v3.0",
|
48 |
+
"kadirnar/yolov6m6-v3.0",
|
49 |
+
"kadirnar/yolov6l6-v3.0",
|
50 |
+
],
|
51 |
+
default="kadirnar/yolov6s-v3.0",
|
52 |
+
),
|
53 |
+
gr.inputs.Slider(minimum=320, maximum=1280, default=1280, step=32, label="Image Size"),
|
54 |
+
gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.25, step=0.05, label="Confidence Threshold"),
|
55 |
+
gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.45, step=0.05, label="IOU Threshold"),
|
56 |
+
]
|
57 |
+
|
58 |
+
outputs = gr.outputs.Image(type="filepath", label="Output Image")
|
59 |
+
title = "YOLOv6: a single-stage object detection framework dedicated to industrial applications."
|
60 |
+
|
61 |
+
examples = [['highway1.jpg', 'kadirnar/yolov6m6-v3.0', 1280, 0.25, 0.45],['highway.jpg', 'kadirnar/yolov6s6-v3.0', 1280, 0.25, 0.45]]
|
62 |
+
|
63 |
+
demo_app = gr.Interface(
|
64 |
+
fn=yolov6_inference,
|
65 |
+
inputs=inputs,
|
66 |
+
outputs=outputs,
|
67 |
+
title=title,
|
68 |
+
examples=examples,
|
69 |
+
cache_examples=True,
|
70 |
+
theme='huggingface',
|
71 |
+
)
|
72 |
+
demo_app.launch(debug=True, enable_queue=True)
|
coco.yaml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# COCO 2017 dataset http://cocodataset.org
|
2 |
+
train: ../coco/images/train2017 # 118287 images
|
3 |
+
val: ../coco/images/val2017 # 5000 images
|
4 |
+
test: ../coco/images/test2017
|
5 |
+
anno_path: ../coco/annotations/instances_val2017.json
|
6 |
+
# number of classes
|
7 |
+
nc: 80
|
8 |
+
# whether it is coco dataset, only coco dataset should be set to True.
|
9 |
+
is_coco: True
|
10 |
+
|
11 |
+
# class names
|
12 |
+
names: [ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
|
13 |
+
'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
|
14 |
+
'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
|
15 |
+
'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
|
16 |
+
'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
|
17 |
+
'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
|
18 |
+
'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
|
19 |
+
'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
|
20 |
+
'hair drier', 'toothbrush' ]
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
yolov6detect==0.2.3
|