michaelwja commited on
Commit
3cbf1d1
1 Parent(s): 19dfee0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from PIL import Image
4
+
5
+ # Load the model using torch.hub (you must have the model locally)
6
+ model_name = "skin_burn.pt"
7
+ model =torch.hub.load("WongKinYiu/yolov7", 'custom',model_name)
8
+
9
+ def predict(img):
10
+ # Run inference with YOLO model
11
+ results = model(img)
12
+ # Convert the result to an image
13
+ result_img = Image.fromarray(results.render())
14
+ return result_img
15
+
16
+ # Define a Gradio interface
17
+ iface = gr.Interface(
18
+ fn=predict, # the function to wrap
19
+ inputs=gr.inputs.Image(), # input type
20
+ outputs=gr.outputs.Image() # output type
21
+ )
22
+
23
+ iface.launch()