Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,13 +9,13 @@ model = torch.jit.load(model_path, map_location=torch.device('cpu'))
|
|
9 |
model.eval()
|
10 |
|
11 |
# Define a function to preprocess images to match the expected input shape
|
|
|
12 |
def preprocess_image(image):
|
13 |
-
# Resize the image to a fixed size (e.g.,
|
14 |
-
image = image.resize((
|
15 |
|
16 |
-
# Convert to RGB
|
17 |
-
|
18 |
-
input_tensor = np.array(image) / 255.0
|
19 |
|
20 |
# Add the batch dimension
|
21 |
input_tensor = input_tensor[np.newaxis, :]
|
|
|
9 |
model.eval()
|
10 |
|
11 |
# Define a function to preprocess images to match the expected input shape
|
12 |
+
|
13 |
def preprocess_image(image):
|
14 |
+
# Resize the image to a fixed size (e.g., 224x224)
|
15 |
+
image = image.resize((1024, 768))
|
16 |
|
17 |
+
# Convert to RGB (without adding extra dimensions)
|
18 |
+
input_tensor = np.array(image.convert("RGB")) / 255.0
|
|
|
19 |
|
20 |
# Add the batch dimension
|
21 |
input_tensor = input_tensor[np.newaxis, :]
|