Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# 加载模型和tokenizer | |
generator = pipeline('text-generation', model='hfl/chinese-llama-2-1.3b') | |
# 定义预测函数 | |
def predict(text,password,temperature): | |
if password != "123": | |
return "Password wrong" | |
else: | |
result = generator(text, max_length=400, num_return_sequences=1 , temperature=float(temperature)) | |
return result[0]['generated_text'] | |
# 创建Gradio界面 | |
demo = gr.Interface(fn=predict,inputs=[gr.Textbox(label="Text"),gr.Textbox(label="Password"),gr.Textbox(label="temperature")],outputs="text",title="Chinese-llama-2-1.3b",description="input your text") | |
# 启动Gradio界面 | |
demo.launch(share=True) |