Spaces:
Running
Running
valentynliubchenko
commited on
Commit
•
b613d12
1
Parent(s):
126a142
Added project
Browse files- .gitattributes +1 -0
- app.py +68 -0
- examples/bandicam-2023-10-17-19-51-40-419_jpg.rf.e71c21f30412a470901f75e5d092b73e.jpg +3 -0
- examples/bandicam-2023-11-23-12-35-58-973_jpg.rf.3bbe26f52b40a7c77097299ca4f1d186.jpg +3 -0
- examples/bandicam-2023-11-23-12-37-57-081_jpg.rf.05e939a369daa2daf6d756483a58ff1b.jpg +3 -0
- examples/bandicam-2023-11-25-15-00-37-826_jpg.rf.b4acced2cd865e31d9a32ce77e6f7cbd.jpg +3 -0
- examples/bandicam-2023-11-25-15-00-48-703_jpg.rf.d4a7bbcf5e10d3bf1cd47d734872fab7.jpg +3 -0
- requirements.txt +5 -0
- saved_model/yolov8l_bird_100.pt +3 -0
- saved_model/yolov8m_bird_100.pt +3 -0
- saved_model/yolov8n_bird_100.pt +3 -0
- saved_model/yolov8s_bird_100.pt +3 -0
.gitattributes
CHANGED
@@ -24,6 +24,7 @@
|
|
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 |
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
*.tflite 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 |
+
examples/**/* filter=lfs diff=lfs merge=lfs -text
|
28 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
29 |
*.tar filter=lfs diff=lfs merge=lfs -text
|
30 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from ultralytics import YOLO
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
model_options = ["yolov8n_bird_100.pt", "yolov8s_bird_100.pt", "yolov8m_bird_100.pt", "yolov8l_bird_100.pt"]
|
7 |
+
model_names = ["Nano", "Small", "Medium", "Large"]
|
8 |
+
print("before loading examples")
|
9 |
+
example_list = [["./examples/" + example] for example in os.listdir("examples")]
|
10 |
+
print("before loading models")
|
11 |
+
models = [YOLO(os.path.join("./saved_model", option)) for option in model_options]
|
12 |
+
print("finish preparation")
|
13 |
+
|
14 |
+
def process_image(input_image, model_name, conf):
|
15 |
+
print('start processing: ')
|
16 |
+
if input_image is None:
|
17 |
+
return None, "No objects detected."
|
18 |
+
|
19 |
+
print(f"model_name : {model_name}")
|
20 |
+
print(f"conf : {conf}")
|
21 |
+
|
22 |
+
if model_name is None:
|
23 |
+
model_name = model_names[0]
|
24 |
+
|
25 |
+
if conf is None:
|
26 |
+
conf = 0.6
|
27 |
+
|
28 |
+
model_index = model_names.index(model_name)
|
29 |
+
print('model_index: ')
|
30 |
+
print(model_index)
|
31 |
+
model = models[model_index]
|
32 |
+
|
33 |
+
results = model.predict(input_image, conf=conf)
|
34 |
+
class_counts = {}
|
35 |
+
class_counts_str = "Class Counts:\n"
|
36 |
+
|
37 |
+
for r in results:
|
38 |
+
im_array = r.plot()
|
39 |
+
im_array = im_array.astype(np.uint8)
|
40 |
+
|
41 |
+
if len(r.boxes) == 0: # If no objects are detected
|
42 |
+
return None, "No objects detected."
|
43 |
+
|
44 |
+
for box in r.boxes:
|
45 |
+
class_name = r.names[box.cls[0].item()]
|
46 |
+
class_counts[class_name] = class_counts.get(class_name, 0) + 1
|
47 |
+
|
48 |
+
for cls, count in class_counts.items():
|
49 |
+
class_counts_str += f"\n{cls}: {count}"
|
50 |
+
|
51 |
+
return im_array, class_counts_str
|
52 |
+
|
53 |
+
iface = gr.Interface(
|
54 |
+
fn=process_image,
|
55 |
+
inputs=[
|
56 |
+
gr.Image(),
|
57 |
+
gr.Radio(model_names, label="Choose model", value=model_names[0]),
|
58 |
+
gr.Slider(minimum=0.2, maximum=1.0, step=0.1, label="Confidence Threshold", value=0.6)
|
59 |
+
],
|
60 |
+
outputs=["image", gr.Textbox(label="More info")],
|
61 |
+
title="YOLO Object detection. Trained on bird_1_3_dataset (millitary vehicles).",
|
62 |
+
description='''The bird_1_3_dataset dataset is composed of millitary vehicles.\n
|
63 |
+
https://universe.roboflow.com/arnold-gudima-t7mdj/bird_1_3 ''',
|
64 |
+
live=True,
|
65 |
+
examples=example_list
|
66 |
+
)
|
67 |
+
|
68 |
+
iface.launch()
|
examples/bandicam-2023-10-17-19-51-40-419_jpg.rf.e71c21f30412a470901f75e5d092b73e.jpg
ADDED
Git LFS Details
|
examples/bandicam-2023-11-23-12-35-58-973_jpg.rf.3bbe26f52b40a7c77097299ca4f1d186.jpg
ADDED
Git LFS Details
|
examples/bandicam-2023-11-23-12-37-57-081_jpg.rf.05e939a369daa2daf6d756483a58ff1b.jpg
ADDED
Git LFS Details
|
examples/bandicam-2023-11-25-15-00-37-826_jpg.rf.b4acced2cd865e31d9a32ce77e6f7cbd.jpg
ADDED
Git LFS Details
|
examples/bandicam-2023-11-25-15-00-48-703_jpg.rf.d4a7bbcf5e10d3bf1cd47d734872fab7.jpg
ADDED
Git LFS Details
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==3.49.0
|
2 |
+
numpy==1.26.0
|
3 |
+
opencv-python==4.9.0.80
|
4 |
+
ultralytics==8.1.10
|
5 |
+
mediapipe==0.10.7
|
saved_model/yolov8l_bird_100.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ef0fb592ea934ab372a3650a222d31e2a2f2496feaaa40ddc8a0270666c4ba9a
|
3 |
+
size 87644265
|
saved_model/yolov8m_bird_100.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8723f8f8735c7c5d3604400e03b9c22a2412d24043b1c31cb144d1b87ce853d7
|
3 |
+
size 52022913
|
saved_model/yolov8n_bird_100.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:86d151e6934901348905535b7e88e8143a05d22739b5b8481dd8a0ea119d7cda
|
3 |
+
size 6233433
|
saved_model/yolov8s_bird_100.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b87ab4d5ae02faf4a56fd6ae51d49b0899bdc705edef8a8178e726e6c7700757
|
3 |
+
size 22506777
|