AnishKumbhar commited on
Commit
70485e0
1 Parent(s): ff48a9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
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: Any):
19
- image = Image.open(BytesIO(input))
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
 
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