lmedz commited on
Commit
c1f17cc
·
verified ·
1 Parent(s): 4ff372e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -5,12 +5,23 @@ from torchvision import transforms
5
  from PIL import Image
6
 
7
  # モデル読み込み
 
 
 
 
8
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
 
 
 
 
 
 
9
  model = timm.create_model('convnext_small', pretrained=False, num_classes=2)
10
- model.load_state_dict(torch.load("model.pth", map_location=device))
11
  model.to(device)
12
  model.eval()
13
 
 
14
  # 前処理
15
  transform = transforms.Compose([
16
  transforms.Resize((224, 224)),
 
5
  from PIL import Image
6
 
7
  # モデル読み込み
8
+ from huggingface_hub import hf_hub_download
9
+ import torch
10
+ import timm
11
+
12
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
13
+
14
+ model_path = hf_hub_download(
15
+ repo_id="ryumiyake/ips-model-weights", # ←作ったModel Hubのリポジトリ名
16
+ filename="model.pth"
17
+ )
18
+
19
  model = timm.create_model('convnext_small', pretrained=False, num_classes=2)
20
+ model.load_state_dict(torch.load(model_path, map_location=device))
21
  model.to(device)
22
  model.eval()
23
 
24
+
25
  # 前処理
26
  transform = transforms.Compose([
27
  transforms.Resize((224, 224)),