DevashishBhake commited on
Commit
5604609
β€’
1 Parent(s): 564e3a4

new file: app.py

Browse files
Files changed (2) hide show
  1. app.py +19 -0
  2. best.pt +3 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from PIL import Image
4
+ import numpy as np
5
+
6
+ model = torch.hub.load('ultralytics/yolov5', 'custom', path=r'./best.pt', force_reload=True)
7
+
8
+ def yolo(im, size=512):
9
+ g = (size / max(im.size)) # gain
10
+ im = im.resize((int(x * g) for x in im.size), Image.ANTIALIAS) # resize
11
+
12
+ results = model(im) # inference
13
+ results.render() # updates results.imgs with boxes and labels
14
+ return Image.fromarray(results.ims[0])
15
+
16
+ gr.Interface(fn=yolo,
17
+ inputs=gr.inputs.Image(type = "pil", label = "Original Image"),
18
+ outputs=gr.outputs.Image(type = "pil", label = "Output Image")).launch()
19
+
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:65c0a558b56fb8695ed0160524bb35c86c07be6e8d31330a69cbacb09cdee7fb
3
+ size 42128361