Spaces:
Runtime error
Runtime error
Download app.py from Stdaniel/igbo-translator: direct link, hf CLI and curl.
- Browser
- Download file 723 Bytes
-
https://huggingface.co/spaces/Stdaniel/igbo-translator/resolve/main/app.py
- Command line
-
hf download hf://spaces/Stdaniel/igbo-translator/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Stdaniel/igbo-translator/resolve/main/app.py
723 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load OPUS-MT model (change path if you have a local fine-tuned version) | |
| translator = pipeline("translation", model="./my_custom_model") # or "Helsinki-NLP/opus-mt-en-ig" | |
| def translate_text(text): | |
| if not text.strip(): | |
| return "" | |
| result = translator(text) | |
| return result[0]["translation_text"] | |
| demo = gr.Interface( | |
| fn=translate_text, | |
| inputs=gr.Textbox(lines=4, placeholder="Enter English text here..."), | |
| outputs=gr.Textbox(label="Igbo Translation"), | |
| title="English → Igbo Translator", | |
| description="Translate English text to Igbo using an OPUS-MT model.", | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |