Update app.py
Browse files
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 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
| 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'])
|