import gradio as gr from transformers import pipeline def translator(sentence): model_checkpoint = "AirrStorm/Finetuned-OpusMT-EN2FR" translator = pipeline("translation", model=model_checkpoint) return translator(sentence)[0]['translation_text'] # Create a cleaner UI with input and output labels and additional styling demo = gr.Interface( fn=translator, inputs=gr.Textbox( lines=3, placeholder="Enter text in English...", label="Input (English)" ), outputs=gr.Textbox( lines=3, placeholder="Translation will appear here...", label="Output (French)" ), title="English to French Translator", description="This tool translates text from English to French. Especially fine-tuned for programming-related terms.", live=False, # Live updates are not necessary for translation theme="dark-peach" # Optional: use the Hugging Face theme ) demo.launch()