Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,9 +8,9 @@ model = tf.keras.models.load_model("car_brand_classifier_final.h5")
|
|
| 8 |
|
| 9 |
# Define the preprocessing function
|
| 10 |
def preprocess_image(image):
|
| 11 |
-
if isinstance(image,
|
| 12 |
-
image = Image.
|
| 13 |
-
|
| 14 |
image = image.convert("RGB") # Ensure it's in RGB mode
|
| 15 |
image = image.resize((299, 299)) # Resize to match model input size
|
| 16 |
image = np.array(image) / 255.0 # Normalize pixel values
|
|
@@ -32,7 +32,7 @@ def predict(image):
|
|
| 32 |
# Create the Gradio interface
|
| 33 |
iface = gr.Interface(
|
| 34 |
fn=predict,
|
| 35 |
-
inputs="
|
| 36 |
outputs="text",
|
| 37 |
title="Car Vision",
|
| 38 |
description="Upload an image of a car to classify its brand."
|
|
|
|
| 8 |
|
| 9 |
# Define the preprocessing function
|
| 10 |
def preprocess_image(image):
|
| 11 |
+
if isinstance(image, np.ndarray): # If Gradio gives a NumPy array, convert it to PIL Image
|
| 12 |
+
image = Image.fromarray(image)
|
| 13 |
+
|
| 14 |
image = image.convert("RGB") # Ensure it's in RGB mode
|
| 15 |
image = image.resize((299, 299)) # Resize to match model input size
|
| 16 |
image = np.array(image) / 255.0 # Normalize pixel values
|
|
|
|
| 32 |
# Create the Gradio interface
|
| 33 |
iface = gr.Interface(
|
| 34 |
fn=predict,
|
| 35 |
+
inputs=gr.Image(type="numpy"), # Ensure Gradio passes a NumPy array
|
| 36 |
outputs="text",
|
| 37 |
title="Car Vision",
|
| 38 |
description="Upload an image of a car to classify its brand."
|