Azure99 commited on
Commit
70bee57
1 Parent(s): ddaba6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
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-4b", torch_dtype=torch.float16, device_map="auto")
14
- tokenizer = AutoTokenizer.from_pretrained("Azure99/blossom-v5-4b")
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 single duck is flying in the vast sky that is shared with the setting sun, mirroring the serenity of the autumn waters beneath. The tranquil water is reflecting the sublime orange hues of the twilight sky, blending all into a picturesque harmony. It's an awe-inspiring end to a quiet autumn day, the scene dominated by immense tranquility and beauty."}
42
-
43
  [作画要求]->"原神中的可莉"
44
- [输出]->{"description": "原神中的可莉", "en_description": "Klee in Genshin Impact", "expanded_description": "A small animated girl with flaming red hair in pigtails, amber eyes, and a star-shaped hairpin. She is dressed in a crimson and white outfit with a distinctive gold trim. On her back, she carries a large russet backpack that looks like a treasure chest. In her hand, she holds a supernatural-looking bomb with sparkling particles evolving around it. This setting is in a colorful and magical world with ethereal floating islands and a dabbling stream nearby."}
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": "An intricate close-up detailing a woman with a brown skin-tone. She is seen from an over-the-shoulder perspective and is adorned with a transparent, prismatic, and elaborate headdress similar to a nemes, showcasing a myriad of refracted colors across its unique design."}
48
-
49
  [作画要求]->"一只高贵的柯基犬,素描画风格\n根据上面的描述生成一张图片吧!"
50
- [输出]->{"description": "一只高贵的柯基犬,素描画风格", "en_description": "A noble corgi dog, sketch style", "expanded_description": "A noble corgi dog, standing with a majestic aura, in the style of an old-fashioned sketch. The corgi displays a regal posture, with its head raised high and ears perked up. Its fur is short and dense, embodying various shades of brown and white. The sketch emphasizes the contrast and depth of the corgi's coat textures, his expressive eyes full of intelligence and alertness, and his little stubby tail wagging with joy. The background is composed of light strokes, providing a minimalistic setup that further highlights the corgi's nobility."}
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():