Spaces:
Sleeping
Sleeping
YonaniCodes commited on
Commit ·
a91136c
1
Parent(s): 4ee7a4c
app.py
CHANGED
|
@@ -8,7 +8,7 @@ from PIL import Image, ImageDraw, ImageFont
|
|
| 8 |
# Register the custom layer
|
| 9 |
tf.keras.utils.get_custom_objects().update({'KerasLayer': hub.KerasLayer})
|
| 10 |
|
| 11 |
-
#
|
| 12 |
model = tf.keras.models.load_model("dog_breed_model.h5")
|
| 13 |
|
| 14 |
def load_breeds(file_path='unique_breeds.json'):
|
|
@@ -40,6 +40,11 @@ def predict_breed(image):
|
|
| 40 |
|
| 41 |
# Draw the prediction and confidence over the image
|
| 42 |
img_with_text = image.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
draw = ImageDraw.Draw(img_with_text)
|
| 44 |
|
| 45 |
# Set font for drawing text (ensure you have a suitable font installed)
|
|
|
|
| 8 |
# Register the custom layer
|
| 9 |
tf.keras.utils.get_custom_objects().update({'KerasLayer': hub.KerasLayer})
|
| 10 |
|
| 11 |
+
# Load the model
|
| 12 |
model = tf.keras.models.load_model("dog_breed_model.h5")
|
| 13 |
|
| 14 |
def load_breeds(file_path='unique_breeds.json'):
|
|
|
|
| 40 |
|
| 41 |
# Draw the prediction and confidence over the image
|
| 42 |
img_with_text = image.copy()
|
| 43 |
+
|
| 44 |
+
# Convert to RGB mode if it's not
|
| 45 |
+
if img_with_text.mode != 'RGB':
|
| 46 |
+
img_with_text = img_with_text.convert('RGB')
|
| 47 |
+
|
| 48 |
draw = ImageDraw.Draw(img_with_text)
|
| 49 |
|
| 50 |
# Set font for drawing text (ensure you have a suitable font installed)
|