mortal99 commited on
Commit
b6f9036
1 Parent(s): 0ac4a04

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 1.安装依赖
2
+ import os
3
+ os.system("pip install paddlenlp==2.5.2")
4
+ os.system("pip install ppdiffusers==0.11.1")
5
+
6
+ # 2.导入库文件
7
+ import gradio as gr
8
+ from ppdiffusers import DiffusionPipeline, DPMSolverMultistepScheduler
9
+ import paddle
10
+
11
+ # 3.功能函数
12
+ def quickstart(prompt):
13
+ image = pipe(prompt).images[0]
14
+ return image
15
+
16
+ # 4.样式设计
17
+ with gr.Blocks() as demo:
18
+ gr.Markdown("# 用 LoRA 和 DreamBooth 创作: 万物皆会Coding")
19
+ gr.Image("image/gaoda01.png")
20
+ gr.Markdown("## prompt: A picture of person coding")
21
+ gr.Markdown("## prompt: A picture of dog coding")
22
+ greet_btn = gr.Button("开始生成")
23
+ input_text=gr.Textbox(label="输入你想要的主体")
24
+ # 5.接口调用
25
+ greet_btn.click(quickstart, inputs=input_text, outputs=gr.Image())
26
+
27
+ # 6.加载模型
28
+ pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
29
+ pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
30
+ pipe.unet.load_attn_procs("model_output/", from_hf_hub=False)
31
+
32
+ # 7.启动
33
+ demo.launch()