commit 77b1ad16dec2689cf78c031215751df45a967e24 Author: SOULOFCINDER <841135647@qq.com> Date: Fri Mar 31 12:58:06 2023 +0800 inital diff --git a/t5_large/app.py b/t5_large/app.py new file mode 100644 index 0000000..221d9cf --- /dev/null +++ b/t5_large/app.py @@ -0,0 +1,37 @@ +import gradio as gr + +from transformers import T5Tokenizer, T5Model + +def inference(text): + model_path = "t5-large" + tokenizer = T5Tokenizer.from_pretrained(model_path) + model = T5Model.from_pretrained(model_path) + + input_ids = tokenizer( + text, return_tensors="pt" + ).input_ids # Batch size 1 + decoder_input_ids = tokenizer("Studies show that", return_tensors="pt").input_ids # Batch size 1 + + # forward pass + outputs = model(input_ids=input_ids, decoder_input_ids=decoder_input_ids) + + print(outputs[0]) + last_hidden_states = outputs.last_hidden_state + return outputs[0] + +examples=[["Studies have been shown that owning a dog is good for you"]] + +with gr.Blocks() as demo: + gr.Markdown( + """ + # Translation:t5-large + Gradio Demo for t5-large. To use it, simply type in text, or click one of the examples to load them. + """) + with gr.Row(): + text_input = gr.Textbox() + text_output = gr.Textbox() + image_button = gr.Button("上传") + image_button.click(inference, inputs=text_input, outputs=text_output) + gr.Examples(examples,inputs=text_input) + +demo.launch() diff --git a/t5_large/t5-large b/t5_large/t5-large new file mode 160000 index 0000000..6ed159b --- /dev/null +++ b/t5_large/t5-large @@ -0,0 +1 @@ +Subproject commit 6ed159b7a9408621a1ed0b9ca39aacc42c694d73