Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import torch
|
|
3 |
from torch import nn
|
4 |
from pathlib import Path
|
5 |
|
|
|
|
|
6 |
model = nn.Sequential(
|
7 |
nn.Conv2d(1, 32, 3, padding='same'),
|
8 |
nn.ReLU(),
|
@@ -22,8 +24,6 @@ state_dict = torch.load('pytorch_model.bin', map_location='cpu')
|
|
22 |
model.load_state_dict(state_dict, strict=False)
|
23 |
model.eval()
|
24 |
|
25 |
-
LABELS = Path('class_names.txt').read_text().splitlines()
|
26 |
-
|
27 |
def predict(img):
|
28 |
x = torch.tensor(img, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.
|
29 |
with torch.no_grad():
|
|
|
3 |
from torch import nn
|
4 |
from pathlib import Path
|
5 |
|
6 |
+
LABELS = Path('class_names.txt').read_text().splitlines()
|
7 |
+
|
8 |
model = nn.Sequential(
|
9 |
nn.Conv2d(1, 32, 3, padding='same'),
|
10 |
nn.ReLU(),
|
|
|
24 |
model.load_state_dict(state_dict, strict=False)
|
25 |
model.eval()
|
26 |
|
|
|
|
|
27 |
def predict(img):
|
28 |
x = torch.tensor(img, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.
|
29 |
with torch.no_grad():
|