Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,10 +10,11 @@ model = tf.keras.models.load_model("car_brand_classifier_final.h5", compile=Fals
|
|
| 10 |
# Define image directory where car brand images are stored
|
| 11 |
IMAGE_DIR = "car_brands" # Make sure this folder exists with images named as class labels
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
def preprocess_image(
|
| 15 |
-
image =
|
| 16 |
-
image =
|
|
|
|
| 17 |
image = np.expand_dims(image, axis=0) # Add batch dimension
|
| 18 |
return image
|
| 19 |
|
|
|
|
| 10 |
# Define image directory where car brand images are stored
|
| 11 |
IMAGE_DIR = "car_brands" # Make sure this folder exists with images named as class labels
|
| 12 |
|
| 13 |
+
# Define the preprocessing function
|
| 14 |
+
def preprocess_image(image_path):
|
| 15 |
+
image = Image.open(image_path) # Open image from path
|
| 16 |
+
image = image.resize((299, 299)) # Resize to model input size
|
| 17 |
+
image = np.array(image) / 255.0 # Normalize pixel values
|
| 18 |
image = np.expand_dims(image, axis=0) # Add batch dimension
|
| 19 |
return image
|
| 20 |
|