Shubhambansal2 commited on
Commit
6fc0a14
·
verified ·
1 Parent(s): 4dd712b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -6,8 +6,6 @@ from fastbook import PILImage
6
  # Load the pretrained FastAI model
7
  learn = load_learner("model.pkl")
8
 
9
-
10
-
11
  def classify_image(image):
12
  # Convert Gradio input to PIL Image
13
  image_pil = Image.fromarray(image.astype('uint8'), 'RGB')
@@ -18,12 +16,12 @@ def classify_image(image):
18
  # Perform inference
19
  classification,_,probs = learn.predict(PILImage.create('temp_image.jpg'))
20
 
21
- return f"Predicted class: {classification}, Probabilities: {probs:.2f}"
22
 
23
  # Define Gradio interface
24
- inputs = gr.inputs.Image(shape=(224, 224))
25
- outputs = gr.outputs.Textbox(label="Prediction")
26
- interface = gr.Interface(fn=classify_image, inputs=inputs, outputs=outputs, capture_session=True)
27
 
28
  # Run the interface
29
  interface.launch(share=True)
 
6
  # Load the pretrained FastAI model
7
  learn = load_learner("model.pkl")
8
 
 
 
9
  def classify_image(image):
10
  # Convert Gradio input to PIL Image
11
  image_pil = Image.fromarray(image.astype('uint8'), 'RGB')
 
16
  # Perform inference
17
  classification,_,probs = learn.predict(PILImage.create('temp_image.jpg'))
18
 
19
+ return f"This is a {classification}"
20
 
21
  # Define Gradio interface
22
+ inputs = gr.Image()
23
+ label = gr.Textbox(label="Prediction")
24
+ interface = gr.Interface(fn=classify_image, inputs=inputs, outputs=label)
25
 
26
  # Run the interface
27
  interface.launch(share=True)