hcs commited on
Commit
cc314be
·
1 Parent(s): 4afdb1d

Add application file

Browse files
Files changed (1) hide show
  1. core.py +3 -4
core.py CHANGED
@@ -19,11 +19,10 @@ def load_model(pretrained_dict, new):
19
  device = torch.device("cpu")
20
  print("use cpu")
21
 
22
- # ans = hf_hub_download(repo_id="google/pegasus-xsum", filename="config.json")
23
- # /home/my/.cache/huggingface/hub/models--google--pegasus-xsum/snapshots/8d8ffc158a3bee9fbb03afacdfc347c823c5ec8b/config.json
24
 
25
  model_ckpt_path = hf_hub_download(repo_id="M4869/beauty_prediction_fpb5k", filename="resnet18.pth")
26
- net = Nets.ResNet(block=Nets.BasicBlock, layers=[2, 2, 2, 2], num_classes=1).to(device)
27
  load_model(torch.load(model_ckpt_path, encoding='latin1', map_location=torch.device('cpu')), net)
28
  net.eval()
29
 
@@ -40,4 +39,4 @@ def fun(img_path):
40
  with torch.no_grad():
41
  img = img.unsqueeze(0).to(device)
42
  output = net(img).squeeze(1).cpu().numpy()[0]
43
- return output
 
19
  device = torch.device("cpu")
20
  print("use cpu")
21
 
22
+ net = Nets.ResNet(block=Nets.BasicBlock, layers=[2, 2, 2, 2], num_classes=1).to(device)
 
23
 
24
  model_ckpt_path = hf_hub_download(repo_id="M4869/beauty_prediction_fpb5k", filename="resnet18.pth")
25
+ # /home/my/.cache/huggingface/hub/models--google--pegasus-xsum/snapshots/8d8ffc158a3bee9fbb03afacdfc347c823c5ec8b/config.json
26
  load_model(torch.load(model_ckpt_path, encoding='latin1', map_location=torch.device('cpu')), net)
27
  net.eval()
28
 
 
39
  with torch.no_grad():
40
  img = img.unsqueeze(0).to(device)
41
  output = net(img).squeeze(1).cpu().numpy()[0]
42
+ return output * 20