BitsAndBytes / app.py
dreyyyy's picture
second commit
549bee4
raw
history blame contribute delete
811 Bytes
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
# Load your Hugging Face model and tokenizer
model_name = "dreyyyy/EN-ES" # Replace with your model ID
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
# Define the prediction function
def translate_text(input_text):
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**inputs)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# Create the Gradio interface
iface = gr.Interface(
fn=translate_text,
inputs="text",
outputs="text",
title="Text Translation",
description="Translate input text using a Hugging Face model."
)
# Launch the Gradio app
if __name__ == "__main__":
iface.launch()