Update food_identification.py
Browse files- food_identification.py +2 -2
food_identification.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import tensorflow as tf
|
| 2 |
import tensorflow_hub as hub
|
| 3 |
import json
|
| 4 |
import numpy as np
|
|
@@ -21,7 +21,7 @@ def identify_food(image):
|
|
| 21 |
"""
|
| 22 |
# Preprocess image
|
| 23 |
image = image.resize((224, 224)) # Resize for model compatibility
|
| 24 |
-
image_array = np.array(image) / 255.0 # Normalize
|
| 25 |
image_array = np.expand_dims(image_array, axis=0) # Add batch dimension
|
| 26 |
|
| 27 |
# Predict using the model
|
|
|
|
| 1 |
+
import tensorflow as tf
|
| 2 |
import tensorflow_hub as hub
|
| 3 |
import json
|
| 4 |
import numpy as np
|
|
|
|
| 21 |
"""
|
| 22 |
# Preprocess image
|
| 23 |
image = image.resize((224, 224)) # Resize for model compatibility
|
| 24 |
+
image_array = np.array(image, dtype=np.float32) / 255.0 # Normalize and convert to float32
|
| 25 |
image_array = np.expand_dims(image_array, axis=0) # Add batch dimension
|
| 26 |
|
| 27 |
# Predict using the model
|