rrighart commited on
Commit
61ab183
1 Parent(s): ed034b9

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ import torch
4
+
5
+ ###############
6
+
7
+ def yolov7_inference(
8
+ image: gr.inputs.Image = None,
9
+
10
+ ):
11
+
12
+ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
13
+ path = 'y7-prdef.pt'
14
+ model = torch.hub.load("WongKinYiu/yolov7","custom",f"{path}")
15
+
16
+ results = model([image], size=640)
17
+ return results.render()[0]
18
+
19
+
20
+ inputs = [
21
+ gr.inputs.Image(type="pil", label="Input Image"),
22
+ ]
23
+
24
+
25
+ demo_app = gr.Interface(
26
+ fn=yolov7_inference,
27
+ inputs=inputs,
28
+ outputs=gr.outputs.Image(type="filepath", label="Output Image"),
29
+ title="Yolov7 | Jar lid product defects",
30
+ examples=['t1.JPG'],
31
+ cache_examples=True,
32
+ )
33
+ demo_app.launch(debug=True, enable_queue=True)
34
+