ssocean commited on
Commit
83d6a82
·
verified ·
1 Parent(s): 67aea18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
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
- return round(probability + 0.05, 4)
 
 
 
 
 
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
  # 示例数据