Spaces:
Sleeping
Sleeping
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'] | |
examples = [ | |
["The program runs without errors"], | |
["I need to debug the code to find the issue."], | |
["The code has a error in line 15."], | |
["I will meet you at the park in the afternoon."], | |
["The weather is beautiful today."] | |
] | |
# 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 to translate it into French (e.g., 'The program runs smoothly.')", | |
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 | |
examples=examples # Optional: Add examples to make it easier for users | |
) | |
demo.launch() | |