update
This commit is contained in:
parent
0e8c90ca1b
commit
88ca5fecf9
|
@ -1,10 +1,6 @@
|
||||||
# please visit https://github.com/xfyun/aiges/releases to get stable and suitable iamges.
|
# please visit https://github.com/xfyun/aiges/releases to get stable and suitable iamges.
|
||||||
|
|
||||||
FROM docker.io/library/python:3.8.9
|
FROM public.ecr.aws/iflytek-open/cuda-go-python-base:11.6-1.17-3.9.13-ubuntu1804
|
||||||
|
|
||||||
|
|
||||||
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
|
|
||||||
RUN sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR /home/user/app
|
WORKDIR /home/user/app
|
||||||
|
|
|
@ -1,31 +1,25 @@
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
from transformers import pipeline, set_seed
|
from transformers import pipeline, set_seed
|
||||||
|
|
||||||
|
|
||||||
def inference(text):
|
def inference(text):
|
||||||
model_path = "distilgpt2"
|
model_path = "distilgpt2"
|
||||||
generator = pipeline('text-generation', model=model_path)
|
generator = pipeline('text-generation', model=model_path)
|
||||||
set_seed(42)
|
set_seed(42)
|
||||||
|
|
||||||
output=[]
|
output = []
|
||||||
lst=generator(text, max_length=20, num_return_sequences=5)
|
lst = generator(text, max_length=20, num_return_sequences=5)
|
||||||
for dic in lst:
|
for dic in lst:
|
||||||
output.append(dic['generated_text'])
|
output.append(dic['generated_text'])
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
# tokenizer = GPT2Tokenizer.from_pretrained(model_path)
|
|
||||||
# model = GPT2Model.from_pretrained(model_path)
|
|
||||||
# encoded_input = tokenizer(text, return_tensors='pt')
|
|
||||||
# output = model(**encoded_input)
|
|
||||||
# print(output)
|
|
||||||
# return output
|
|
||||||
|
|
||||||
|
examples = [["Hello, I’m a language model."]]
|
||||||
examples=[["Hello, I’m a language model."]]
|
|
||||||
|
|
||||||
with gr.Blocks() as demo:
|
with gr.Blocks() as demo:
|
||||||
gr.Markdown(
|
gr.Markdown(
|
||||||
"""
|
"""
|
||||||
# Text generation:distilgpt2
|
# Text generation:distilgpt2
|
||||||
Gradio Demo for distilgpt2. To use it, simply type in text, or click one of the examples to load them.
|
Gradio Demo for distilgpt2. To use it, simply type in text, or click one of the examples to load them.
|
||||||
""")
|
""")
|
||||||
|
@ -34,6 +28,6 @@ with gr.Blocks() as demo:
|
||||||
text_output = gr.Textbox()
|
text_output = gr.Textbox()
|
||||||
image_button = gr.Button("上传")
|
image_button = gr.Button("上传")
|
||||||
image_button.click(inference, inputs=text_input, outputs=text_output)
|
image_button.click(inference, inputs=text_input, outputs=text_output)
|
||||||
gr.Examples(examples,inputs=text_input)
|
gr.Examples(examples, inputs=text_input)
|
||||||
|
|
||||||
demo.launch()
|
demo.launch()
|
||||||
|
|
Loading…
Reference in New Issue