valentynliubchenko commited on
Commit
b613d12
1 Parent(s): 126a142

Added project

Browse files
.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

  • SHA256: 6887559be4bbe3c5ea5cc1068043902b13ad5a3cce2a1c2b6fbc7a527e23a61e
  • Pointer size: 131 Bytes
  • Size of remote file: 112 kB
examples/bandicam-2023-11-23-12-35-58-973_jpg.rf.3bbe26f52b40a7c77097299ca4f1d186.jpg ADDED

Git LFS Details

  • SHA256: a0c5adaee7ec85a27a7b5f67637fdffc5d4e06afb1886e0faa62281d90b1855e
  • Pointer size: 131 Bytes
  • Size of remote file: 153 kB
examples/bandicam-2023-11-23-12-37-57-081_jpg.rf.05e939a369daa2daf6d756483a58ff1b.jpg ADDED

Git LFS Details

  • SHA256: e7b5c4b589e1316652103c098551a05900cfdc6d5109bf431e788b4d0772b900
  • Pointer size: 131 Bytes
  • Size of remote file: 181 kB
examples/bandicam-2023-11-25-15-00-37-826_jpg.rf.b4acced2cd865e31d9a32ce77e6f7cbd.jpg ADDED

Git LFS Details

  • SHA256: d88e6f3cb3c84c67be254e426f7ff6e013d3933c39a06a49861b19aac3783d1c
  • Pointer size: 131 Bytes
  • Size of remote file: 146 kB
examples/bandicam-2023-11-25-15-00-48-703_jpg.rf.d4a7bbcf5e10d3bf1cd47d734872fab7.jpg ADDED

Git LFS Details

  • SHA256: 97fe08fd3a96a0840788461da5c0dec0f4f6388b6b98c170cf9cdd347346b6a3
  • Pointer size: 130 Bytes
  • Size of remote file: 68.5 kB
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