jacksonwambali commited on
Commit
d9b8d56
·
verified ·
1 Parent(s): 6883f32

Rename app.py to app

Browse files
Files changed (1) hide show
  1. app.py → app +7 -8
app.py → app RENAMED
@@ -1,18 +1,17 @@
1
  import gradio as gr
2
  from fastai.vision.all import load_learner, PILImage
3
 
4
- # Load your learner
 
 
 
5
  learn = load_learner('export.pkl')
6
 
7
- # Define the prediction function
8
  def predict(img):
9
- img = PILImage.create(img) # Convert image into PILImage
10
- pred, pred_idx, probs = learn.predict(img) # Make prediction
11
- labels = learn.dls.vocab # Get the labels
12
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
 
14
- # Define the Gradio interface
15
  interface = gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label(num_top_classes=3))
16
-
17
- # Launch the interface
18
  interface.launch(share=True)
 
1
  import gradio as gr
2
  from fastai.vision.all import load_learner, PILImage
3
 
4
+ # Import any custom code here (if needed)
5
+ # Example:
6
+ # from your_module import CustomTransform, CustomModel
7
+
8
  learn = load_learner('export.pkl')
9
 
 
10
  def predict(img):
11
+ img = PILImage.create(img)
12
+ pred, pred_idx, probs = learn.predict(img)
13
+ labels = learn.dls.vocab
14
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
15
 
 
16
  interface = gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label(num_top_classes=3))
 
 
17
  interface.launch(share=True)