Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -332,11 +332,13 @@ async def predict_tomato(file: UploadFile = File(...)):
|
|
| 332 |
# 4. Turn the matrix back into an image so the rest of the code can use it
|
| 333 |
#image = Image.fromarray(image_array)
|
| 334 |
|
|
|
|
| 335 |
# 1. Standard Resize
|
| 336 |
image = image.resize((224, 224))
|
| 337 |
|
| 338 |
# 2. Custom Normalization: Converting [0, 255] to [-1.0, 1.0]
|
| 339 |
-
input_data = np.array(image).astype(np.float32)
|
|
|
|
| 340 |
input_data = np.expand_dims(input_data, axis=0)
|
| 341 |
|
| 342 |
# --- RUN INFERENCE ---
|
|
|
|
| 332 |
# 4. Turn the matrix back into an image so the rest of the code can use it
|
| 333 |
#image = Image.fromarray(image_array)
|
| 334 |
|
| 335 |
+
|
| 336 |
# 1. Standard Resize
|
| 337 |
image = image.resize((224, 224))
|
| 338 |
|
| 339 |
# 2. Custom Normalization: Converting [0, 255] to [-1.0, 1.0]
|
| 340 |
+
input_data = np.array(image).astype(np.float32)
|
| 341 |
+
input_data = (input_data / 127.5) - 1.0
|
| 342 |
input_data = np.expand_dims(input_data, axis=0)
|
| 343 |
|
| 344 |
# --- RUN INFERENCE ---
|