JosephTK commited on
Commit
25f2f9b
1 Parent(s): 9761ba8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -19,8 +19,15 @@ colors = ["red",
19
  "slategray",
20
  ]
21
 
22
- def detect(image):
23
- inputs = image_processor(images=image, return_tensors="pt")
 
 
 
 
 
 
 
24
  outputs = model(**inputs)
25
 
26
  # convert outputs to COCO API
@@ -64,7 +71,7 @@ def detect(image):
64
  demo = gr.Interface(
65
  fn=detect,
66
  examples=["examples/football.jpg", "examples/cats.jpg"],
67
- inputs=[gr.inputs.Image(label="Input image", type="pil", shape=(400, 360))],
68
  outputs=[gr.Image(label="Output image"), gr.BarPlot(show_label=False, x="label", y="counts", x_title="Labels", y_title="Counts", vertical=False), gr.Textbox(show_label=False)],
69
  title="YOLO Object Detection",
70
  )
 
19
  "slategray",
20
  ]
21
 
22
+ def detect(image):
23
+ # Change width to 640 pixels
24
+ #h, w, c = image.shape
25
+ #scale = 640 / w
26
+
27
+ inputs = image_processor(images=image,
28
+ do_resize=True,
29
+ size={"longest_edge": 640},
30
+ return_tensors="pt")
31
  outputs = model(**inputs)
32
 
33
  # convert outputs to COCO API
 
71
  demo = gr.Interface(
72
  fn=detect,
73
  examples=["examples/football.jpg", "examples/cats.jpg"],
74
+ inputs=[gr.inputs.Image(label="Input image", type="pil"],
75
  outputs=[gr.Image(label="Output image"), gr.BarPlot(show_label=False, x="label", y="counts", x_title="Labels", y_title="Counts", vertical=False), gr.Textbox(show_label=False)],
76
  title="YOLO Object Detection",
77
  )