Spaces:
Runtime error
Runtime error
Commit
·
c35fda2
1
Parent(s):
5757896
Upload simple_run.gradio.py
Browse files- simple_run.gradio.py +44 -0
simple_run.gradio.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#该应用创建工具共包含三个区域,顶部工具栏,左侧代码区,右侧交互效果区,其中右侧交互效果是通过左侧代码生成的,存在对照关系。
|
2 |
+
#顶部工具栏:运行、保存、新开浏览器打开、实时预览开关,针对运行和在浏览器打开选项进行重要说明:
|
3 |
+
#[运行]:交互效果并非实时更新,代码变更后,需点击运行按钮获得最新交互效果。
|
4 |
+
#[在浏览器打开]:新建页面查看交互效果。
|
5 |
+
#以下为应用创建工具的示例代码
|
6 |
+
|
7 |
+
import gradio as gr
|
8 |
+
from ppdiffusers import StableDiffusionPipeline
|
9 |
+
import os
|
10 |
+
|
11 |
+
# 加载模型
|
12 |
+
model_path = "dream_outputs"
|
13 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_path)
|
14 |
+
|
15 |
+
def generate_images(prompt="Neolle", num_inference_steps=50, guidance_scale=7.5):
|
16 |
+
image = pipe(prompt, num_inference_steps=int(num_inference_steps),guidance_scale=float(guidance_scale)).images[0]
|
17 |
+
# image = os.getcwd()
|
18 |
+
return image
|
19 |
+
|
20 |
+
with gr.Blocks() as demo:
|
21 |
+
gr.Markdown(
|
22 |
+
"""
|
23 |
+
# 诺艾尔生成器
|
24 |
+
基于 Linaqruf/anything-v3.0 训练,采用DreamBooth的技术并使用a photo of Neolle文本进行了训练。用于微调的图片共10张,均为原神角色诺艾尔,batch_size取1,学习率是5e-6,共训练1000步。
|
25 |
+
|
26 |
+
## 输入参数如下:
|
27 |
+
- prompt:提示语
|
28 |
+
- num_inference_steps: 推理轮次,越高越耗时,能够提高画作结果的精细程度,默认50
|
29 |
+
- guidance_scale:训练图片的影响度,如果无法满足提示词描述的场景,可以降低该值,默认7.5
|
30 |
+
|
31 |
+
## 推荐的提示词示例:
|
32 |
+
- Noelle with glasses
|
33 |
+
- Noelle with sunglasses
|
34 |
+
- Noelle with dark hair, beautiful eyes
|
35 |
+
- Noelle, 20 years old
|
36 |
+
- Noelle playing basketball
|
37 |
+
- Noelle with cat ears, blue hair
|
38 |
+
""")
|
39 |
+
gr.Interface(fn=generate_images,
|
40 |
+
inputs=["text","text","text"],
|
41 |
+
outputs="image")
|
42 |
+
|
43 |
+
if __name__ == "__main__":
|
44 |
+
demo.launch()
|