bauckluc commited on
Commit
b761786
1 Parent(s): 2453fc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -7,7 +7,7 @@ model_path = "DogClassifier2.4.keras"
7
  model = tf.keras.models.load_model(model_path)
8
 
9
  # Define the core prediction function
10
- def predict_bmwX(image):
11
  # Preprocess image
12
  image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
13
  image = image.convert("RGB") # Ensure the image is in RGB format
@@ -35,10 +35,6 @@ def predict_bmwX(image):
35
  'Poodle', 'Pug', 'Rhodesian', 'Rottweiler', 'Saint Bernard', 'Schnauzer', 'Scotch Terrier', 'Shar_Pei',
36
  'Shiba Inu', 'Shih-Tzu', 'Siberian Husky', 'Vizsla', 'Yorkie']
37
 
38
- # Check if the number of predictions matches the number of class names
39
- if len(prediction[0]) != len(class_names):
40
- return f"Error: Number of model outputs ({len(prediction[0])}) does not match number of class names ({len(class_names)})."
41
-
42
  # Apply threshold and set probabilities lower than 0.015 to 0.0
43
  threshold = 0.01395
44
  prediction = np.array(prediction)
@@ -59,8 +55,8 @@ def predict_bmwX(image):
59
 
60
  input_image = gr.Image()
61
  iface = gr.Interface(
62
- fn=predict_bmwX,
63
  inputs=input_image,
64
  outputs=gr.Label(),
65
- description="A simple MLP classification model for image classification using the MNIST dataset.")
66
  iface.launch(share=True)
 
7
  model = tf.keras.models.load_model(model_path)
8
 
9
  # Define the core prediction function
10
+ def predict_breed(image):
11
  # Preprocess image
12
  image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
13
  image = image.convert("RGB") # Ensure the image is in RGB format
 
35
  'Poodle', 'Pug', 'Rhodesian', 'Rottweiler', 'Saint Bernard', 'Schnauzer', 'Scotch Terrier', 'Shar_Pei',
36
  'Shiba Inu', 'Shih-Tzu', 'Siberian Husky', 'Vizsla', 'Yorkie']
37
 
 
 
 
 
38
  # Apply threshold and set probabilities lower than 0.015 to 0.0
39
  threshold = 0.01395
40
  prediction = np.array(prediction)
 
55
 
56
  input_image = gr.Image()
57
  iface = gr.Interface(
58
+ fn=predict_breed,
59
  inputs=input_image,
60
  outputs=gr.Label(),
61
+ description="A simple classification model for determining a dog breed.")
62
  iface.launch(share=True)