Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,10 @@ import tensorflow as tf
|
|
3 |
import numpy as np
|
4 |
from PIL import Image
|
5 |
|
6 |
-
# Load
|
7 |
-
transfer_learning_model = tf.keras.models.load_model('
|
8 |
|
9 |
-
# Class names
|
10 |
class_names = ['butterfly', 'cat', 'elephant', 'horse', 'squirrel']
|
11 |
|
12 |
def classify_image(image, model):
|
@@ -15,7 +15,7 @@ def classify_image(image, model):
|
|
15 |
image = Image.fromarray(image.astype('uint8'), 'RGB')
|
16 |
|
17 |
# Resize the image using np.resize
|
18 |
-
image = np.resize(image, (
|
19 |
|
20 |
image = image / 255.0 # Normalize the image
|
21 |
image = np.expand_dims(image, axis=0) # Add batch dimension
|
@@ -40,7 +40,7 @@ transfer_learning_interface = gr.Interface(
|
|
40 |
inputs=image_input,
|
41 |
outputs=label,
|
42 |
title='Animal Classifier',
|
43 |
-
description='Upload an image of an
|
44 |
)
|
45 |
|
46 |
transfer_learning_interface.launch()
|
|
|
3 |
import numpy as np
|
4 |
from PIL import Image
|
5 |
|
6 |
+
# Load the custom classification models
|
7 |
+
transfer_learning_model = tf.keras.models.load_model('model_vgg16.keras')
|
8 |
|
9 |
+
# Class names
|
10 |
class_names = ['butterfly', 'cat', 'elephant', 'horse', 'squirrel']
|
11 |
|
12 |
def classify_image(image, model):
|
|
|
15 |
image = Image.fromarray(image.astype('uint8'), 'RGB')
|
16 |
|
17 |
# Resize the image using np.resize
|
18 |
+
image = np.resize(image, (300, 300, 3)) # Add the channel dimension
|
19 |
|
20 |
image = image / 255.0 # Normalize the image
|
21 |
image = np.expand_dims(image, axis=0) # Add batch dimension
|
|
|
40 |
inputs=image_input,
|
41 |
outputs=label,
|
42 |
title='Animal Classifier',
|
43 |
+
description='Upload an image of a butterfly, a cat, an elephant, a horse or a squirrel, and the classifier will tell you which animal it is, along with the confidence level of the prediction.'
|
44 |
)
|
45 |
|
46 |
transfer_learning_interface.launch()
|