Gradio / main.py
nchen909's picture
Update main.py
7012ad7 verified
raw
history blame contribute delete
728 Bytes
import gradio as gr
from transformers import pipeline
# 初始化pipeline
pipe_gpt = pipeline("text-generation", model="FreedomIntelligence/Apollo-0.5B", trust_remote_code=True)
def generate_text(input_text):
output = pipe_gpt(input_text, max_length=500) # 调整max_length来控制生成文本的长度
return output[0]["generated_text"]
# 创建Gradio界面
iface = gr.Interface(fn=generate_text,
inputs=gr.Textbox(lines=5, placeholder="Type your prompt here..."),
outputs="text",
title="Text Generation with Apollo-0.5B",
description="Enter some text to see how Apollo-0.5B continues it.")
# 运行Gradio应用
iface.launch()