Spaces:
Runtime error
Runtime error
| # 1.安装依赖 | |
| import os | |
| os.system("pip install paddlepaddle") | |
| os.system("pip install paddlenlp==2.5.2") | |
| os.system("pip install ppdiffusers==0.11.1") | |
| # 2.导入库文件 | |
| import gradio as gr | |
| from ppdiffusers import DiffusionPipeline, DPMSolverMultistepScheduler | |
| import paddle | |
| # 3.功能函数 | |
| def quickstart(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| # 4.样式设计 | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# 用 LoRA 和 DreamBooth 创作: 万物皆Coding") | |
| gr.Image("2100.png") | |
| gr.Markdown("## prompt: A picture of person coding") | |
| gr.Markdown("## prompt: A picture of dog coding") | |
| greet_btn = gr.Button("开始生成") | |
| input_text=gr.Textbox(label="输入你想要的主体") | |
| # 5.接口调用 | |
| greet_btn.click(quickstart, inputs=input_text, outputs=gr.Image()) | |
| # 6.加载模型 | |
| pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5") | |
| pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config) | |
| pipe.unet.load_attn_procs("mortal99", from_hf_hub=True) | |
| # 7.启动 | |
| demo.launch() | |