SANJAYV10 commited on
Commit
0f3e8d6
1 Parent(s): 43b252b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import torch
2
- import fastapi
3
- import numpy as np
4
  from PIL import Image
 
5
 
6
  class TorchTensor(torch.Tensor):
7
  pass
@@ -12,8 +12,9 @@ class Prediction:
12
  app = fastapi.FastAPI(docs_url="/")
13
 
14
  model = torch.load("best_model.pth", map_location='cpu')
15
- # Define a function to preprocess the input image
16
- def preprocess_input(input: fastapi.UploadFile):
 
17
  image = Image.open(input.file)
18
  image = image.resize((224, 224))
19
  input = np.array(image)
 
1
  import torch
2
+ from fastapi import FastAPI, UploadFile
 
3
  from PIL import Image
4
+ import numpy as np
5
 
6
  class TorchTensor(torch.Tensor):
7
  pass
 
12
  app = fastapi.FastAPI(docs_url="/")
13
 
14
  model = torch.load("best_model.pth", map_location='cpu')
15
+
16
+ def preprocess_input(input: UploadFile):
17
+ """Preprocess the input image."""
18
  image = Image.open(input.file)
19
  image = image.resize((224, 224))
20
  input = np.array(image)