Datasets:
EntropyDrop commited on
Commit ·
2d86a45
1
Parent(s): bf40649
update
Browse files- DDJ_real2render/real2render.py +16 -3
- DDJ_real2render/template/template14.png +3 -0
- DDJ_real2render/template/template15.png +3 -0
- DDJ_real2render/test_batch.sh +15 -0
- DDJ_real2render/test_output/img10_template13.png +3 -0
- DDJ_real2render/test_output/img11_template13.png +3 -0
- DDJ_real2render/test_output/img11_template14.png +3 -0
- DDJ_real2render/test_output/img12_template13.png +3 -0
- DDJ_real2render/test_output/img12_template14.png +3 -0
- DDJ_real2render/test_output/img13_template13.png +3 -0
- DDJ_real2render/test_output/img13_template14.png +3 -0
- DDJ_real2render/test_output/img14_template13.png +3 -0
- DDJ_real2render/test_output/img14_template14.png +3 -0
- DDJ_real2render/test_output/img15_template13.png +3 -0
- DDJ_real2render/test_output/img15_template14.png +3 -0
- DDJ_real2render/test_output/img15_template14_template15.png +3 -0
- DDJ_real2render/test_output/img16_template13.png +3 -0
- DDJ_real2render/test_output/img16_template14.png +3 -0
- DDJ_real2render/test_output/img16_template14_template15.png +3 -0
- DDJ_real2render/test_output/img17_template13.png +3 -0
- DDJ_real2render/test_output/img17_template14.png +3 -0
- DDJ_real2render/test_output/img17_template14_template15.png +3 -0
- DDJ_real2render/test_output/img2_template13.png +3 -0
- DDJ_real2render/test_output/img3_template13.png +3 -0
- DDJ_real2render/test_output/img4_template13.png +3 -0
- DDJ_real2render/test_output/img6_template13_2.png +3 -0
- DDJ_real2render/test_output/img7_template13.png +3 -0
- DDJ_real2render/test_output/img8_template13.png +3 -0
- 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=
|
| 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
|
DDJ_real2render/template/template15.png
ADDED
|
Git LFS Details
|
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
|
DDJ_real2render/test_output/img11_template13.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img11_template14.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img12_template13.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img12_template14.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img13_template13.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img13_template14.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img14_template13.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img14_template14.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img15_template13.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img15_template14.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img15_template14_template15.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img16_template13.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img16_template14.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img16_template14_template15.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img17_template13.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img17_template14.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img17_template14_template15.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img2_template13.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img3_template13.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img4_template13.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img6_template13_2.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img7_template13.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img8_template13.png
ADDED
|
Git LFS Details
|
DDJ_real2render/test_output/img9_template13.png
ADDED
|
Git LFS Details
|