Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,12 +11,16 @@ ImageFile.LOAD_TRUNCATED_IMAGES = True
|
|
| 11 |
new_model = tf.keras.models.load_model('tree-not-tree.keras')
|
| 12 |
|
| 13 |
def TreeOrNotTree(img):
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
# Reshape to add batch dimension (1, 128, 128, 3)
|
| 20 |
img_array = np.expand_dims(img_array, axis=0)
|
| 21 |
|
| 22 |
# Make prediction
|
|
|
|
| 11 |
new_model = tf.keras.models.load_model('tree-not-tree.keras')
|
| 12 |
|
| 13 |
def TreeOrNotTree(img):
|
| 14 |
+
# Convert PIL image to a numpy array (RGB format)
|
| 15 |
+
img_array = np.array(img)
|
| 16 |
+
|
| 17 |
+
# Resize the image to the expected input size (128x128) using cv2
|
| 18 |
+
img_array = cv2.resize(img_array, (128, 128))
|
| 19 |
+
|
| 20 |
+
# Normalize the image
|
| 21 |
+
img_array = img_array / 255.0
|
| 22 |
|
| 23 |
+
# Reshape to add batch dimension (1, 128, 128, 3)
|
| 24 |
img_array = np.expand_dims(img_array, axis=0)
|
| 25 |
|
| 26 |
# Make prediction
|