Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,7 +30,6 @@ def load_model():
|
|
30 |
model.eval()
|
31 |
return model
|
32 |
|
33 |
-
model = load_model()
|
34 |
|
35 |
def transform_image(image_bytes):
|
36 |
my_transforms = transforms.Compose([transforms.Resize(255),
|
@@ -95,9 +94,10 @@ from torchvision import transforms
|
|
95 |
# response = requests.get("https://git.io/JJkYN")
|
96 |
# labels = response.text.split("\n")
|
97 |
|
|
|
98 |
|
99 |
def predict(inp):
|
100 |
-
inp = transforms.ToTensor()(inp).unsqueeze(0)
|
101 |
with torch.no_grad():
|
102 |
prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)
|
103 |
confidences = {labels[i]: float(prediction[i]) for i in range(3)}
|
|
|
30 |
model.eval()
|
31 |
return model
|
32 |
|
|
|
33 |
|
34 |
def transform_image(image_bytes):
|
35 |
my_transforms = transforms.Compose([transforms.Resize(255),
|
|
|
94 |
# response = requests.get("https://git.io/JJkYN")
|
95 |
# labels = response.text.split("\n")
|
96 |
|
97 |
+
model = load_model()
|
98 |
|
99 |
def predict(inp):
|
100 |
+
inp = transforms.Resize((224, 224))(inp).transforms.ToTensor()(inp).unsqueeze(0)
|
101 |
with torch.no_grad():
|
102 |
prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)
|
103 |
confidences = {labels[i]: float(prediction[i]) for i in range(3)}
|