Spaces:
Running on Zero
Running on Zero
Download tests/test_export_profiles.py from broyang/3dai: direct link, hf CLI and curl.
- Browser
- Download file 1.9 kB
-
https://huggingface.co/spaces/broyang/3dai/resolve/main/tests/test_export_profiles.py
- Command line
-
hf download hf://spaces/broyang/3dai/tests/test_export_profiles.py
-
curl -L -o test_export_profiles.py https://huggingface.co/spaces/broyang/3dai/resolve/main/tests/test_export_profiles.py
1.9 kB
| import sys | |
| import unittest | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent.parent | |
| sys.path.insert(0, str(ROOT)) | |
| from export_profiles import ( # noqa: E402 | |
| balanced_export_settings, | |
| faces_for_texture_size, | |
| simplify_ratio_for_texture_size, | |
| texture_steps_for_texture_size, | |
| ) | |
| class TextureQualityBudget(unittest.TestCase): | |
| def test_face_budget_scales_with_texture_area_and_caps_at_200k(self): | |
| self.assertEqual( | |
| [faces_for_texture_size(size) for size in (512, 1024, 1536, 2048, 4096)], | |
| [6250, 25000, 56250, 100000, 200000], | |
| ) | |
| def test_optimization_steps_scale_with_texture_size_and_cap_at_1000(self): | |
| self.assertEqual( | |
| [texture_steps_for_texture_size(size) for size in (512, 1024, 1536, 2048, 4096)], | |
| [250, 500, 750, 1000, 1000], | |
| ) | |
| def test_simplify_ratio_reaches_the_budget_without_over_decimating(self): | |
| self.assertAlmostEqual(simplify_ratio_for_texture_size(2048, 400000), 0.75) | |
| self.assertAlmostEqual(simplify_ratio_for_texture_size(4096, 400000), 0.5) | |
| self.assertEqual(simplify_ratio_for_texture_size(2048, 50000), 0.0) | |
| self.assertEqual(simplify_ratio_for_texture_size(512, 10000000), 0.999) | |
| def test_balanced_settings_carry_the_derived_steps(self): | |
| settings = balanced_export_settings(0.5, 4096) | |
| self.assertEqual(settings["texture_optimization_steps"], 1000) | |
| self.assertEqual(settings["texture_init"], "zeros") | |
| self.assertEqual(settings["texture_lr"], 1e-2) | |
| self.assertEqual(settings["texture_size"], 4096) | |
| self.assertEqual(settings["simplify"], 0.5) | |
| self.assertEqual(settings["uv_backend"], "cumesh") | |
| self.assertEqual(settings["render_views"], 100) | |
| self.assertEqual(settings["decimate_backend"], "cumesh") | |
| if __name__ == "__main__": | |
| unittest.main() | |