Spaces:
Runtime error
Runtime error
AnishKumbhar
commited on
Commit
•
d1f3905
1
Parent(s):
c830390
Update app.py
Browse files
app.py
CHANGED
@@ -46,9 +46,8 @@ class_names = [
|
|
46 |
|
47 |
model.load_state_dict(torch.load('best_model.pth', map_location='cpu'))
|
48 |
# Define a function to preprocess the input image
|
49 |
-
def preprocess_input(input:
|
50 |
-
|
51 |
-
image = Image.open(io.BytesIO(image_data))
|
52 |
image = image.resize((224, 224)).convert("RGB")
|
53 |
input = np.array(image)
|
54 |
input = np.transpose(input, (2, 0, 1))
|
@@ -58,7 +57,7 @@ def preprocess_input(input: str):
|
|
58 |
|
59 |
# Define an endpoint to make predictions
|
60 |
@app.post("/predict")
|
61 |
-
async def predict_endpoint(input:
|
62 |
"""Make a prediction on an image uploaded by the user."""
|
63 |
|
64 |
# Preprocess the input image
|
|
|
46 |
|
47 |
model.load_state_dict(torch.load('best_model.pth', map_location='cpu'))
|
48 |
# Define a function to preprocess the input image
|
49 |
+
def preprocess_input(input: fastapi.UploadFile):
|
50 |
+
image = Image.open(input.file)
|
|
|
51 |
image = image.resize((224, 224)).convert("RGB")
|
52 |
input = np.array(image)
|
53 |
input = np.transpose(input, (2, 0, 1))
|
|
|
57 |
|
58 |
# Define an endpoint to make predictions
|
59 |
@app.post("/predict")
|
60 |
+
async def predict_endpoint(input:fastapi.UploadFile):
|
61 |
"""Make a prediction on an image uploaded by the user."""
|
62 |
|
63 |
# Preprocess the input image
|