EntropyDrop commited on
Commit
64c7374
·
1 Parent(s): db3126e
DDJ_real2render/create_template.py CHANGED
@@ -5,7 +5,7 @@ import argparse
5
  from PIL import Image
6
  import numpy as np
7
 
8
- VIEW_NAMES = ("front_left", "front_right", "back_left", "back_right")
9
 
10
 
11
  def resolve_renderer_path(renderer_path):
 
5
  from PIL import Image
6
  import numpy as np
7
 
8
+ VIEW_NAMES = ("front_left", "back_left", "front_right", "back_right")
9
 
10
 
11
  def resolve_renderer_path(renderer_path):
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的玩家模型相同,且为包含内层/外层贴图的双图层模型,不能有额外元素。texture不能高于Minecraft所支持的分辨率。模型参考[图2]
16
 
17
  - 生成的minecraft角色的尺寸、朝向、姿势与[图2]完全一致,且必须包含正面图与背面图,并排放置。
18
 
@@ -20,13 +20,23 @@ DEFAULT_PROMPT = """生成[图1]中角色的Minecraft形象
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").
@@ -43,6 +53,10 @@ def real2render(image_path, template_path=None, template2_path=None, output_path
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
 
@@ -50,12 +64,16 @@ def real2render(image_path, template_path=None, template2_path=None, output_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,
@@ -71,6 +89,7 @@ def main():
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="16:9",
@@ -84,6 +103,7 @@ def main():
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,
 
12
  # Default prompt for real-to-render Minecraft character generation
13
  DEFAULT_PROMPT = """生成[图1]中角色的Minecraft形象
14
 
15
+ - 人物模型必须与minecraft的玩家模型相同,且为包含内层/外层贴图的双图层模型,不能有额外元素。texture不能高于Minecraft所支持的分辨率/网格,按照前左、后左,前右、后右的横向排序渲染;内层网格模型参考[图2],外层网格模型参考[图3],实际例子参考[图4]
16
 
17
  - 生成的minecraft角色的尺寸、朝向、姿势与[图2]完全一致,且必须包含正面图与背面图,并排放置。
18
 
 
20
 
21
  - 在上述约束下,尽可能完美、准确的还原[图1]中的角色,包括外貌特征、全身所有服装、各种饰品等(不包括手持物品)"""
22
 
23
+ def real2render(
24
+ image_path,
25
+ template_path=None,
26
+ template2_path=None,
27
+ output_path=None,
28
+ prompt=None,
29
+ aspect_ratio="1:1",
30
+ image_size="1K",
31
+ template3_path=None,
32
+ ):
33
  """
34
  High-level API to generate a Minecraft 3D character render from a real character photo using Nano Banana Pro.
35
 
36
  :param image_path: Path to the real character input image (Graph 1).
37
  :param template_path: Path to the template reference image (Graph 2, defaults to inverse_uv/template.png).
38
  :param template2_path: Path to the second template reference image (Graph 3, defaults to None).
39
+ :param template3_path: Path to the third template reference image (Graph 4, defaults to None).
40
  :param output_path: Output PNG path.
41
  :param prompt: Custom prompt text (defaults to standard Minecraft real-to-render prompt).
42
  :param aspect_ratio: Image aspect ratio (default: "1:1").
 
53
  template2_file = template2_path
54
  if template2_file and not os.path.exists(template2_file):
55
  raise FileNotFoundError(f"Template 2 image '{template2_file}' does not exist.")
56
+
57
+ template3_file = template3_path
58
+ if template3_file and not os.path.exists(template3_file):
59
+ raise FileNotFoundError(f"Template 3 image '{template3_file}' does not exist.")
60
 
61
  prompt_text = prompt or DEFAULT_PROMPT
62
 
 
64
  print(f"[*] Template Image (Graph 2): {template_file}")
65
  if template2_file:
66
  print(f"[*] Template 2 Image (Graph 3): {template2_file}")
67
+ if template3_file:
68
+ print(f"[*] Template 3 Image (Graph 4): {template3_file}")
69
  print(f"[*] Image Size: {image_size}, Aspect Ratio: {aspect_ratio}")
70
  print(f"[*] Prompt:\n{prompt_text}\n")
71
 
72
  local_image_paths = [image_path, template_file]
73
  if template2_file:
74
  local_image_paths.append(template2_file)
75
+ if template3_file:
76
+ local_image_paths.append(template3_file)
77
 
78
  output_file = banana_pro_image.generate_img2img(
79
  local_image_paths=local_image_paths,
 
89
  parser.add_argument("image", help="Path to local real character photo (Graph 1).")
90
  parser.add_argument("-t", "--template", default=DEFAULT_TEMPLATE_PATH, help="Path to reference template image (Graph 2).")
91
  parser.add_argument("-t2", "--template2", default=None, help="Path to second reference template image (Graph 3).")
92
+ parser.add_argument("-t3", "--template3", default=None, help="Path to third reference template image (Graph 4).")
93
  parser.add_argument("-o", "--output", help="Output path for the generated image.")
94
  parser.add_argument("-p", "--prompt", default=DEFAULT_PROMPT, help="Prompt for image generation.")
95
  parser.add_argument("-a", "--aspect-ratio", default="16:9",
 
103
  image_path=args.image,
104
  template_path=args.template,
105
  template2_path=args.template2,
106
+ template3_path=args.template3,
107
  output_path=args.output,
108
  prompt=args.prompt,
109
  aspect_ratio=args.aspect_ratio,
DDJ_real2render/template/template19.png ADDED

Git LFS Details

  • SHA256: f912127074591a953e2e60dda583789914a7a96a0beff84b03ded3cc245d1fd5
  • Pointer size: 130 Bytes
  • Size of remote file: 48.9 kB
DDJ_real2render/template/template20.png ADDED

Git LFS Details

  • SHA256: 66e0871ea943354bcee77a08f9aaca9d57b0dd9706b01a412603c604c31b8f8b
  • Pointer size: 130 Bytes
  • Size of remote file: 48.9 kB
DDJ_real2render/test_output/img6_template18_2.png ADDED

Git LFS Details

  • SHA256: ba98d804c18f97a048dbc3b1243a62a14cb10b5c7423af6bb276f53b12d87229
  • Pointer size: 132 Bytes
  • Size of remote file: 4.46 MB
DDJ_real2render/test_output/img6_template19.png ADDED

Git LFS Details

  • SHA256: 5a899aa4d332503d58e3d73de801daa84cec533e22af1667f723e9d8efc3056b
  • Pointer size: 132 Bytes
  • Size of remote file: 3.99 MB
DDJ_real2render/test_output/img6_template20.png ADDED

Git LFS Details

  • SHA256: 62467f41de2d81ed5b229200440c9fc0ad8601cdd5115879d4ee6b739372572c
  • Pointer size: 132 Bytes
  • Size of remote file: 1.48 MB