Spaces:
Runtime error
Runtime error
adding 5 different models and switching effnet with swin transformer
Browse files- Vit_20%Food101.pth +0 -3
- app.py +4 -4
- model.py +1 -1
- models/Vit_20%Food101.pth +0 -0
- Vit_40%lre-4DataAugFood101.pth β models/Vit_40%lre-4DataAugFood101.pth +2 -2
- Vit_60%Food101.pth β models/Vit_60%Food101.pth +0 -0
- effnet_b2_food101.pth β models/effnet_b2_food101.pth +0 -0
- swin40%newer.pth β models/swin40%newer.pth +0 -0
- models/swin60%.pth +0 -0
- swin60%.pth +0 -3
Vit_20%Food101.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:cbdb15e1e44c857322f027b28da05df6dadb78a6514b5ca525021d9a4dd31da0
|
3 |
-
size 343566279
|
|
|
|
|
|
|
|
app.py
CHANGED
@@ -13,17 +13,17 @@ from pathlib import Path
|
|
13 |
###############################
|
14 |
|
15 |
def predict(img):
|
16 |
-
|
17 |
class_names = []
|
18 |
with open('classes.txt', 'r') as f:
|
19 |
class_names = [foodname.strip() for foodname in f.readlines()]
|
20 |
-
|
21 |
|
22 |
img = transform(img).unsqueeze(0)
|
23 |
|
24 |
-
|
25 |
with torch.inference_mode():
|
26 |
-
pred_label = class_names[
|
27 |
print(pred_label)
|
28 |
return pred_label
|
29 |
|
|
|
13 |
###############################
|
14 |
|
15 |
def predict(img):
|
16 |
+
swinb, transform = create_model()
|
17 |
class_names = []
|
18 |
with open('classes.txt', 'r') as f:
|
19 |
class_names = [foodname.strip() for foodname in f.readlines()]
|
20 |
+
swinb.load_state_dict(torch.load(f = 'models/swin40%newer.pth', map_location = torch.device('cpu')))
|
21 |
|
22 |
img = transform(img).unsqueeze(0)
|
23 |
|
24 |
+
swinb.eval()
|
25 |
with torch.inference_mode():
|
26 |
+
pred_label = class_names[swinb(img).softmax(dim = 1).argmax(dim = 1)]
|
27 |
print(pred_label)
|
28 |
return pred_label
|
29 |
|
model.py
CHANGED
@@ -8,7 +8,7 @@ from torchvision import models, transforms
|
|
8 |
###############################
|
9 |
|
10 |
def create_model():
|
11 |
-
weights = models.
|
12 |
transform = weights.transforms()
|
13 |
|
14 |
model = models.efficientnet_b2(weights = weights)
|
|
|
8 |
###############################
|
9 |
|
10 |
def create_model():
|
11 |
+
weights = models.Swin_B_Weights.DEFAULT
|
12 |
transform = weights.transforms()
|
13 |
|
14 |
model = models.efficientnet_b2(weights = weights)
|
models/Vit_20%Food101.pth
ADDED
File without changes
|
Vit_40%lre-4DataAugFood101.pth β models/Vit_40%lre-4DataAugFood101.pth
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:17f355e8cea1d64a2a99e7a293de89b54928c1e3f83f306572ffa8cf6dbff2ba
|
3 |
+
size 226492416
|
Vit_60%Food101.pth β models/Vit_60%Food101.pth
RENAMED
File without changes
|
effnet_b2_food101.pth β models/effnet_b2_food101.pth
RENAMED
File without changes
|
swin40%newer.pth β models/swin40%newer.pth
RENAMED
File without changes
|
models/swin60%.pth
ADDED
File without changes
|
swin60%.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:2e66e4a7c0b16980324566f0e8f81e1133942308e4dfe91dfabab2af89c62241
|
3 |
-
size 347973311
|
|
|
|
|
|
|
|