valentynliubchenko commited on
Commit
44068da
·
1 Parent(s): 72b17a3

Added chose models

Browse files
app.py CHANGED
@@ -3,14 +3,16 @@ import gradio as gr
3
  from ultralytics import YOLO
4
  import numpy as np
5
 
6
- model = YOLO('./xViewyolov8m_v8_100e.pt')
 
 
7
  example_list = [["examples/" + example] for example in os.listdir("examples")]
8
 
9
-
10
-
11
- def process_image(input_image):
12
- # results = model(input_image)
13
- # results = model.predict(input_image, conf=0.6, classes=range(0, 78))
14
  results = model.predict(input_image, conf=0.6)
15
  class_counts = {}
16
  class_counts_str = "Class Counts:\n"
@@ -30,9 +32,9 @@ def process_image(input_image):
30
 
31
  iface = gr.Interface(
32
  fn=process_image,
33
- inputs=gr.Image(),
34
  outputs=["image", gr.Textbox(label="More info")],
35
- title="YOLO Object detection. Trained on xView dataset. Medium model. Predict with conf=0.6",
36
  description='''The xView dataset is composed of satellite images collected from WorldView-3 satellites at a 0.3m ground sample distance.\n
37
  It contains over 1 million objects across 60 classes in over 1,400 km of imagery.
38
  https://challenge.xviewdataset.org ''',
 
3
  from ultralytics import YOLO
4
  import numpy as np
5
 
6
+ model_options = ["xViewyolov8n_v8_100e.pt", "xViewyolov8s_v8_100e.pt", "xViewyolov8m_v8_100e.pt"]
7
+ model_names = ["Nano", "Smoll", "Medium"]
8
+ models = [YOLO(os.path.join("./saved_model", option)) for option in model_options]
9
  example_list = [["examples/" + example] for example in os.listdir("examples")]
10
 
11
+ def process_image(input_image, model_name):
12
+ print(model_name)
13
+ model_index = model_names.index(model_name)
14
+ model = models[model_index]
15
+
16
  results = model.predict(input_image, conf=0.6)
17
  class_counts = {}
18
  class_counts_str = "Class Counts:\n"
 
32
 
33
  iface = gr.Interface(
34
  fn=process_image,
35
+ inputs=[gr.Image(), gr.Radio(model_names, label="Choose model", value=model_names[0])],
36
  outputs=["image", gr.Textbox(label="More info")],
37
+ title="YOLO Object detection. Trained on xView dataset.",
38
  description='''The xView dataset is composed of satellite images collected from WorldView-3 satellites at a 0.3m ground sample distance.\n
39
  It contains over 1 million objects across 60 classes in over 1,400 km of imagery.
40
  https://challenge.xviewdataset.org ''',
xViewyolov8m_v8_100e.pt → saved_model/xViewyolov8m_v8_100e.pt RENAMED
File without changes
saved_model/xViewyolov8n_v8_100e.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63e1c214fc1cfd7a1e521d6b976f7763c743bf6cc812037034e439d4b15609c7
3
+ size 52107713
saved_model/xViewyolov8s_v8_100e.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63e1c214fc1cfd7a1e521d6b976f7763c743bf6cc812037034e439d4b15609c7
3
+ size 52107713