hillol7 commited on
Commit
3e2bc02
·
verified ·
1 Parent(s): fef88a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -1,20 +1,19 @@
1
  import gradio as gr
2
  from fastai.vision.all import load_learner, PILImage
3
- import torch
4
-
5
  learn = load_learner('model.pkl')
6
 
7
  def classify_image(image):
8
- pred, pred_idx, probs = learn.predict(image)
9
  return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))}
10
 
11
  interface = gr.Interface(
12
  fn=classify_image,
13
- inputs=gr.inputs.Image(type='pil'),
14
- outputs=gr.outputs.Label(num_top_classes=3),
15
  title="Potato Plant Disease Classifier",
16
- description="Potato leaf: "
17
  )
18
 
19
  if __name__ == "__main__":
20
- interface.launch()
 
1
  import gradio as gr
2
  from fastai.vision.all import load_learner, PILImage
3
+
 
4
  learn = load_learner('model.pkl')
5
 
6
  def classify_image(image):
7
+ pred, _, probs = learn.predict(image)
8
  return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))}
9
 
10
  interface = gr.Interface(
11
  fn=classify_image,
12
+ inputs=gr.Image(type='pil'), # Updated to new API
13
+ outputs=gr.Label(num_top_classes=3), # Updated to new API
14
  title="Potato Plant Disease Classifier",
15
+ description="Potato leaf:"
16
  )
17
 
18
  if __name__ == "__main__":
19
+ interface.launch(share=True)