EntropyDrop commited on
Commit
2d86a45
·
1 Parent(s): bf40649
Files changed (29) hide show
  1. DDJ_real2render/real2render.py +16 -3
  2. DDJ_real2render/template/template14.png +3 -0
  3. DDJ_real2render/template/template15.png +3 -0
  4. DDJ_real2render/test_batch.sh +15 -0
  5. DDJ_real2render/test_output/img10_template13.png +3 -0
  6. DDJ_real2render/test_output/img11_template13.png +3 -0
  7. DDJ_real2render/test_output/img11_template14.png +3 -0
  8. DDJ_real2render/test_output/img12_template13.png +3 -0
  9. DDJ_real2render/test_output/img12_template14.png +3 -0
  10. DDJ_real2render/test_output/img13_template13.png +3 -0
  11. DDJ_real2render/test_output/img13_template14.png +3 -0
  12. DDJ_real2render/test_output/img14_template13.png +3 -0
  13. DDJ_real2render/test_output/img14_template14.png +3 -0
  14. DDJ_real2render/test_output/img15_template13.png +3 -0
  15. DDJ_real2render/test_output/img15_template14.png +3 -0
  16. DDJ_real2render/test_output/img15_template14_template15.png +3 -0
  17. DDJ_real2render/test_output/img16_template13.png +3 -0
  18. DDJ_real2render/test_output/img16_template14.png +3 -0
  19. DDJ_real2render/test_output/img16_template14_template15.png +3 -0
  20. DDJ_real2render/test_output/img17_template13.png +3 -0
  21. DDJ_real2render/test_output/img17_template14.png +3 -0
  22. DDJ_real2render/test_output/img17_template14_template15.png +3 -0
  23. DDJ_real2render/test_output/img2_template13.png +3 -0
  24. DDJ_real2render/test_output/img3_template13.png +3 -0
  25. DDJ_real2render/test_output/img4_template13.png +3 -0
  26. DDJ_real2render/test_output/img6_template13_2.png +3 -0
  27. DDJ_real2render/test_output/img7_template13.png +3 -0
  28. DDJ_real2render/test_output/img8_template13.png +3 -0
  29. DDJ_real2render/test_output/img9_template13.png +3 -0
DDJ_real2render/real2render.py CHANGED
@@ -12,7 +12,7 @@ DEFAULT_TEMPLATE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),
12
  # Default prompt for real-to-render Minecraft character generation
13
  DEFAULT_PROMPT = """生成[图1]中角色的Minecraft形象
14
 
15
- - 人物模型必须与minecraft的玩家模型相同,且为包含内层/外层贴图的双图层模型,不能有额外元素。材质不能高于Minecraft所支持的分辨率。模型参考[图2]
16
 
17
  - 生成的minecraft角色的姿势与[图2]完全一致(不是笔直站立),且必须包含正面图与背面图,并排放置。
18
 
@@ -20,12 +20,13 @@ DEFAULT_PROMPT = """生成[图1]中角色的Minecraft形象
20
 
21
  - 在上述约束下,尽可能完美、准确的还原[图1]中的角色,包括外貌特征、全身所有服装、各种饰品等(不包括手持物品)"""
22
 
23
- def real2render(image_path, template_path=None, output_path=None, prompt=None, aspect_ratio="1:1", image_size="1K"):
24
  """
25
  High-level API to generate a Minecraft 3D character render from a real character photo using Nano Banana Pro.
26
 
27
  :param image_path: Path to the real character input image (Graph 1).
28
  :param template_path: Path to the template reference image (Graph 2, defaults to inverse_uv/template.png).
 
29
  :param output_path: Output PNG path.
30
  :param prompt: Custom prompt text (defaults to standard Minecraft real-to-render prompt).
31
  :param aspect_ratio: Image aspect ratio (default: "1:1").
