import gradio as gr # Load your Hugging Face model (replace with your model name) model_name = "Helsinki-NLP/opus-mt-en-es" model = gr.load(model_name, src="models") # Define the input component (text box) text_input = gr.inputs.Textbox(lines=5, label="Enter text in English") # Define the output component (text box) text_output = gr.outputs.Textbox(label="Translated text in Spanish") # Create the Gradio interface iface = gr.Interface( fn=model, inputs=text_input, outputs=text_output, title="Hugging Face Model Translator", description="Translate English text to Spanish using Hugging Face models.", theme="default", # You can customize the theme (e.g., "huggingface") examples=[ ["Hello, how are you?"], ["I love Gradio!"], ["This is a test sentence."], ], ) # Launch the interface iface.launch()