Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import pandas as pd
|
|
8 |
|
9 |
# Load paraphrase model and tokenizer
|
10 |
model = T5ForConditionalGeneration.from_pretrained('ramsrigouthamg/t5_paraphraser')
|
11 |
-
tokenizer = T5Tokenizer.from_pretrained('t5-base')
|
12 |
|
13 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
14 |
model = model.to(device)
|
@@ -232,7 +232,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css, js=custom_js) as demo:
|
|
232 |
outputs=output_text
|
233 |
)
|
234 |
|
235 |
-
# Calculate and display metrics on load
|
236 |
test_sentences = [
|
237 |
"The quick brown fox jumps over the lazy dog.",
|
238 |
"Artificial intelligence is transforming industries.",
|
@@ -240,12 +240,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css, js=custom_js) as demo:
|
|
240 |
"He enjoys reading books on machine learning.",
|
241 |
"The stock market fluctuates daily due to various factors."
|
242 |
]
|
243 |
-
|
244 |
-
fn=calculate_precision_recall_accuracy,
|
245 |
-
inputs=None,
|
246 |
-
outputs=metrics_output,
|
247 |
-
_js="() => { return ['" + "', '".join(test_sentences) + "']; }"
|
248 |
-
)
|
249 |
|
250 |
# Launch Gradio app
|
251 |
demo.launch(share=False)
|
|
|
8 |
|
9 |
# Load paraphrase model and tokenizer
|
10 |
model = T5ForConditionalGeneration.from_pretrained('ramsrigouthamg/t5_paraphraser')
|
11 |
+
tokenizer = T5Tokenizer.from_pretrained('t5-base', legacy=False) # Explicitly set legacy=False
|
12 |
|
13 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
14 |
model = model.to(device)
|
|
|
232 |
outputs=output_text
|
233 |
)
|
234 |
|
235 |
+
# Calculate and display metrics on load without _js
|
236 |
test_sentences = [
|
237 |
"The quick brown fox jumps over the lazy dog.",
|
238 |
"Artificial intelligence is transforming industries.",
|
|
|
240 |
"He enjoys reading books on machine learning.",
|
241 |
"The stock market fluctuates daily due to various factors."
|
242 |
]
|
243 |
+
metrics_output.value = calculate_precision_recall_accuracy(test_sentences)
|
|
|
|
|
|
|
|
|
|
|
244 |
|
245 |
# Launch Gradio app
|
246 |
demo.launch(share=False)
|