Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,8 +8,8 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, MarianMTModel, Ma
|
|
| 8 |
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 9 |
|
| 10 |
MODEL_OPTIONS = [
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
]
|
| 14 |
|
| 15 |
# Cache
|
|
@@ -69,7 +69,7 @@ def polish(sentence: str, choice: str) -> str:
|
|
| 69 |
return "Unknown option."
|
| 70 |
|
| 71 |
# --- Gradio UI ---
|
| 72 |
-
with gr.Blocks(title="English Grammar Polisher") as demo:
|
| 73 |
gr.Markdown("### English Grammar Polisher\nChoose FLAN-T5 (Google) or OPUS-MT (Helsinki-NLP).")
|
| 74 |
inp = gr.Textbox(lines=3, label="Input (English) E.g. She go tomorrow buy two bread.", placeholder="Type an English sentence to correct.")
|
| 75 |
choice = gr.Dropdown(choices=MODEL_OPTIONS, value="FLAN-T5-base (Google)", label="Method")
|
|
|
|
| 8 |
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 9 |
|
| 10 |
MODEL_OPTIONS = [
|
| 11 |
+
"Helsinki-NLP", # Round-trip OPUS-MT en→es→en
|
| 12 |
+
"FLAN-T5-base (Google en→en)"
|
| 13 |
]
|
| 14 |
|
| 15 |
# Cache
|
|
|
|
| 69 |
return "Unknown option."
|
| 70 |
|
| 71 |
# --- Gradio UI ---
|
| 72 |
+
with gr.Blocks(title="English Grammar Polisher (CPU enabled)") as demo:
|
| 73 |
gr.Markdown("### English Grammar Polisher\nChoose FLAN-T5 (Google) or OPUS-MT (Helsinki-NLP).")
|
| 74 |
inp = gr.Textbox(lines=3, label="Input (English) E.g. She go tomorrow buy two bread.", placeholder="Type an English sentence to correct.")
|
| 75 |
choice = gr.Dropdown(choices=MODEL_OPTIONS, value="FLAN-T5-base (Google)", label="Method")
|