Jahnavibh Claude commited on
Commit
41b21ec
·
1 Parent(s): 0201f9e

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]>

Files changed (1) hide show
  1. app.py +4 -2
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
- # Normalize to [0, 255] for uint8 input
54
- img_array = np.clip(img_array, 0, 255).astype(np.uint8)
 
 
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)