valentynliubchenko commited on
Commit
0c6b368
·
1 Parent(s): 44068da

Confidence Threshold

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -8,12 +8,13 @@ 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"
19
 
@@ -32,7 +33,11 @@ def process_image(input_image, model_name):
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
@@ -40,6 +45,6 @@ iface = gr.Interface(
40
  https://challenge.xviewdataset.org ''',
41
  live=True,
42
  examples=example_list
43
- )
44
 
45
  iface.launch()
 
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, conf):
12
  print(model_name)
13
+ print(conf)
14
  model_index = model_names.index(model_name)
15
  model = models[model_index]
16
 
17
+ results = model.predict(input_image, conf=conf)
18
  class_counts = {}
19
  class_counts_str = "Class Counts:\n"
20
 
 
33
 
34
  iface = gr.Interface(
35
  fn=process_image,
36
+ inputs=[
37
+ gr.Image(),
38
+ gr.Radio(model_names, label="Choose model", value=model_names[0]),
39
+ gr.Slider(minimum=0.2, maximum=1.0, step=0.1, label="Confidence Threshold", value=0.6)
40
+ ],
41
  outputs=["image", gr.Textbox(label="More info")],
42
  title="YOLO Object detection. Trained on xView dataset.",
43
  description='''The xView dataset is composed of satellite images collected from WorldView-3 satellites at a 0.3m ground sample distance.\n
 
45
  https://challenge.xviewdataset.org ''',
46
  live=True,
47
  examples=example_list
48
+ )
49
 
50
  iface.launch()