Update app.py
Browse files
app.py
CHANGED
|
@@ -4,11 +4,12 @@ from torchvision import models
|
|
| 4 |
from PIL import Image
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
-
# ๋ชจ๋ธ ํด๋์ค ์ ์ (
|
| 8 |
class MyModel(torch.nn.Module):
|
| 9 |
def __init__(self, num_classes):
|
| 10 |
super(MyModel, self).__init__()
|
| 11 |
-
self.model = models.
|
|
|
|
| 12 |
|
| 13 |
def forward(self, x):
|
| 14 |
return self.model(x)
|
|
@@ -42,4 +43,4 @@ def predict(image):
|
|
| 42 |
|
| 43 |
# Gradio ์ธํฐํ์ด์ค ์ค์
|
| 44 |
iface = gr.Interface(fn=predict, inputs=gr.Image(type='pil'), outputs='label', live=True)
|
| 45 |
-
iface.launch()
|
|
|
|
| 4 |
from PIL import Image
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
+
# ๋ชจ๋ธ ํด๋์ค ์ ์ (ResNet18)
|
| 8 |
class MyModel(torch.nn.Module):
|
| 9 |
def __init__(self, num_classes):
|
| 10 |
super(MyModel, self).__init__()
|
| 11 |
+
self.model = models.resnet18(pretrained=False) # ResNet18 ๋ชจ๋ธ ์ฌ์ฉ
|
| 12 |
+
self.model.fc = torch.nn.Linear(self.model.fc.in_features, num_classes) # ๋ง์ง๋ง ๋ ์ด์ด ์์
|
| 13 |
|
| 14 |
def forward(self, x):
|
| 15 |
return self.model(x)
|
|
|
|
| 43 |
|
| 44 |
# Gradio ์ธํฐํ์ด์ค ์ค์
|
| 45 |
iface = gr.Interface(fn=predict, inputs=gr.Image(type='pil'), outputs='label', live=True)
|
| 46 |
+
iface.launch()
|