Spaces:
Sleeping
Sleeping
File size: 634 Bytes
b2021b7 d98cc18 b2021b7 d98cc18 6fb4888 d98cc18 d7dab5d d98cc18 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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()
|