hcs commited on
Commit
25ec020
·
1 Parent(s): d42ee1a

Add application file

Browse files
Files changed (1) hide show
  1. core.py +21 -1
core.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import torch
2
  import torchvision.transforms as transforms
3
  from PIL import Image
@@ -20,8 +22,26 @@ device = torch.device("cpu")
20
  print("use cpu")
21
 
22
  # model_ckpt_path = "./models/resnet18.pth"
23
- model_ckpt_path = "https://huggingface.co/M4869/beauty_prediction_fpb5k/blob/main/resnet18.pth"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
 
25
  net = Nets.ResNet(block=Nets.BasicBlock, layers=[2, 2, 2, 2], num_classes=1).to(device)
26
  load_model(torch.load(model_ckpt_path, encoding='latin1'), net)
27
  net.eval()
 
1
+ import pdb
2
+
3
  import torch
4
  import torchvision.transforms as transforms
5
  from PIL import Image
 
22
  print("use cpu")
23
 
24
  # model_ckpt_path = "./models/resnet18.pth"
25
+ # model_ckpt_path = "https://huggingface.co/M4869/beauty_prediction_fpb5k/blob/main/resnet18.pth"
26
+
27
+ # model_ckpt_path = "M4869/beauty_prediction_fpb5k"
28
+ # model = torch.hub.load("huggingface/transformers", model_ckpt_path)
29
+
30
+
31
+ from huggingface_hub import hf_hub_download
32
+ import joblib
33
+
34
+ REPO_ID = "M4869"
35
+ FILENAME = "beauty_prediction_fpb5k"
36
+
37
+ # tmp = joblib.load(
38
+ # hf_hub_download(repo_id=REPO_ID, filename=FILENAME)
39
+ # )
40
+
41
+ # ans = hf_hub_download(repo_id="google/pegasus-xsum", filename="config.json")
42
+ # /home/my/.cache/huggingface/hub/models--google--pegasus-xsum/snapshots/8d8ffc158a3bee9fbb03afacdfc347c823c5ec8b/config.json
43
 
44
+ model_ckpt_path = hf_hub_download(repo_id="M4869/beauty_prediction_fpb5k", filename="resnet18.pth")
45
  net = Nets.ResNet(block=Nets.BasicBlock, layers=[2, 2, 2, 2], num_classes=1).to(device)
46
  load_model(torch.load(model_ckpt_path, encoding='latin1'), net)
47
  net.eval()