Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,16 +5,15 @@ import torch
|
|
5 |
|
6 |
os.environ["TRANSFORMERS_CACHE"] = "/tmp"
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
11 |
|
12 |
MODEL_NAME = "s-nlp/roberta-base-formality-ranker"
|
13 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
14 |
model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
|
15 |
|
16 |
-
# Move model to GPU if available
|
17 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
18 |
model = model.to(device)
|
19 |
|
20 |
def calculate_formality_percentages(score):
|
@@ -68,5 +67,5 @@ if __name__ == "__main__":
|
|
68 |
server_name="0.0.0.0",
|
69 |
server_port=7860,
|
70 |
share=True,
|
71 |
-
enable_queue=True
|
72 |
)
|
|
|
5 |
|
6 |
os.environ["TRANSFORMERS_CACHE"] = "/tmp"
|
7 |
|
8 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
9 |
+
if torch.cuda.is_available():
|
10 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
|
11 |
+
torch.cuda.init()
|
12 |
|
13 |
MODEL_NAME = "s-nlp/roberta-base-formality-ranker"
|
14 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
15 |
model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
|
16 |
|
|
|
|
|
17 |
model = model.to(device)
|
18 |
|
19 |
def calculate_formality_percentages(score):
|
|
|
67 |
server_name="0.0.0.0",
|
68 |
server_port=7860,
|
69 |
share=True,
|
70 |
+
enable_queue=True
|
71 |
)
|