Spaces:
Runtime error
Runtime error
AnishKumbhar
commited on
Commit
•
70485e0
1
Parent(s):
ff48a9b
Update app.py
Browse files
app.py
CHANGED
@@ -15,13 +15,13 @@ app = fastapi.FastAPI(docs_url="/")
|
|
15 |
model = torch.load("model67.bin", map_location='cpu')
|
16 |
|
17 |
# Define a function to preprocess the input image
|
18 |
-
def preprocess_input(input:
|
19 |
-
image = Image.open(
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
return input
|
26 |
|
27 |
# Define an endpoint to make predictions
|
|
|
15 |
model = torch.load("model67.bin", map_location='cpu')
|
16 |
|
17 |
# Define a function to preprocess the input image
|
18 |
+
def preprocess_input(input: fastapi.UploadFile):
|
19 |
+
image = Image.open(input.file)
|
20 |
+
image = image.resize((224, 224))
|
21 |
+
input = np.array(image)
|
22 |
+
input = torch.from_numpy(input).float()
|
23 |
+
input = input.permute(2, 0, 1)
|
24 |
+
input = input.unsqueeze(0)
|
25 |
return input
|
26 |
|
27 |
# Define an endpoint to make predictions
|