Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import torch
|
2 |
-
import
|
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 |
-
|
16 |
-
def preprocess_input(input:
|
|
|
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)
|