@@ -39,15 +40,25 @@ def real2render(image_path, template_path=None, output_path=None, prompt=None, a
39
  if not os.path.exists(template_file):
40
  raise FileNotFoundError(f"Template image '{template_file}' does not exist.")
41
 
 
 
 
 
42
  prompt_text = prompt or DEFAULT_PROMPT
43
 
44
  print(f"[*] Real Image (Graph 1): {image_path}")
45
  print(f"[*] Template Image (Graph 2): {template_file}")
 
 
46
  print(f"[*] Image Size: {image_size}, Aspect Ratio: {aspect_ratio}")
47
  print(f"[*] Prompt:\n{prompt_text}\n")
48
 
 
 
 
 
49
  output_file = banana_pro_image.generate_img2img(
50
- local_image_paths=[image_path, template_file],
51
  prompt=prompt_text,
52
  output_path=output_path,
53
  aspect_ratio=aspect_ratio,
@@ -59,6 +70,7 @@ def main():
59
  parser = argparse.ArgumentParser(description="Convert real character photo to Minecraft render using Nano Banana Pro.")
60
  parser.add_argument("image", help="Path to local real character photo (Graph 1).")
61
  parser.add_argument("-t", "--template", default=DEFAULT_TEMPLATE_PATH, help="Path to reference template image (Graph 2).")
 
62
  parser.add_argument("-o", "--output", help="Output path for the generated image.")
63
  parser.add_argument("-p", "--prompt", default=DEFAULT_PROMPT, help="Prompt for image generation.")
64
  parser.add_argument("-a", "--aspect-ratio", default="1:1",
@@ -71,6 +83,7 @@ def main():
71
  output_file = real2render(
72
  image_path=args.image,
73
  template_path=args.template,
 
74
  output_path=args.output,
75
  prompt=args.prompt,
76
  aspect_ratio=args.aspect_ratio,
 
12
  # Default prompt for real-to-render Minecraft character generation
13
  DEFAULT_PROMPT = """生成[图1]中角色的Minecraft形象
14
 
15
+ - 人物模型必须与minecraft的玩家模型相同,且为包含内层/外层贴图的双图层模型,不能有额外元素。材质不能高于Minecraft所支持的分辨率。模型参考[图2]和[图3]
16
 
17
  - 生成的minecraft角色的姿势与[图2]完全一致(不是笔直站立),且必须包含正面图与背面图,并排放置。
18
 
 
20
 
21
  - 在上述约束下,尽可能完美、准确的还原[图1]中的角色,包括外貌特征、全身所有服装、各种饰品等(不包括手持物品)"""
22
 
23
+ def real2render(image_path, template_path=None, template2_path=None, output_path=None, prompt=None, aspect_ratio="1:1", image_size="1K"):
24
  """
25
  High-level API to generate a Minecraft 3D character render from a real character photo using Nano Banana Pro.
26
 
27
  :param image_path: Path to the real character input image (Graph 1).
28
  :param template_path: Path to the template reference image (Graph 2, defaults to inverse_uv/template.png).
29
+ :param template2_path: Path to the second template reference image (Graph 3, defaults to None).
30
  :param output_path: Output PNG path.
31
  :param prompt: Custom prompt text (defaults to standard Minecraft real-to-render prompt).
32
  :param aspect_ratio: Image aspect ratio (default: "1:1").
 
40
  if not os.path.exists(template_file):
41
  raise FileNotFoundError(f"Template image '{template_file}' does not exist.")
42
 
43
+ template2_file = template2_path
44
+ if template2_file and not os.path.exists(template2_file):
45
+ raise FileNotFoundError(f"Template 2 image '{template2_file}' does not exist.")
46
+
47
  prompt_text = prompt or DEFAULT_PROMPT
48
 
49
  print(f"[*] Real Image (Graph 1): {image_path}")
50
  print(f"[*] Template Image (Graph 2): {template_file}")
51
+ if template2_file:
52
+ print(f"[*] Template 2 Image (Graph 3): {template2_file}")
53
  print(f"[*] Image Size: {image_size}, Aspect Ratio: {aspect_ratio}")
54
  print(f"[*] Prompt:\n{prompt_text}\n")
55
 
56
+ local_image_paths = [image_path, template_file]
57
+ if template2_file:
58
+ local_image_paths.append(template2_file)
59
+
60
  output_file = banana_pro_image.generate_img2img(
61
+ local_image_paths=local_image_paths,
62
  prompt=prompt_text,
63
  output_path=output_path,
64
  aspect_ratio=aspect_ratio,
 
70
  parser = argparse.ArgumentParser(description="Convert real character photo to Minecraft render using Nano Banana Pro.")
71
  parser.add_argument("image", help="Path to local real character photo (Graph 1).")
72
  parser.add_argument("-t", "--template", default=DEFAULT_TEMPLATE_PATH, help="Path to reference template image (Graph 2).")
73
+ parser.add_argument("-t2", "--template2", default=None, help="Path to second reference template image (Graph 3).")
74
  parser.add_argument("-o", "--output", help="Output path for the generated image.")
75
  parser.add_argument("-p", "--prompt", default=DEFAULT_PROMPT, help="Prompt for image generation.")
76
  parser.add_argument("-a", "--aspect-ratio", default="1:1",
 
83
  output_file = real2render(
84
  image_path=args.image,
85
  template_path=args.template,
86
+ template2_path=args.template2,
87
  output_path=args.output,
88
  prompt=args.prompt,
89
  aspect_ratio=args.aspect_ratio,
DDJ_real2render/template/template14.png ADDED

Git LFS Details

  • SHA256: af44d3f99f07323aa627c4929d48099e79d0e50a26368967069ffdf5e37c1a28
  • Pointer size: 130 Bytes
  • Size of remote file: 37.6 kB
DDJ_real2render/template/template15.png ADDED

Git LFS Details

  • SHA256: be17c70d3b4db2392e3c7ee2c14cadae8fab687984d086466d1e3abfc1d590fc
  • Pointer size: 130 Bytes
  • Size of remote file: 24.4 kB
DDJ_real2render/test_batch.sh ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ template_x=${template_x:-template14}
2
+ template_y=${template_y:-template15}
3
+
4
+ for i in {15..17}; do
5
+ if [ -f "test_input/img${i}.png" ]; then
6
+ img_file="test_input/img${i}.png"
7
+ elif [ -f "test_input/img${i}.jpg" ]; then
8
+ img_file="test_input/img${i}.jpg"
9
+ else
10
+ echo "Warning: test_input/img${i} not found."
11
+ continue
12
+ fi
13
+
14
+ python real2render.py "$img_file" -t template/${template_x}.png -t2 template/${template_y}.png -o test_output/img${i}_${template_x}_${template_y}.png
15
+ done
DDJ_real2render/test_output/img10_template13.png ADDED

Git LFS Details

  • SHA256: 435ed472a2472c430c6433bf66088efcae1fa969af37aa313d92bd8db67d40dd
  • Pointer size: 132 Bytes
  • Size of remote file: 1.03 MB
DDJ_real2render/test_output/img11_template13.png ADDED

Git LFS Details

  • SHA256: 3ef89d2cec0958df254d8146fb56a80fbb643170f49afc95e91598f62fcf885f
  • Pointer size: 131 Bytes
  • Size of remote file: 993 kB
DDJ_real2render/test_output/img11_template14.png ADDED

Git LFS Details

  • SHA256: d59865ee2e61ba49e8369c2005fa6689dcc070a70f401308bb2b4fbe5c72427d
  • Pointer size: 132 Bytes
  • Size of remote file: 1.01 MB
DDJ_real2render/test_output/img12_template13.png ADDED

Git LFS Details

  • SHA256: 8281cbb7164f05ea678d424f5826959b4e4a9bc07b74cb52eaeb6a7a3030be1d
  • Pointer size: 131 Bytes
  • Size of remote file: 443 kB
DDJ_real2render/test_output/img12_template14.png ADDED

Git LFS Details

  • SHA256: 20f9908b55e5b9c9b663f37c6e50d8ff04a2b8f74c12bf5c83a1a62feba5a680
  • Pointer size: 132 Bytes
  • Size of remote file: 1.04 MB
DDJ_real2render/test_output/img13_template13.png ADDED

Git LFS Details

  • SHA256: 9a2a23311540864d874f686ba5b5914548924bd6029e26445db5c5a792887394
  • Pointer size: 131 Bytes
  • Size of remote file: 908 kB
DDJ_real2render/test_output/img13_template14.png ADDED

Git LFS Details

  • SHA256: b7d14571dadec621459476f7922cbad8b49e05f6a56f8cb04928f69623157f62
  • Pointer size: 132 Bytes
  • Size of remote file: 1.08 MB
DDJ_real2render/test_output/img14_template13.png ADDED

Git LFS Details

  • SHA256: d3b9e7025fbef3e8f3ca3a7cf4ab4880e3ae9e8d4bfac0dc14c32b220d858e00
  • Pointer size: 132 Bytes
  • Size of remote file: 1.01 MB
DDJ_real2render/test_output/img14_template14.png ADDED

Git LFS Details

  • SHA256: 3d1f3b09eb4c97a7e1e8f6be8ccb14bb5e9f43b1fb61a5d3adc7ab2bd83a59d8
  • Pointer size: 132 Bytes
  • Size of remote file: 1.01 MB
DDJ_real2render/test_output/img15_template13.png ADDED

Git LFS Details

  • SHA256: 6d87a44260fa56de176825764fd59789fd3687c81029ddee3afcd718583750ca
  • Pointer size: 131 Bytes
  • Size of remote file: 989 kB
DDJ_real2render/test_output/img15_template14.png ADDED

Git LFS Details

  • SHA256: 3296f22451db00f2fe38738a2c10c27eb724f05090ff89a8a6fa123c829891e3
  • Pointer size: 131 Bytes
  • Size of remote file: 993 kB
DDJ_real2render/test_output/img15_template14_template15.png ADDED

Git LFS Details

  • SHA256: 4fae30adb5787818fda70d0743c6867a4df874a688b8b07e0d43571fd0acf82b
  • Pointer size: 132 Bytes
  • Size of remote file: 1.02 MB
DDJ_real2render/test_output/img16_template13.png ADDED

Git LFS Details

  • SHA256: 69d433dcb8ded4b8ab46e6c318e4f379ed681715ef606f033bbcc9318d48e1fc
  • Pointer size: 131 Bytes
  • Size of remote file: 425 kB
DDJ_real2render/test_output/img16_template14.png ADDED

Git LFS Details

  • SHA256: 1ac389ed9a62b3885b6072e8dd8a05406de898cf5c698577b3da75dc92dbd787
  • Pointer size: 131 Bytes
  • Size of remote file: 944 kB
DDJ_real2render/test_output/img16_template14_template15.png ADDED

Git LFS Details

  • SHA256: d5e2621a8d373e3de6def85ace5a7366d441b38d2f70ce472ec866233a7a2c7e
  • Pointer size: 131 Bytes
  • Size of remote file: 964 kB
DDJ_real2render/test_output/img17_template13.png ADDED

Git LFS Details

  • SHA256: e479ada031ea0c041ddc79fca20833ef4c10ce9b6fa710aea2b974cc39a09d35
  • Pointer size: 131 Bytes
  • Size of remote file: 958 kB
DDJ_real2render/test_output/img17_template14.png ADDED

Git LFS Details

  • SHA256: 5e0fe4e5056e73291be82d16394d60891d94b9927c1d3fd46e6e8ffb3e89ab74
  • Pointer size: 131 Bytes
  • Size of remote file: 938 kB
DDJ_real2render/test_output/img17_template14_template15.png ADDED

Git LFS Details

  • SHA256: e896ab9f90a13019f6ee2aee7c490a30375a424661a0bc2d80848c5a144988d8
  • Pointer size: 131 Bytes
  • Size of remote file: 948 kB
DDJ_real2render/test_output/img2_template13.png ADDED

Git LFS Details

  • SHA256: 9c1ca4f026e4462ea7060fa3814a9b9a4bed4afab852fee7fb8186f62c3ca182
  • Pointer size: 131 Bytes
  • Size of remote file: 987 kB
DDJ_real2render/test_output/img3_template13.png ADDED

Git LFS Details

  • SHA256: 798c70d005f9f05ce389b6f655f6ae85e5e0f7806cf11be2592904721b7d6fad
  • Pointer size: 132 Bytes
  • Size of remote file: 1.13 MB
DDJ_real2render/test_output/img4_template13.png ADDED

Git LFS Details

  • SHA256: ffff956e5cf26cc246508d1948bbbb8a00a0d982e0dae9302668a5322edcda52
  • Pointer size: 132 Bytes
  • Size of remote file: 1.01 MB
DDJ_real2render/test_output/img6_template13_2.png ADDED

Git LFS Details

  • SHA256: de3de839c14af39b6b508b3e5fe1b806874e5d76800927cd4557207a62a59100
  • Pointer size: 132 Bytes
  • Size of remote file: 1 MB
DDJ_real2render/test_output/img7_template13.png ADDED

Git LFS Details

  • SHA256: 3fc2af6bf9b54c6401a012552475599692537d6ccf7a7d733bbb1665c93baad0
  • Pointer size: 132 Bytes
  • Size of remote file: 1.06 MB
DDJ_real2render/test_output/img8_template13.png ADDED

Git LFS Details

  • SHA256: 13d6c9556c3d7ff1f59a7d990355ad245cfe1ec7bd83027fc6800a4b45c85891
  • Pointer size: 132 Bytes
  • Size of remote file: 1.09 MB
DDJ_real2render/test_output/img9_template13.png ADDED

Git LFS Details

  • SHA256: 85dc110fa2ac130d3b71637b6035c249d08ee76c6dd521295e1a229e58ba2def
  • Pointer size: 131 Bytes
  • Size of remote file: 374 kB