Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -19,15 +19,13 @@ model.eval()
|
|
19 |
|
20 |
|
21 |
|
22 |
-
@spaces.GPU
|
23 |
def predict(title, abstract):
|
24 |
model_device = next(model.parameters()).device
|
25 |
text = f'''Given a certain paper, Title: {title}\n Abstract: {abstract}. \n Predict its normalized academic impact (between 0 and 1):'''
|
26 |
-
inputs = tokenizer(text, return_tensors="pt")
|
27 |
-
|
28 |
with torch.no_grad():
|
29 |
outputs = model(**inputs)
|
30 |
-
|
31 |
probability = torch.sigmoid(outputs.logits).item()
|
32 |
# reason for +0.05: We observed that the predicted values in the web demo are generally around 0.05 lower than those in the local deployment (due to differences in software/hardware environments). Therefore, we applied the following compensation in the web demo. Please do not use this in the local deployment.
|
33 |
if probability + 0.05 >=1.0:
|
|
|
19 |
|
20 |
|
21 |
|
22 |
+
@spaces.GPU(duration=60, enable_queue=True)
|
23 |
def predict(title, abstract):
|
24 |
model_device = next(model.parameters()).device
|
25 |
text = f'''Given a certain paper, Title: {title}\n Abstract: {abstract}. \n Predict its normalized academic impact (between 0 and 1):'''
|
26 |
+
inputs = tokenizer(text, return_tensors="pt")
|
|
|
27 |
with torch.no_grad():
|
28 |
outputs = model(**inputs)
|
|
|
29 |
probability = torch.sigmoid(outputs.logits).item()
|
30 |
# reason for +0.05: We observed that the predicted values in the web demo are generally around 0.05 lower than those in the local deployment (due to differences in software/hardware environments). Therefore, we applied the following compensation in the web demo. Please do not use this in the local deployment.
|
31 |
if probability + 0.05 >=1.0:
|