Spaces:
Sleeping
Sleeping
Fix input type mismatch - convert to INT8
Browse files- Model expects INT8 input, not UINT8
- Convert pixel values from [0, 255] to [-128, 127] range
- Cast to np.int8 as required by the model
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
app.py
CHANGED
|
@@ -50,8 +50,10 @@ def preprocess_image(image):
|
|
| 50 |
# Convert to numpy array
|
| 51 |
img_array = np.array(image, dtype=np.float32)
|
| 52 |
|
| 53 |
-
#
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
|
| 56 |
# Add batch dimension
|
| 57 |
img_array = np.expand_dims(img_array, axis=0)
|
|
|
|
| 50 |
# Convert to numpy array
|
| 51 |
img_array = np.array(image, dtype=np.float32)
|
| 52 |
|
| 53 |
+
# Convert to INT8 input as expected by the model
|
| 54 |
+
# First normalize to [-128, 127] range
|
| 55 |
+
img_array = img_array.astype(np.float32)
|
| 56 |
+
img_array = (img_array - 128.0).astype(np.int8)
|
| 57 |
|
| 58 |
# Add batch dimension
|
| 59 |
img_array = np.expand_dims(img_array, axis=0)
|