ssocean commited on
Commit
50758b6
·
verified ·
1 Parent(s): 78e4c26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -14,12 +14,12 @@ tokenizer = AutoTokenizer.from_pretrained(model_path)
14
 
15
  @spaces.GPU
16
  def predict(title, abstract):
17
- torch.cuda.set_device(torch.device('cuda'))
18
-
19
  model.eval()
20
  text = f'''Given a certain paper, Title: {title}\n Abstract: {abstract}. \n Predict its normalized academic impact (between 0 and 1):'''
21
  inputs = tokenizer(text, return_tensors="pt")
22
- inputs = inputs.to(torch.device('cuda'))
23
  with torch.no_grad():
24
  outputs = model(**inputs)
25
  probability = torch.sigmoid(outputs.logits).item()
 
14
 
15
  @spaces.GPU
16
  def predict(title, abstract):
17
+ global model
18
+ torch.cuda.set_device(torch.device('cuda:0'))
19
  model.eval()
20
  text = f'''Given a certain paper, Title: {title}\n Abstract: {abstract}. \n Predict its normalized academic impact (between 0 and 1):'''
21
  inputs = tokenizer(text, return_tensors="pt")
22
+ inputs = inputs.to(torch.device('cuda:0'))
23
  with torch.no_grad():
24
  outputs = model(**inputs)
25
  probability = torch.sigmoid(outputs.logits).item()