Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -45,9 +45,14 @@ def predict(title, abstract):
|
|
45 |
inputs = tokenizer(text, return_tensors="pt")
|
46 |
with torch.no_grad():
|
47 |
outputs = model(**inputs.to(device))
|
48 |
-
probability = torch.sigmoid(outputs.logits).item()
|
49 |
# 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.
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
|
53 |
# 示例数据
|
|
|
45 |
inputs = tokenizer(text, return_tensors="pt")
|
46 |
with torch.no_grad():
|
47 |
outputs = model(**inputs.to(device))
|
48 |
+
probability = torch.sigmoid(outputs.logits).item() + 0.05
|
49 |
# 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.
|
50 |
+
|
51 |
+
# Clamp the value to ensure it is between 0 and 1 (for probabilities)
|
52 |
+
clamped_probability = torch.clamp(probability, min=0.0, max=1.0)
|
53 |
+
|
54 |
+
# Return the clamped probability, rounded to 4 decimal places
|
55 |
+
return round(clamped_probability, 4)
|
56 |
|
57 |
|
58 |
# 示例数据
|