Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -51,11 +51,11 @@ try:
|
|
51 |
except Exception as e:
|
52 |
print(f"Error loading the model: {e}")
|
53 |
|
54 |
-
# Define image preprocessing
|
55 |
transform = transforms.Compose([
|
56 |
-
transforms.Resize((224, 224)),
|
57 |
-
transforms.ToTensor(),
|
58 |
-
transforms.Normalize(mean=[0
|
59 |
])
|
60 |
|
61 |
# Prediction function
|
@@ -98,3 +98,4 @@ interface = gr.Interface(
|
|
98 |
# Launch the app
|
99 |
if __name__ == "__main__":
|
100 |
interface.launch()
|
|
|
|
51 |
except Exception as e:
|
52 |
print(f"Error loading the model: {e}")
|
53 |
|
54 |
+
# Define image preprocessing to match training preprocessing
|
55 |
transform = transforms.Compose([
|
56 |
+
transforms.Resize((224, 224)), # Resize to match model input size
|
57 |
+
transforms.ToTensor(), # Convert to a tensor
|
58 |
+
transforms.Normalize(mean=[0, 0, 0], std=[1/255, 1/255, 1/255]), # Scale pixel values to [0, 1]
|
59 |
])
|
60 |
|
61 |
# Prediction function
|
|
|
98 |
# Launch the app
|
99 |
if __name__ == "__main__":
|
100 |
interface.launch()
|
101 |
+
|