from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
import gradio as gr
# Create translation function
tokenizer = AutoTokenizer.from_pretrained("claudiatang/flan-t5-base-eng-hwp")
model = AutoModelForSeq2SeqLM.from_pretrained("claudiatang/flan-t5-base-eng-hwp")
def translate_eng_hwp(eng_input):
translator = pipeline("translation", model=model, tokenizer=tokenizer)
eng_input = "translate English to Hawaiian Pidgin: " + str(eng_input)
output = translator(eng_input)
hwp_output = output[0]["translation_text"]
return hwp_output
# Create Gradio interface
with gr.Blocks(theme=gr.themes.Default(primary_hue="blue", secondary_hue="blue")) as demo:
gr.HTML("""