Spaces:
Sleeping
Sleeping
new
Browse files
app.py
CHANGED
|
@@ -9,6 +9,10 @@ model = load_model('cats_and_dogs_classifier.h5')
|
|
| 9 |
|
| 10 |
# Define prediction function
|
| 11 |
def predict(image):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
# Resize image to match model's expected sizing (150x150 pixels)
|
| 13 |
img = image.resize((150, 150))
|
| 14 |
# Convert image to array and expand dimensions to fit model input requirements
|
|
@@ -23,3 +27,4 @@ def predict(image):
|
|
| 23 |
# Create a Gradio interface
|
| 24 |
interface = gr.Interface(fn=predict, inputs="image", outputs="text")
|
| 25 |
interface.launch()
|
|
|
|
|
|
| 9 |
|
| 10 |
# Define prediction function
|
| 11 |
def predict(image):
|
| 12 |
+
# Ensure the image is a PIL Image object
|
| 13 |
+
if isinstance(image, np.ndarray):
|
| 14 |
+
image = Image.fromarray(image)
|
| 15 |
+
|
| 16 |
# Resize image to match model's expected sizing (150x150 pixels)
|
| 17 |
img = image.resize((150, 150))
|
| 18 |
# Convert image to array and expand dimensions to fit model input requirements
|
|
|
|
| 27 |
# Create a Gradio interface
|
| 28 |
interface = gr.Interface(fn=predict, inputs="image", outputs="text")
|
| 29 |
interface.launch()
|
| 30 |
+
|