Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- model.py +29 -0
- requirements.txt +20 -0
model.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
"""
|
| 4 |
+
Created on Fri Mar 7 13:29:20 2025
|
| 5 |
+
|
| 6 |
+
@author: lt611-10
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import torch
|
| 10 |
+
import torchvision
|
| 11 |
+
|
| 12 |
+
def create_effnetb2(num_classes:int=3, seed:int=42):
|
| 13 |
+
|
| 14 |
+
weights=torchvision.models.EfficientNet_B2_Weights.DEFAULT
|
| 15 |
+
effnetb2=torchvision.models.efficientnet_b2(weights=weights)
|
| 16 |
+
|
| 17 |
+
effnetb2_transforms=weights.transforms()
|
| 18 |
+
|
| 19 |
+
for params in effnetb2.parameters():
|
| 20 |
+
params.requires_grad=False
|
| 21 |
+
|
| 22 |
+
torch.manual_seed(seed)
|
| 23 |
+
effnetb2.classifier=torch.nn.Sequential(
|
| 24 |
+
torch.nn.Dropout(p=0.3, inplace=True),
|
| 25 |
+
torch.nn.Linear(in_features=1408, out_features=num_classes)
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
return effnetb2, effnetb2_transforms
|
| 29 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
"""
|
| 4 |
+
Created on Fri Mar 7 15:48:43 2025
|
| 5 |
+
|
| 6 |
+
@author: lt611-10
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
torch=2.5.1
|
| 10 |
+
torchvision=0.20.1
|
| 11 |
+
gradio=5.20.1
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|