Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,8 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
10 |
|
11 |
device = torch.device("cuda:0")
|
12 |
|
13 |
-
llm = AutoModelForCausalLM.from_pretrained("Azure99/blossom-v5-
|
14 |
-
tokenizer = AutoTokenizer.from_pretrained("Azure99/blossom-v5-
|
15 |
diffusion_pipe = DiffusionPipeline.from_pretrained(
|
16 |
"playgroundai/playground-v2.5-1024px-aesthetic",
|
17 |
torch_dtype=torch.float16,
|
@@ -35,20 +35,20 @@ def save_image(img):
|
|
35 |
|
36 |
LLM_PROMPT = '''你的任务是从输入的[作画要求]中抽取画面描述(description),然后description翻译为英文(en_description),最后对en_description进行扩写(expanded_description),增加足够多的细节,且符合人类的第一直觉。
|
37 |
[输出]是一个json,包含description、en_description、expanded_description三个字符串字段,请直接输出一个完整的json,不要输出任何解释或其他无关内容。
|
38 |
-
|
39 |
下面是一些示例:
|
40 |
[作画要求]->"画一幅画:落霞与孤鹜齐飞,秋水共长天一色。"
|
41 |
-
[输出]->{"description": "落霞与孤鹜齐飞,秋水共长天一色", "en_description": "The setting sun and the solitary duck fly together, the autumn water shares a single hue with the vast sky", "expanded_description": "A
|
42 |
-
|
43 |
[作画要求]->"原神中的可莉"
|
44 |
-
[输出]->{"description": "原神中的可莉", "en_description": "Klee in Genshin Impact", "expanded_description": "
|
45 |
-
|
46 |
[作画要求]->"create an image for me. a close up of a woman wearing a transparent, prismatic, elaborate nemeses headdress, over the should pose, brown skin-tone"
|
47 |
-
[输出]->{"description": "a close up of a woman wearing a transparent, prismatic, elaborate nemeses headdress, over the should pose, brown skin-tone", "en_description": "a close up of a woman wearing a transparent, prismatic, elaborate nemeses headdress, over the should pose, brown skin-tone", "expanded_description": "
|
48 |
-
|
49 |
[作画要求]->"一只高贵的柯基犬,素描画风格\n根据上面的描述生成一张图片吧!"
|
50 |
-
[输出]->{"description": "一只高贵的柯基犬,素描画风格", "en_description": "A noble corgi dog, sketch style", "expanded_description": "A
|
51 |
-
|
52 |
[作画要求]->$USER_PROMPT
|
53 |
[输出]->'''
|
54 |
|
@@ -99,9 +99,9 @@ def generate(
|
|
99 |
|
100 |
|
101 |
css = '''
|
102 |
-
.gradio-container{max-width: 560px !important}
|
103 |
-
h1{text-align:center}
|
104 |
-
'''
|
105 |
with gr.Blocks(css=css) as demo:
|
106 |
gr.Markdown("# Blossom Playground v2.5")
|
107 |
with gr.Group():
|
|
|
10 |
|
11 |
device = torch.device("cuda:0")
|
12 |
|
13 |
+
llm = AutoModelForCausalLM.from_pretrained("Azure99/blossom-v5-9b", torch_dtype=torch.float16, device_map="auto")
|
14 |
+
tokenizer = AutoTokenizer.from_pretrained("Azure99/blossom-v5-9b")
|
15 |
diffusion_pipe = DiffusionPipeline.from_pretrained(
|
16 |
"playgroundai/playground-v2.5-1024px-aesthetic",
|
17 |
torch_dtype=torch.float16,
|
|
|
35 |
|
36 |
LLM_PROMPT = '''你的任务是从输入的[作画要求]中抽取画面描述(description),然后description翻译为英文(en_description),最后对en_description进行扩写(expanded_description),增加足够多的细节,且符合人类的第一直觉。
|
37 |
[输出]是一个json,包含description、en_description、expanded_description三个字符串字段,请直接输出一个完整的json,不要输出任何解释或其他无关内容。
|
38 |
+
|
39 |
下面是一些示例:
|
40 |
[作画要求]->"画一幅画:落霞与孤鹜齐飞,秋水共长天一色。"
|
41 |
+
[输出]->{"description": "落霞与孤鹜齐飞,秋水共长天一色", "en_description": "The setting sun and the solitary duck fly together, the autumn water shares a single hue with the vast sky", "expanded_description": "A lone duck gracefully gliding across the tranquil surface of a shimmering lake, bathed in the warm golden glow of the setting sun, creating a breathtaking scene of natural beauty and tranquility."}
|
42 |
+
|
43 |
[作画要求]->"原神中的可莉"
|
44 |
+
[输出]->{"description": "原神中的可莉", "en_description": "Klee in Genshin Impact", "expanded_description": "An artistic portrait of Klee from Genshin Impact, standing in a vibrant meadow with colorful explosions of her elemental abilities in the background."}
|
45 |
+
|
46 |
[作画要求]->"create an image for me. a close up of a woman wearing a transparent, prismatic, elaborate nemeses headdress, over the should pose, brown skin-tone"
|
47 |
+
[输出]->{"description": "a close up of a woman wearing a transparent, prismatic, elaborate nemeses headdress, over the should pose, brown skin-tone", "en_description": "a close up of a woman wearing a transparent, prismatic, elaborate nemeses headdress, over the should pose, brown skin-tone", "expanded_description": "A close-up portrait of an elegant woman with rich brown skin, wearing a stunning transparent, prismatic, and intricately detailed Nemes headdress, striking a confident and alluring over-the-shoulder pose."}
|
48 |
+
|
49 |
[作画要求]->"一只高贵的柯基犬,素描画风格\n根据上面的描述生成一张图片吧!"
|
50 |
+
[输出]->{"description": "一只高贵的柯基犬,素描画风格", "en_description": "A noble corgi dog, sketch style", "expanded_description": "A majestic corgi with a regal bearing, depicted in a detailed and intricate pencil sketch, capturing the essence of its noble lineage and dignified presence."}
|
51 |
+
|
52 |
[作画要求]->$USER_PROMPT
|
53 |
[输出]->'''
|
54 |
|
|
|
99 |
|
100 |
|
101 |
css = '''
|
102 |
+
.gradio-container{max-width: 560px !important}
|
103 |
+
h1{text-align:center}
|
104 |
+
'''
|
105 |
with gr.Blocks(css=css) as demo:
|
106 |
gr.Markdown("# Blossom Playground v2.5")
|
107 |
with gr.Group():
|