cwhuh commited on
Commit
39fee28
ยท
1 Parent(s): e841ca6

chore : remove output structure, refined prompt

Browse files
Files changed (3) hide show
  1. app.py +1 -6
  2. llm_wrapper.py +0 -6
  3. 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.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": ""