LuisCe commited on
Commit
c0a7d9c
·
verified ·
1 Parent(s): 0fb07d6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.learner import load_learner
3
+ from PIL import Image
4
+
5
+ # Load the learner
6
+ learn_inf = load_learner("LuisCe/Practica03")
7
+
8
+ # Define the prediction function
9
+ def predict_image(img):
10
+ # Convert the PIL image to a format that fastai expects
11
+ img_fastai = Image.fromarray(img.astype('uint8'), 'RGB')
12
+ # Make prediction
13
+ pred, _, _ = learn_inf.predict(img_fastai)
14
+ # Return prediction
15
+ return pred
16
+
17
+ # Create Gradio interface
18
+ gr.Interface(predict_image,
19
+ inputs="image",
20
+ outputs="text",
21
+ title="Grape Segmentation",
22
+ description="Segment grapes in the image.",
23
+ theme="compact",
24
+ allow_flagging=False).launch()