Spaces:
Runtime error
Runtime error
File size: 1,074 Bytes
b6f9036 a9aabfe b6f9036 46e2de7 ced5105 b6f9036 5d15bc9 b6f9036 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# 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()
|