SagarPuniyani commited on
Commit
1d0c7f1
·
verified ·
1 Parent(s): 2ec730e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -33
app.py CHANGED
@@ -1,32 +1,3 @@
1
- # import gradio as gr
2
- # from fastai.vision.all import *
3
- # import timm
4
-
5
- # # Load the exported model
6
- # learn = load_learner('./efficientnet_b3_model.pkl', cpu=True) # Using cpu=True for compatibility
7
-
8
- # learn.export('./efficientnet_b3_model.pkl') # export_model(learn, 'efficientnet_b3_model.pkl')
9
-
10
-
11
- # # Define the prediction function
12
- # def classify_image(image):
13
- # pred, idx, probs = learn.predict(image)
14
- # # Return the top 3 predictions with their probabilities
15
- # return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))}
16
-
17
- # # Set up the Gradio interface
18
- # interface = gr.Interface(
19
- # fn=classify_image, # Function to make predictions
20
- # inputs=gr.Image(type="pil"), # Input as an image in PIL format
21
- # outputs=gr.Label(num_top_classes=3), # Output shows top 3 predicted classes
22
- # title="EfficientNet B3 Image Classifier",
23
- # description="Upload an image to classify using the trained EfficientNet B3 model."
24
- # )
25
-
26
- # # Launch the Gradio app
27
- # if __name__ == "__main__":
28
- # interface.launch(share=True) # `share=True` makes the app publicly accessible
29
-
30
  from pathlib import Path
31
  from fastai.vision.all import *
32
  import gradio as gr
@@ -46,10 +17,7 @@ def classify_image(image):
46
  interface = gr.Interface(
47
  fn=classify_image,
48
  inputs=gr.Image(type="pil"),
49
- outputs=[
50
- gr.Label(num_top_classes=3),
51
- gr.Textbox(value="The prediction results above represent the top 3 cancer stages."),
52
- ],
53
  title="EfficientNet B3 Image Classifier",
54
  description="Upload an image to classify using the trained EfficientNet B3 model."
55
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from pathlib import Path
2
  from fastai.vision.all import *
3
  import gradio as gr
 
17
  interface = gr.Interface(
18
  fn=classify_image,
19
  inputs=gr.Image(type="pil"),
20
+ outputs=gr.Label(num_top_classes=3),
 
 
 
21
  title="EfficientNet B3 Image Classifier",
22
  description="Upload an image to classify using the trained EfficientNet B3 model."
23
  )