Sa-m commited on
Commit
b79f841
1 Parent(s): 2fafbac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -20,13 +20,15 @@ def find(name, path):
20
 
21
  model = torch.hub.load('ultralytics/yolov5', 'custom', path='Content/best.pt', force_reload=True)
22
  def detect(inp):
23
- output=model(inp)
24
- outPath='./yolov5/runs/detect/exp/'+inp.split('/')[2]
25
- #out_path='./yolov5/runs/detect/exp/'+inp_vid.split('/')[2]
26
- return outPath
27
-
28
- inp=gr.inputs.Image()
29
- output=gr.outputs.Image()
 
 
30
 
31
 
32
  io=gr.Interface(fn=detect, inputs=inp, outputs=output, title='Party Symbol Detection',examples=['Content/4.jpg'])
 
20
 
21
  model = torch.hub.load('ultralytics/yolov5', 'custom', path='Content/best.pt', force_reload=True)
22
  def detect(inp):
23
+ g = (size / max(inp.size)) # gain
24
+ #im = im.resize((int(x * g) for x in im.size), Image.ANTIALIAS) # resize
25
+ results = model(inp) # inference
26
+ results.render() # updates results.imgs with boxes and labels
27
+ return Image.fromarray(results.imgs[0])
28
+
29
+
30
+ inp = gr.inputs.Image(type='pil', label="Original Image")
31
+ output = gr.outputs.Image(type="pil", label="Output Image")
32
 
33
 
34
  io=gr.Interface(fn=detect, inputs=inp, outputs=output, title='Party Symbol Detection',examples=['Content/4.jpg'])