Spaces:
Runtime error
Runtime error
Commit
·
1e3d80a
1
Parent(s):
fbcd3b4
Update app.py
Browse files
app.py
CHANGED
@@ -6,16 +6,8 @@ from sklearn.tree import DecisionTreeClassifier
|
|
6 |
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier, GradientBoostingClassifier
|
7 |
import joblib
|
8 |
import pickle
|
9 |
-
from PIL import Image
|
10 |
|
11 |
-
|
12 |
-
"""
|
13 |
-
Load image from file path and convert to numpy array
|
14 |
-
"""
|
15 |
-
with Image.open(image_path).convert('L') as img:
|
16 |
-
img = img.resize((28,28))
|
17 |
-
img = np.array(img)
|
18 |
-
return img
|
19 |
|
20 |
|
21 |
def fashion_MNIST_prediction(test_image, model='KNN'):
|
@@ -62,14 +54,7 @@ def fashion_MNIST_prediction(test_image, model='KNN'):
|
|
62 |
|
63 |
else:
|
64 |
return "Invalid Model Selection"
|
65 |
-
|
66 |
-
def predict(image_path, model):
|
67 |
-
test_image = load_image(image_path)
|
68 |
-
label, prediction = fashion_MNIST_prediction(test_image, model)
|
69 |
-
return label, prediction
|
70 |
-
|
71 |
-
image_paths = ['Ankle boot.jpg', 'bag.jpg', 'dress.jpg', 't-shirt.jpg']
|
72 |
-
###
|
73 |
|
74 |
input_image = gr.inputs.Image(shape=(28, 28), image_mode='L')
|
75 |
input_model = gr.inputs.Dropdown(['KNN', 'DecisionTreeClassifier', 'RandomForestClassifier', 'AdaBoostClassifier', 'GradientBoostingClassifier'])
|
|
|
6 |
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier, GradientBoostingClassifier
|
7 |
import joblib
|
8 |
import pickle
|
|
|
9 |
|
10 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
|
13 |
def fashion_MNIST_prediction(test_image, model='KNN'):
|
|
|
54 |
|
55 |
else:
|
56 |
return "Invalid Model Selection"
|
57 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
input_image = gr.inputs.Image(shape=(28, 28), image_mode='L')
|
60 |
input_model = gr.inputs.Dropdown(['KNN', 'DecisionTreeClassifier', 'RandomForestClassifier', 'AdaBoostClassifier', 'GradientBoostingClassifier'])
|