File size: 735 Bytes
00d6742
70812f9
 
00d6742
35727aa
70812f9
00d6742
 
 
70812f9
00d6742
 
 
 
35727aa
 
70812f9
00d6742
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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.inputs.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()