Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import gradio as gr
|
|
8 |
class MyModel(torch.nn.Module):
|
9 |
def __init__(self, num_classes):
|
10 |
super(MyModel, self).__init__()
|
11 |
-
self.model = models.resnet18(
|
12 |
self.model.fc = torch.nn.Linear(self.model.fc.in_features, num_classes) # ๋ง์ง๋ง ๋ ์ด์ด ์์
|
13 |
|
14 |
def forward(self, x):
|
@@ -17,8 +17,9 @@ class MyModel(torch.nn.Module):
|
|
17 |
# ๋ชจ๋ธ ์ด๊ธฐํ
|
18 |
num_classes = 6 # ํด๋์ค ์์ ๋ง๊ฒ ์ค์
|
19 |
model = MyModel(num_classes)
|
20 |
-
|
21 |
-
|
|
|
22 |
model.eval()
|
23 |
|
24 |
# ๋ฐ์ดํฐ ๋ณํ ์ ์
|
|
|
8 |
class MyModel(torch.nn.Module):
|
9 |
def __init__(self, num_classes):
|
10 |
super(MyModel, self).__init__()
|
11 |
+
self.model = models.resnet18(weights=None) # ResNet18 ๋ชจ๋ธ ์ฌ์ฉ
|
12 |
self.model.fc = torch.nn.Linear(self.model.fc.in_features, num_classes) # ๋ง์ง๋ง ๋ ์ด์ด ์์
|
13 |
|
14 |
def forward(self, x):
|
|
|
17 |
# ๋ชจ๋ธ ์ด๊ธฐํ
|
18 |
num_classes = 6 # ํด๋์ค ์์ ๋ง๊ฒ ์ค์
|
19 |
model = MyModel(num_classes)
|
20 |
+
|
21 |
+
# ๋ชจ๋ธ ๊ฐ์ค์น ๋ก๋ (CPU๋ก ๋งคํ)
|
22 |
+
model.load_state_dict(torch.load('resnet18_finetuned_2.pth', map_location=torch.device('cpu')), strict=False)
|
23 |
model.eval()
|
24 |
|
25 |
# ๋ฐ์ดํฐ ๋ณํ ์ ์
|