kiki7555 commited on
Commit
4691a60
1 Parent(s): 1ea602b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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 = ['Rasse 1', 'Rasse 2', 'Rasse 3', 'Rasse 4', 'Rasse 5'] # Ersetzen Sie dies durch Ihre tatsächlichen Rassennamen
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)) # Entspricht der Größe aus Ihrem Notebook
15
  image = np.array(image)
16
- image = image / 255.0 # Normalisierung der Pixelwerte
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"Breed: {predicted_class}, Confidence: {confidence}%"
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