Farid Rener
commited on
Commit
·
4071bec
1
Parent(s):
c018454
Better
Browse files- app.py +3 -9
- requirements.txt +0 -2
app.py
CHANGED
@@ -1,21 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
import pickle
|
3 |
-
import numpy as np
|
4 |
from PIL import Image
|
|
|
5 |
from fastai.learner import load_learner
|
6 |
|
7 |
model = load_learner('./mushrooms.pkl')
|
8 |
|
9 |
# Function to preprocess image and classify
|
10 |
def classify_image(image):
|
11 |
-
|
12 |
-
|
13 |
-
image_array = image_array.reshape(1, -1) # Reshape if needed (depends on model)
|
14 |
-
|
15 |
-
# Run model prediction
|
16 |
-
prediction = model.predict(image_array)
|
17 |
-
|
18 |
-
return str(prediction[0]) # Return predicted class
|
19 |
|
20 |
# Gradio Interface
|
21 |
iface = gr.Interface(
|
|
|
1 |
import gradio as gr
|
2 |
import pickle
|
|
|
3 |
from PIL import Image
|
4 |
+
|
5 |
from fastai.learner import load_learner
|
6 |
|
7 |
model = load_learner('./mushrooms.pkl')
|
8 |
|
9 |
# Function to preprocess image and classify
|
10 |
def classify_image(image):
|
11 |
+
prediction, _, probs = model.predict(image)
|
12 |
+
return str(prediction) + str(probs) # Return predicted class
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Gradio Interface
|
15 |
iface = gr.Interface(
|
requirements.txt
CHANGED
@@ -1,4 +1,2 @@
|
|
1 |
fastai
|
2 |
-
torch
|
3 |
gradio
|
4 |
-
numpy
|
|
|
1 |
fastai
|
|
|
2 |
gradio
|
|