Update app.py
Browse files
app.py
CHANGED
@@ -6,14 +6,14 @@ import numpy as np
|
|
6 |
# Load the dog breed classifier model
|
7 |
model_path = "dog_breed_classifier_trained.keras"
|
8 |
model = tf.keras.models.load_model(model_path)
|
9 |
-
labels = ['
|
10 |
|
11 |
# Define function for dog breed classification with data augmentation
|
12 |
def preprocess_image(image):
|
13 |
image = Image.fromarray(image.astype('uint8'), 'RGB')
|
14 |
-
image = image.resize((128, 128))
|
15 |
image = np.array(image)
|
16 |
-
image = image / 255.0 #
|
17 |
return image
|
18 |
|
19 |
# Prediction function
|
@@ -22,7 +22,7 @@ def predict_dog_breed(image):
|
|
22 |
prediction = model.predict(np.expand_dims(image, axis=0))
|
23 |
predicted_class = labels[np.argmax(prediction)]
|
24 |
confidence = np.round(np.max(prediction) * 100, 2)
|
25 |
-
result = f"
|
26 |
return result
|
27 |
|
28 |
# Create Gradio interface
|
|
|
6 |
# Load the dog breed classifier model
|
7 |
model_path = "dog_breed_classifier_trained.keras"
|
8 |
model = tf.keras.models.load_model(model_path)
|
9 |
+
labels = ['Beagle', 'French Bulldog', 'German Shepherd', 'Golden Retriever', 'Labrador Retriever']
|
10 |
|
11 |
# Define function for dog breed classification with data augmentation
|
12 |
def preprocess_image(image):
|
13 |
image = Image.fromarray(image.astype('uint8'), 'RGB')
|
14 |
+
image = image.resize((128, 128))
|
15 |
image = np.array(image)
|
16 |
+
image = image / 255.0 # Normalization of pixel values
|
17 |
return image
|
18 |
|
19 |
# Prediction function
|
|
|
22 |
prediction = model.predict(np.expand_dims(image, axis=0))
|
23 |
predicted_class = labels[np.argmax(prediction)]
|
24 |
confidence = np.round(np.max(prediction) * 100, 2)
|
25 |
+
result = f"{predicted_class}, Confidence: {confidence}%"
|
26 |
return result
|
27 |
|
28 |
# Create Gradio interface
|