offthewallace commited on
Commit
8be80ef
·
1 Parent(s): d4cbb06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -1,9 +1,17 @@
1
  import gradio as gr
2
  import torch
3
-
4
  from PIL import Image
5
 
6
- model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt', force_reload=True)
 
 
 
 
 
 
 
 
 
7
 
8
  def detect(image):
9
  results = model(image)
 
1
  import gradio as gr
2
  import torch
 
3
  from PIL import Image
4
 
5
+ model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt', source="local")
6
+
7
+
8
+ def yolo(im, size=640):
9
+ g = (size / max(im.size)) # gain
10
+ im = im.resize((int(x * g) for x in im.size), Image.BICUBIC) # resize
11
+
12
+ results = model(im) # inference
13
+ results.render() # updates results.imgs with boxes and labels
14
+ return Image.fromarray(results.imgs[0])
15
 
16
  def detect(image):
17
  results = model(image)