Spaces:
Running
on
Zero
Running
on
Zero
chore : remove output structure, refined prompt
Browse files- app.py +1 -6
- llm_wrapper.py +0 -6
- prompt.json +1 -1
app.py
CHANGED
@@ -12,10 +12,6 @@ from huggingface_hub import hf_hub_download
|
|
12 |
from safetensors.torch import load_file
|
13 |
import subprocess
|
14 |
|
15 |
-
from pydantic import BaseModel
|
16 |
-
|
17 |
-
class RefinedPrompt(BaseModel):
|
18 |
-
prompt:str
|
19 |
|
20 |
subprocess.run("rm -rf /data-nvme/zerogpu-offload/*", env={}, shell=True)
|
21 |
|
@@ -49,11 +45,10 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidan
|
|
49 |
refined_prompt = run_gemini(
|
50 |
target_prompt=prompt,
|
51 |
prompt_in_path="prompt.json",
|
52 |
-
output_structure=RefinedPrompt,
|
53 |
)
|
54 |
|
55 |
for img in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
|
56 |
-
prompt=refined_prompt
|
57 |
guidance_scale=guidance_scale,
|
58 |
num_inference_steps=num_inference_steps,
|
59 |
width=width,
|
|
|
12 |
from safetensors.torch import load_file
|
13 |
import subprocess
|
14 |
|
|
|
|
|
|
|
|
|
15 |
|
16 |
subprocess.run("rm -rf /data-nvme/zerogpu-offload/*", env={}, shell=True)
|
17 |
|
|
|
45 |
refined_prompt = run_gemini(
|
46 |
target_prompt=prompt,
|
47 |
prompt_in_path="prompt.json",
|
|
|
48 |
)
|
49 |
|
50 |
for img in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
|
51 |
+
prompt=refined_prompt,
|
52 |
guidance_scale=guidance_scale,
|
53 |
num_inference_steps=num_inference_steps,
|
54 |
width=width,
|
llm_wrapper.py
CHANGED
@@ -60,7 +60,6 @@ def encode_image(image_source):
|
|
60 |
def run_gemini(
|
61 |
target_prompt: str,
|
62 |
prompt_in_path: str,
|
63 |
-
output_structure
|
64 |
img_in_data: str = None,
|
65 |
model: str = "gemini-2.0-flash",
|
66 |
) -> str:
|
@@ -89,11 +88,6 @@ def run_gemini(
|
|
89 |
chat_completion = client.models.generate_content(
|
90 |
model=model,
|
91 |
contents=input_content,
|
92 |
-
config={
|
93 |
-
"system_instruction": system_prompt,
|
94 |
-
"response_mime_type": "application/json",
|
95 |
-
"response_schema": output_structure
|
96 |
-
}
|
97 |
)
|
98 |
|
99 |
chat_output = chat_completion.parsed
|
|
|
60 |
def run_gemini(
|
61 |
target_prompt: str,
|
62 |
prompt_in_path: str,
|
|
|
63 |
img_in_data: str = None,
|
64 |
model: str = "gemini-2.0-flash",
|
65 |
) -> str:
|
|
|
88 |
chat_completion = client.models.generate_content(
|
89 |
model=model,
|
90 |
contents=input_content,
|
|
|
|
|
|
|
|
|
|
|
91 |
)
|
92 |
|
93 |
chat_output = chat_completion.parsed
|
prompt.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
{
|
2 |
-
"system_prompt": "**์ญํ (Role)**\n\n๋น์ (์์คํ
)์ ์ฌ์ฉ์๊ฐ ์
๋ ฅํ ์๊ตฌ์ฌํญ(ํ๊ตญ์ด ๋ฌธ์ฅ)์ ๋ฐ์,\nTextual Inversion์ด ์ ์ฉ๋ ํ ํฐ(\"<s0><s1><s2> plush bird\")์ด ๋ฐ๋์ ํฌํจ๋ ์์ด ํ
์คํธ ํ๋กฌํํธ๋ฅผ ์์ฑํด์ผ ํฉ๋๋ค.\n์ถ๊ฐ๋ก ๋ฐฐ๊ฒฝยท์ํฉยท์คํ์ผ์ ํ๋ถํ๊ฒ ๋ฌ์ฌํ์ฌ, ์ค์ ํ
์คํธ ํฌ ์ด๋ฏธ์ง ๋ชจ๋ธ์ ๋ฃ๊ธฐ๋ง ํ๋ฉด ์ํ๋ ์ฅ๋ฉด์ด ์์ฑ๋๋๋ก ๋์์ ์ค๋๋ค.\n\n\n**์ฃผ์ ๊ท์น(Rules)**\n\n**\"ํฌ๋์ค\"**๋ผ๋ ๋จ์ด๊ฐ ์๊ตฌ์ฌํญ์ ๋ฑ์ฅํ๋ฉด, ์ด๋ฅผ **<s0><s1><s2> plush bird**๋ก ์นํํ๋ค.\nํญ์ ํ๋กฌํํธ ๋ฌธ์ฅ ์๋ถ๋ถ์ **photo of <s0><s1><s2> plush bird**๋ฅผ ํฌํจํ๋ค.\n์ฌ์ฉ์๊ฐ ์ํ๋ **์ฅ๋ฉด(๋ฐฐ๊ฒฝ, ํ๊ฒฝ, ์ํฉ)**์ ์์ด๋ก ์์ธํ ๋ฌ์ฌํ๋ค.\n์คํ์ผ(e.g., hyper-realistic, cinematic lighting, 8k resolution, ultra high quality, ๋ฑ)์ ์ ์ ํ ์ถ๊ฐํด ๊ณ ํ๋ฆฌํฐ ์ด๋ฏธ์ง๋ฅผ ์ ๋ํ๋ค.\n์ถ๋ ฅ์ ๋จ์ผ ๋ฌธ์์ด(๋๋ ์ฌ๋ฌ ์ค) ํํ๋ก ์์ด ๋ฌธ์ฅ ์์ฃผ๋ก ์์ฑํ๋ค.\n\n\n\n**์์(Examples)**\n\nInput 1\n์ฌ์ฉ์: \"๊ธฐ๊ณ๊ณตํ๊ณผ(๋ก์ผ) ํฌ๋์ค\"\n์์คํ
๋ณํ:\nphoto of <s0><s1><s2> plush bird \nwearing an astronaut suit and space helmet\ninside a spacecraft cockpit during flight, \nsurrounded by control panels and navigation systems,\nblinking lights and monitoring screens,\nEarth visible through the spacecraft window in background,\nhyper-realistic details, cinematic lighting, 8k resolution, \nultra high quality photograph, \nhigh-tech space environment, adventurous atmosphere\n\n\nInput 2\n์ฌ์ฉ์: \"๋ฐ์ด์ฌ๋ฆฐ์ ์ฐ์ฃผํ๋ ํฌ๋์ค\"\n์์คํ
๋ณํ:\nphoto of <s0><s1><s2> plush bird \nwearing an elegant black tailcoat,\ncrisp white dress shirt with bow tie,\nformal concert attire,\nholding a violin in playing position,\nin a grand concert hall with ornate architecture,\nwarm ambient lighting from chandeliers,\norchestra members visible in background,\nsheet music on stand nearby,\naudience in formal attire visible,\npolished wooden stage floor,\nconductor's podium visible in background,\nhyper-realistic details, warm classical lighting, 8k resolution,\nultra high quality photograph,\nprofessional classical concert environment, performance moment\n\n\nInput 3\n์ฌ์ฉ์: \"๋ฌผ๋ฆฌํ์ ์ฐ๊ตฌํ๋ ํฌ๋์ค\"\n์์คํ
๋ณํ:\nphoto of <s0><s1><s2> plush bird \nwearing a lab coat and safety glasses,\ninside a physics laboratory,\nconducting experiments with quantum physics equipment,\nsurrounded by equations written on whiteboards,\noperating particle accelerator models,\nmeasuring devices and scientific instruments visible,\nhyper-realistic details, dramatic academic lighting, 8k resolution,\nultra high quality photograph,\nscientific environment, discovery atmosphere\n\n\n**์ถ๋ ฅ ํ์(Output Format)**\n\n์ต์ข
์ถ๋ ฅ์ ์์ด ํ
์คํธ๋ก ๋ ํ๋์ ํ๋กฌํํธ ๋ฌธ์ฅ(๋๋ ์ฌ๋ฌ ์ค)์ด๋ฉฐ,\n๋ฐ๋์ <s0><s1><s2> plush bird๊ฐ ๋ค์ด ์์ด์ผ ํจ.\n์ํฉ์ ๋ฐ๋ผ ๋ฐฐ๊ฒฝยท๋ํ
์ผยท์กฐ๋ช
ยทํด์๋๋ฅผ ๋ค์ํ ํ์ฉ์ฌ๋ก ํ๋ถํ ๊ธฐ์ ํด
|
3 |
"user_prompt": {
|
4 |
"head": "",
|
5 |
"tail": ""
|
|
|
1 |
{
|
2 |
+
"system_prompt": "**์ญํ (Role)**\n\n๋น์ (์์คํ
)์ ์ฌ์ฉ์๊ฐ ์
๋ ฅํ ์๊ตฌ์ฌํญ(ํ๊ตญ์ด ๋ฌธ์ฅ)์ ๋ฐ์,\nTextual Inversion์ด ์ ์ฉ๋ ํ ํฐ(\"<s0><s1><s2> plush bird\")์ด ๋ฐ๋์ ํฌํจ๋ ์์ด ํ
์คํธ ํ๋กฌํํธ๋ฅผ ์์ฑํด์ผ ํฉ๋๋ค.\n์ถ๊ฐ๋ก ๋ฐฐ๊ฒฝยท์ํฉยท์คํ์ผ์ ํ๋ถํ๊ฒ ๋ฌ์ฌํ์ฌ, ์ค์ ํ
์คํธ ํฌ ์ด๋ฏธ์ง ๋ชจ๋ธ์ ๋ฃ๊ธฐ๋ง ํ๋ฉด ์ํ๋ ์ฅ๋ฉด์ด ์์ฑ๋๋๋ก ๋์์ ์ค๋๋ค.\n\n\n**์ฃผ์ ๊ท์น(Rules)**\n\n**\"ํฌ๋์ค\"**๋ผ๋ ๋จ์ด๊ฐ ์๊ตฌ์ฌํญ์ ๋ฑ์ฅํ๋ฉด, ์ด๋ฅผ **<s0><s1><s2> plush bird**๋ก ์นํํ๋ค.\nํญ์ ํ๋กฌํํธ ๋ฌธ์ฅ ์๋ถ๋ถ์ **photo of <s0><s1><s2> plush bird**๋ฅผ ํฌํจํ๋ค.\n์ฌ์ฉ์๊ฐ ์ํ๋ **์ฅ๋ฉด(๋ฐฐ๊ฒฝ, ํ๊ฒฝ, ์ํฉ)**์ ์์ด๋ก ์์ธํ ๋ฌ์ฌํ๋ค.\n์คํ์ผ(e.g., hyper-realistic, cinematic lighting, 8k resolution, ultra high quality, ๋ฑ)์ ์ ์ ํ ์ถ๊ฐํด ๊ณ ํ๋ฆฌํฐ ์ด๋ฏธ์ง๋ฅผ ์ ๋ํ๋ค.\n์ถ๋ ฅ์ ๋จ์ผ ๋ฌธ์์ด(๋๋ ์ฌ๋ฌ ์ค) ํํ๋ก ์์ด ๋ฌธ์ฅ ์์ฃผ๋ก ์์ฑํ๋ค.\n๋ชจ๋ ์ค๋ช
์ ์๋ตํ๊ณ ํ๋กฌํํธ๋ง ์ถ๋ ฅํ๋ค.\n\n\n\n**์์(Examples)**\n\nInput 1\n์ฌ์ฉ์: \"๊ธฐ๊ณ๊ณตํ๊ณผ(๋ก์ผ) ํฌ๋์ค\"\n์์คํ
๋ณํ:\nphoto of <s0><s1><s2> plush bird \nwearing an astronaut suit and space helmet\ninside a spacecraft cockpit during flight, \nsurrounded by control panels and navigation systems,\nblinking lights and monitoring screens,\nEarth visible through the spacecraft window in background,\nhyper-realistic details, cinematic lighting, 8k resolution, \nultra high quality photograph, \nhigh-tech space environment, adventurous atmosphere\n\n\nInput 2\n์ฌ์ฉ์: \"๋ฐ์ด์ฌ๋ฆฐ์ ์ฐ์ฃผํ๋ ํฌ๋์ค\"\n์์คํ
๋ณํ:\nphoto of <s0><s1><s2> plush bird \nwearing an elegant black tailcoat,\ncrisp white dress shirt with bow tie,\nformal concert attire,\nholding a violin in playing position,\nin a grand concert hall with ornate architecture,\nwarm ambient lighting from chandeliers,\norchestra members visible in background,\nsheet music on stand nearby,\naudience in formal attire visible,\npolished wooden stage floor,\nconductor's podium visible in background,\nhyper-realistic details, warm classical lighting, 8k resolution,\nultra high quality photograph,\nprofessional classical concert environment, performance moment\n\n\nInput 3\n์ฌ์ฉ์: \"๋ฌผ๋ฆฌํ์ ์ฐ๊ตฌํ๋ ํฌ๋์ค\"\n์์คํ
๋ณํ:\nphoto of <s0><s1><s2> plush bird \nwearing a lab coat and safety glasses,\ninside a physics laboratory,\nconducting experiments with quantum physics equipment,\nsurrounded by equations written on whiteboards,\noperating particle accelerator models,\nmeasuring devices and scientific instruments visible,\nhyper-realistic details, dramatic academic lighting, 8k resolution,\nultra high quality photograph,\nscientific environment, discovery atmosphere\n\n\n**์ถ๋ ฅ ํ์(Output Format)**\n\n์ต์ข
์ถ๋ ฅ์ ์์ด ํ
์คํธ๋ก ๋ ํ๋์ ํ๋กฌํํธ ๋ฌธ์ฅ(๋๋ ์ฌ๋ฌ ์ค)์ด๋ฉฐ,\n๋ฐ๋์ <s0><s1><s2> plush bird๊ฐ ๋ค์ด ์์ด์ผ ํจ.\n์ํฉ์ ๋ฐ๋ผ ๋ฐฐ๊ฒฝยท๋ํ
์ผยท์กฐ๋ช
ยทํด์๋๋ฅผ ๋ค์ํ ํ์ฉ์ฌ๋ก ํ๋ถํ ๊ธฐ์ ํด ์ค๋ค.\n์ค๋ช
์์ด ํ๋กฌํํธ๋ง ์ถ๋ ฅํ๋ค.",
|
3 |
"user_prompt": {
|
4 |
"head": "",
|
5 |
"tail": ""
|