Vwadhwa02 commited on
Commit
082c013
·
verified ·
1 Parent(s): c0218cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -16,21 +16,21 @@ model_path = Path(r'efficientnet_b3_model.pkl')
16
  learn = load_learner(model_path, cpu=True)
17
 
18
  # Define the prediction function
19
- def classify_image(image,filename):
20
  pred, idx, probs = learn.predict(image)
21
- return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))},filename
22
 
23
  # Set up the Gradio interface
24
  interface = gr.Interface(
25
  fn=classify_image,
26
- inputs=gr.File(label="Upload Image", type="image"),
27
- outputs=[gr.Label(num_top_classes=3),gr.Textbox(label=filename)],
28
  title="EfficientNet B3 Image Classifier",
29
  examples= examples,
30
  description="Upload an image to classify using the trained EfficientNet B3 model.",
31
-
32
  )
33
 
 
34
  # Launch the app
35
  if __name__ == "__main__":
36
  interface.launch(share=True)
 
16
  learn = load_learner(model_path, cpu=True)
17
 
18
  # Define the prediction function
19
+ def classify_image(image):
20
  pred, idx, probs = learn.predict(image)
21
+ return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))}
22
 
23
  # Set up the Gradio interface
24
  interface = gr.Interface(
25
  fn=classify_image,
26
+ inputs=gr.Image(type="pil"),
27
+ outputs=gr.Label(num_top_classes=3),
28
  title="EfficientNet B3 Image Classifier",
29
  examples= examples,
30
  description="Upload an image to classify using the trained EfficientNet B3 model.",
 
31
  )
32
 
33
+
34
  # Launch the app
35
  if __name__ == "__main__":
36
  interface.launch(share=True)