Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
4 |
import torch
|
5 |
import warnings
|
6 |
|
7 |
-
# Suppress NVML warning
|
8 |
warnings.filterwarnings("ignore", message="Can't initialize NVML")
|
9 |
|
10 |
os.environ["TRANSFORMERS_CACHE"] = "/tmp"
|
@@ -20,7 +19,9 @@ model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
|
|
20 |
model = model.to(device)
|
21 |
|
22 |
def calculate_formality_percentages(score):
|
|
|
23 |
grayscale = int(score * 100)
|
|
|
24 |
formal_percent = grayscale
|
25 |
informal_percent = 100 - grayscale
|
26 |
return formal_percent, informal_percent
|
@@ -60,11 +61,10 @@ demo = gr.Interface(
|
|
60 |
]
|
61 |
)
|
62 |
|
63 |
-
# Launch the app
|
64 |
if __name__ == "__main__":
|
65 |
demo.queue()
|
66 |
demo.launch(
|
67 |
server_name="0.0.0.0",
|
68 |
server_port=7860,
|
69 |
-
|
70 |
)
|
|
|
4 |
import torch
|
5 |
import warnings
|
6 |
|
|
|
7 |
warnings.filterwarnings("ignore", message="Can't initialize NVML")
|
8 |
|
9 |
os.environ["TRANSFORMERS_CACHE"] = "/tmp"
|
|
|
19 |
model = model.to(device)
|
20 |
|
21 |
def calculate_formality_percentages(score):
|
22 |
+
# Convert score to grayscale percentage (0-100)
|
23 |
grayscale = int(score * 100)
|
24 |
+
# Use grayscale to determine formal/informal percentages
|
25 |
formal_percent = grayscale
|
26 |
informal_percent = 100 - grayscale
|
27 |
return formal_percent, informal_percent
|
|
|
61 |
]
|
62 |
)
|
63 |
|
|
|
64 |
if __name__ == "__main__":
|
65 |
demo.queue()
|
66 |
demo.launch(
|
67 |
server_name="0.0.0.0",
|
68 |
server_port=7860,
|
69 |
+
ssr_mode=False
|
70 |
)
|