Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from PIL import Image
|
|
4 |
import numpy as np
|
5 |
|
6 |
# Load your custom regression model
|
7 |
-
model_path = "
|
8 |
model_path = "pokemon_model_transferlearning.keras"
|
9 |
|
10 |
#model.load_weights(model_path)
|
@@ -16,7 +16,7 @@ labels = ['Ditto','Venomoth','Venusaur']
|
|
16 |
def predict_regression(image):
|
17 |
# Preprocess image
|
18 |
image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
|
19 |
-
image = image.resize((
|
20 |
image = np.array(image)
|
21 |
print(image.shape)
|
22 |
# Predict
|
@@ -30,6 +30,6 @@ output_text = gr.Textbox(label="Predicted Pokemon")
|
|
30 |
interface = gr.Interface(fn=predict_regression,
|
31 |
inputs=input_image,
|
32 |
outputs=gr.Label(),
|
33 |
-
examples=["
|
34 |
description="A simple mlp classification model for image classification using the mnist dataset.")
|
35 |
interface.launch()
|
|
|
4 |
import numpy as np
|
5 |
|
6 |
# Load your custom regression model
|
7 |
+
model_path = "trainpokemon_model_transferlearning.weights.h5"
|
8 |
model_path = "pokemon_model_transferlearning.keras"
|
9 |
|
10 |
#model.load_weights(model_path)
|
|
|
16 |
def predict_regression(image):
|
17 |
# Preprocess image
|
18 |
image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
|
19 |
+
image = image.resize((150, 150))#.convert('L') #resize the image to 28x28 and converts it to gray scale
|
20 |
image = np.array(image)
|
21 |
print(image.shape)
|
22 |
# Predict
|
|
|
30 |
interface = gr.Interface(fn=predict_regression,
|
31 |
inputs=input_image,
|
32 |
outputs=gr.Label(),
|
33 |
+
examples=["pokemons/train/Ditto/00000008.jpg", "images/Venomoth.jpeg", "images/Venusaur.jpeg"],
|
34 |
description="A simple mlp classification model for image classification using the mnist dataset.")
|
35 |
interface.launch()
|