Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,10 +3,20 @@ import gradio as gr
|
|
| 3 |
|
| 4 |
# Load tokenizer with use_fast=False
|
| 5 |
tokenizer = AutoTokenizer.from_pretrained("SuperSl6/Arabic-Text-Correction", use_fast=False)
|
| 6 |
-
model = pipeline(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def correct_text(input_text):
|
| 9 |
-
result = model(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return result
|
| 11 |
|
| 12 |
# Gradio Interface
|
|
@@ -19,4 +29,4 @@ interface = gr.Interface(
|
|
| 19 |
description="أداة لتصحيح النصوص العربية باستخدام نموذج SuperSl6/Arabic-Text-Correction."
|
| 20 |
)
|
| 21 |
|
| 22 |
-
interface.launch(
|
|
|
|
| 3 |
|
| 4 |
# Load tokenizer with use_fast=False
|
| 5 |
tokenizer = AutoTokenizer.from_pretrained("SuperSl6/Arabic-Text-Correction", use_fast=False)
|
| 6 |
+
model = pipeline(
|
| 7 |
+
"text2text-generation",
|
| 8 |
+
model="SuperSl6/Arabic-Text-Correction",
|
| 9 |
+
tokenizer=tokenizer
|
| 10 |
+
)
|
| 11 |
|
| 12 |
def correct_text(input_text):
|
| 13 |
+
result = model(
|
| 14 |
+
input_text,
|
| 15 |
+
max_length=50, # Limit output length
|
| 16 |
+
no_repeat_ngram_size=2, # Prevent repeating bigrams
|
| 17 |
+
repetition_penalty=1.5, # Penalize repetitions
|
| 18 |
+
num_return_sequences=1 # Return a single output
|
| 19 |
+
)[0]['generated_text']
|
| 20 |
return result
|
| 21 |
|
| 22 |
# Gradio Interface
|
|
|
|
| 29 |
description="أداة لتصحيح النصوص العربية باستخدام نموذج SuperSl6/Arabic-Text-Correction."
|
| 30 |
)
|
| 31 |
|
| 32 |
+
interface.launch()
|