Spaces:
Running
on
Zero
Running
on
Zero
Match API texture generation settings to Gradio app for better quality
Browse files- Use same high-quality settings as Gradio app: 8 views, 768 resolution
- Reduce GPU duration to 180s to match successful Gradio approach
- Improve fallback settings to medium quality (4 views, 384 resolution)
- Remove adaptive settings that were limiting quality
- API should now produce same quality as Gradio upload feature
- gradio_app.py +8 -20
gradio_app.py
CHANGED
@@ -645,29 +645,17 @@ def generation_all(
|
|
645 |
)
|
646 |
|
647 |
|
648 |
-
@spaces.GPU(duration=
|
649 |
def generate_texture_lazy_adaptive(mesh_path, image_path, output_mesh_path, num_available_images=1):
|
650 |
"""Generate texture for a mesh with adaptive settings based on available images."""
|
651 |
try:
|
652 |
# Lazy initialization of texture pipeline inside GPU function
|
653 |
from hy3dpaint.textureGenPipeline import Hunyuan3DPaintPipeline, Hunyuan3DPaintConfig
|
654 |
|
655 |
-
#
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
resolution = 384
|
660 |
-
logger.info(f"Using high quality settings: {max_views} views, {resolution} resolution")
|
661 |
-
elif num_available_images >= 2:
|
662 |
-
# Some views available - medium quality
|
663 |
-
max_views = 2
|
664 |
-
resolution = 256
|
665 |
-
logger.info(f"Using medium quality settings: {max_views} views, {resolution} resolution")
|
666 |
-
else:
|
667 |
-
# Single image - use fast settings
|
668 |
-
max_views = 1
|
669 |
-
resolution = 128
|
670 |
-
logger.info(f"Using fast settings: {max_views} views, {resolution} resolution")
|
671 |
|
672 |
conf = Hunyuan3DPaintConfig(max_num_view=max_views, resolution=resolution)
|
673 |
conf.realesrgan_ckpt_path = "hy3dpaint/ckpt/RealESRGAN_x4plus.pth"
|
@@ -688,10 +676,10 @@ def generate_texture_lazy_adaptive(mesh_path, image_path, output_mesh_path, num_
|
|
688 |
return textured_mesh_path
|
689 |
except Exception as texture_error:
|
690 |
logger.error(f"Texture generation pipeline failed: {texture_error}")
|
691 |
-
# Try with
|
692 |
try:
|
693 |
-
fallback_views =
|
694 |
-
fallback_resolution =
|
695 |
logger.info(f"Trying fallback settings: {fallback_views} views, {fallback_resolution} resolution")
|
696 |
|
697 |
conf = Hunyuan3DPaintConfig(max_num_view=fallback_views, resolution=fallback_resolution)
|
|
|
645 |
)
|
646 |
|
647 |
|
648 |
+
@spaces.GPU(duration=180)
|
649 |
def generate_texture_lazy_adaptive(mesh_path, image_path, output_mesh_path, num_available_images=1):
|
650 |
"""Generate texture for a mesh with adaptive settings based on available images."""
|
651 |
try:
|
652 |
# Lazy initialization of texture pipeline inside GPU function
|
653 |
from hy3dpaint.textureGenPipeline import Hunyuan3DPaintPipeline, Hunyuan3DPaintConfig
|
654 |
|
655 |
+
# Use the same high-quality settings as the Gradio app
|
656 |
+
max_views = 8
|
657 |
+
resolution = 768
|
658 |
+
logger.info(f"Using high quality settings: {max_views} views, {resolution} resolution (same as Gradio app)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
659 |
|
660 |
conf = Hunyuan3DPaintConfig(max_num_view=max_views, resolution=resolution)
|
661 |
conf.realesrgan_ckpt_path = "hy3dpaint/ckpt/RealESRGAN_x4plus.pth"
|
|
|
676 |
return textured_mesh_path
|
677 |
except Exception as texture_error:
|
678 |
logger.error(f"Texture generation pipeline failed: {texture_error}")
|
679 |
+
# Try with medium quality settings as fallback
|
680 |
try:
|
681 |
+
fallback_views = 4
|
682 |
+
fallback_resolution = 384
|
683 |
logger.info(f"Trying fallback settings: {fallback_views} views, {fallback_resolution} resolution")
|
684 |
|
685 |
conf = Hunyuan3DPaintConfig(max_num_view=fallback_views, resolution=fallback_resolution)
|