nihalbaig commited on
Commit
7502434
·
verified ·
1 Parent(s): 32ec834

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -21
app.py CHANGED
@@ -3,16 +3,12 @@ import torch
3
  import yolov7
4
 
5
 
6
- # Images
7
- #torch.hub.download_url_to_file('https://raw.githubusercontent.com/nihalbaig0/BD-Vehicle-Detection/main/images/bondor_to_kodomtoli.jpg', 'bondor_to_kodomtoli.jpg')
8
- #torch.hub.download_url_to_file('https://raw.githubusercontent.com/nihalbaig0/BD-Vehicle-Detection/main/images/lamabazar_to_versitygate.jpg', 'lamabazar_to_versitygate.jpg')
9
-
10
  def yolov7_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
  YOLOv7 inference function
@@ -34,31 +30,28 @@ def yolov7_inference(
34
 
35
 
36
  inputs = [
37
- gr.inputs.Image(type="pil", label="Input Image"),
38
- gr.inputs.Dropdown(
39
  choices=[
40
  "nihalbaig/yolov7",
41
-
42
  ],
43
- default="nihalbaig0/yolov7",
44
  label="Model",
45
  ),
46
- gr.inputs.Slider(minimum=320, maximum=1280, default=640, step=32, label="Image Size"),
47
- gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.25, step=0.05, label="Confidence Threshold"),
48
- gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.45, step=0.05, label="IOU Threshold"),
49
  ]
50
 
51
- outputs = gr.outputs.Image(type="filepath", label="Output Image")
52
  title = "Project-350: BD Vehicle Detection for Autonomous Vehicle"
53
 
54
- #examples = [['bondor_to_kodomtoli.jpg', 'nihalbaig0/yolov7', 640, 0.25, 0.45], ['lamabazar_to_versitygate.jpg', 'nihalbaig0/yolov7', 640, 0.25, 0.45]]
55
  demo_app = gr.Interface(
56
  fn=yolov7_inference,
57
  inputs=inputs,
58
  outputs=outputs,
59
  title=title,
60
- #examples=examples,
61
  cache_examples=True,
62
- theme='darkhuggingface',
63
  )
64
- demo_app.launch(debug=True, enable_queue=True)
 
3
  import yolov7
4
 
5
 
 
 
 
 
6
  def yolov7_inference(
7
+ image,
8
+ model_path,
9
+ image_size,
10
+ conf_threshold,
11
+ iou_threshold,
12
  ):
13
  """
14
  YOLOv7 inference function
 
30
 
31
 
32
  inputs = [
33
+ gr.Image(type="pil", label="Input Image"),
34
+ gr.Dropdown(
35
  choices=[
36
  "nihalbaig/yolov7",
 
37
  ],
38
+ value="nihalbaig0/yolov7",
39
  label="Model",
40
  ),
41
+ gr.Slider(minimum=320, maximum=1280, value=640, step=32, label="Image Size"),
42
+ gr.Slider(minimum=0.0, maximum=1.0, value=0.25, step=0.05, label="Confidence Threshold"),
43
+ gr.Slider(minimum=0.0, maximum=1.0, value=0.45, step=0.05, label="IOU Threshold"),
44
  ]
45
 
46
+ outputs = gr.Image(type="filepath", label="Output Image")
47
  title = "Project-350: BD Vehicle Detection for Autonomous Vehicle"
48
 
 
49
  demo_app = gr.Interface(
50
  fn=yolov7_inference,
51
  inputs=inputs,
52
  outputs=outputs,
53
  title=title,
 
54
  cache_examples=True,
55
+ theme="dark",
56
  )
57
+ demo_app.launch(debug=True, queue=True)