Spaces:
Running on Zero
Running on Zero
Download export_profiles.py from broyang/3dai: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/spaces/broyang/3dai/resolve/main/export_profiles.py
- Command line
-
hf download hf://spaces/broyang/3dai/export_profiles.py
-
curl -L -o export_profiles.py https://huggingface.co/spaces/broyang/3dai/resolve/main/export_profiles.py
1.41 kB
| TEXTURE_REFERENCE_SIZE = 2048 | |
| REFERENCE_FACE_BUDGET = 100000 | |
| MAX_FACE_BUDGET = 200000 | |
| REFERENCE_TEXTURE_STEPS = 1000 | |
| MAX_TEXTURE_STEPS = 1000 | |
| TEXTURE_INIT = "zeros" | |
| TEXTURE_LEARNING_RATE = 1e-2 | |
| MAX_SIMPLIFY_RATIO = 0.999 | |
| BAKE_RENDER_VIEWS = 100 | |
| def texture_scale(texture_size): | |
| return texture_size / TEXTURE_REFERENCE_SIZE | |
| def faces_for_texture_size(texture_size): | |
| budget = REFERENCE_FACE_BUDGET * texture_scale(texture_size) ** 2 | |
| return int(round(min(budget, MAX_FACE_BUDGET))) | |
| def texture_steps_for_texture_size(texture_size): | |
| steps = REFERENCE_TEXTURE_STEPS * texture_scale(texture_size) | |
| return max(1, int(round(min(steps, MAX_TEXTURE_STEPS)))) | |
| def simplify_ratio_for_texture_size(texture_size, source_faces): | |
| target_faces = faces_for_texture_size(texture_size) | |
| if source_faces <= target_faces: | |
| return 0.0 | |
| return min(MAX_SIMPLIFY_RATIO, 1.0 - target_faces / source_faces) | |
| def balanced_export_settings(simplify, texture_size): | |
| return { | |
| "simplify": simplify, | |
| "texture_size": texture_size, | |
| "fill_holes": True, | |
| "fill_holes_num_views": 250, | |
| "render_views": BAKE_RENDER_VIEWS, | |
| "texture_optimization_steps": texture_steps_for_texture_size(texture_size), | |
| "texture_init": TEXTURE_INIT, | |
| "texture_lr": TEXTURE_LEARNING_RATE, | |
| "uv_backend": "cumesh", | |
| "decimate_backend": "cumesh", | |
| } | |