Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load your model | |
| translator = pipeline("translation", model="med-03/my-translation-model") | |
| # Translation function | |
| def translate_text(text): | |
| result = translator(text) | |
| return result[0]["translation_text"] | |
| # Gradio Interface (API-ready) | |
| iface = gr.Interface( | |
| fn=translate_text, | |
| inputs=gr.Textbox(label="Input Text"), | |
| outputs=gr.Textbox(label="Translated Text"), | |
| title="Translation API", | |
| description="Translate text using your Hugging Face model.", | |
| examples=["Hello, how are you?", "This is a test sentence."], | |
| ) | |
| iface.queue(False) | |
| iface.launch() | |