Update app.py
Browse files
app.py
CHANGED
@@ -4,14 +4,14 @@ from PIL import Image
|
|
4 |
import numpy as np
|
5 |
|
6 |
# Load the dog breed classifier model
|
7 |
-
model_path = "
|
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((
|
15 |
image = np.array(image)
|
16 |
image = image / 255.0 # Normalization of pixel values
|
17 |
return image
|
@@ -28,7 +28,9 @@ def predict_dog_breed(image):
|
|
28 |
# Create Gradio interface
|
29 |
input_image = gr.Image()
|
30 |
output_text = gr.Textbox(label="Dog Breed")
|
31 |
-
interface = gr.Interface(fn=predict_dog_breed, inputs=input_image, outputs=output_text,
|
|
|
|
|
32 |
|
33 |
if __name__ == "__main__":
|
34 |
interface.launch()
|
|
|
4 |
import numpy as np
|
5 |
|
6 |
# Load the dog breed classifier model
|
7 |
+
model_path = "best_model.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((150, 150))
|
15 |
image = np.array(image)
|
16 |
image = image / 255.0 # Normalization of pixel values
|
17 |
return image
|
|
|
28 |
# Create Gradio interface
|
29 |
input_image = gr.Image()
|
30 |
output_text = gr.Textbox(label="Dog Breed")
|
31 |
+
interface = gr.Interface(fn=predict_dog_breed, inputs=input_image, outputs=output_text,
|
32 |
+
description="A dog breed classifier using a custom CNN model with data augmentation and regularization techniques.",
|
33 |
+
theme="default")
|
34 |
|
35 |
if __name__ == "__main__":
|
36 |
interface.launch()
|