sum8tt commited on
Commit
c6fde95
1 Parent(s): 9ee8e98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -1,6 +1,11 @@
1
  import gradio as gr
2
  from fastai.vision.all import *
3
 
 
 
 
 
 
4
  # Load the trained model
5
  learn = load_learner('export.pkl')
6
 
@@ -10,11 +15,7 @@ def classify_waterfowl(img):
10
  return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))}
11
 
12
  # Create a Gradio interface
13
- interface = gr.Interface(
14
- fn=classify_waterfowl,
15
- inputs=gr.Image(type="pil"), # User will upload an image for classification
16
- outputs=gr.Label() # Display the model's classification label
17
- )
18
 
19
  # Launch the Gradio app
20
- interface.launch()
 
1
  import gradio as gr
2
  from fastai.vision.all import *
3
 
4
+ # Re-define the GrayscaleTransform class (same as during training)
5
+ class GrayscaleTransform(Transform):
6
+ def encodes(self, img: PILImage):
7
+ return img.convert("L") # Convert to grayscale
8
+
9
  # Load the trained model
10
  learn = load_learner('export.pkl')
11
 
 
15
  return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))}
16
 
17
  # Create a Gradio interface
18
+ interface = gr.Interface(fn=classify_waterfowl, inputs=gr.Image(type="pil"), outputs=gr.Label())
 
 
 
 
19
 
20
  # Launch the Gradio app
21
+ interface.launch()