feat(cutout_tool): Implement cutout region to shape functionality
- Added interaction helpers for cutout region validation and shape menu interaction. - Created main operator for converting image regions into cutout shapes, including AI artifact generation. - Introduced object creation logic for cutout shapes, handling depth and normal textures. - Defined cutout shape identifiers and node groups for various shape types. - Implemented depth texture writing and prediction artifact generation for MoGe-2. - Developed server jobs for generating cutout artifacts, depth planes, and refining image regions. - Added region refinement logic to enhance gesture masks using BEN2.
This commit is contained in:
@@ -6,7 +6,6 @@ from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
from zipfile import ZipFile
|
||||
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
@@ -40,24 +39,17 @@ class PackTest(unittest.TestCase):
|
||||
pack.DIST_DIR = original_dist
|
||||
|
||||
version = tomllib.loads(
|
||||
(pack.SOURCE_DIR / "blender_manifest.toml").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
(pack.SOURCE_DIR / "blender_manifest.toml").read_text(encoding="utf-8")
|
||||
)["version"]
|
||||
self.assertEqual(
|
||||
{path.name for path in output_paths},
|
||||
{
|
||||
f"AnyImage.v{version}.{platform}.zip"
|
||||
for platform in pack.PLATFORMS
|
||||
},
|
||||
{f"AnyImage.v{version}.{platform}.zip" for platform in pack.PLATFORMS},
|
||||
)
|
||||
for output_path in output_paths:
|
||||
platform = output_path.stem.split(".")[-1]
|
||||
with ZipFile(output_path) as archive:
|
||||
names = set(archive.namelist())
|
||||
manifest = archive.read("blender_manifest.toml").decode(
|
||||
"utf-8"
|
||||
)
|
||||
manifest = archive.read("blender_manifest.toml").decode("utf-8")
|
||||
|
||||
self.assertIn("__init__.py", names)
|
||||
self.assertIn("operators/clipboard_image/__init__.py", names)
|
||||
@@ -72,18 +64,14 @@ class PackTest(unittest.TestCase):
|
||||
"operators/common/image_interaction.py",
|
||||
"operators/common/image_region.py",
|
||||
"operators/common/mesh_result.py",
|
||||
"operators/convert_to_plane/normal_map.py",
|
||||
"operators/convert_to_plane/resolution.py",
|
||||
"operators/cutout_tool/__init__.py",
|
||||
"operators/cutout_tool/select_region.py",
|
||||
"operators/cutout_tool/region_to_shape.py",
|
||||
"operators/cutout_tool/geometry/__init__.py",
|
||||
"operators/cutout_tool/geometry/balloon.py",
|
||||
"operators/cutout_tool/geometry/depth_calibration.py",
|
||||
"operators/cutout_tool/geometry/region_contours.py",
|
||||
"operators/cutout_tool/geometry/triangulation.py",
|
||||
"operators/cutout_tool/main.py",
|
||||
"operators/cutout_tool/interaction.py",
|
||||
"operators/cutout_tool/geometry.py",
|
||||
"operators/cutout_tool/object.py",
|
||||
"operators/cutout_tool/shape.py",
|
||||
"operators/convert_to_plane/__init__.py",
|
||||
"operators/convert_to_plane/build.py",
|
||||
"operators/convert_to_plane/object.py",
|
||||
"operators/convert_to_plane/conversion.py",
|
||||
"operators/convert_to_plane/mesh_plane.py",
|
||||
"operators/convert_to_plane/nodes.py",
|
||||
@@ -109,15 +97,20 @@ class PackTest(unittest.TestCase):
|
||||
names,
|
||||
)
|
||||
self.assertIn("server/media/input.py", names)
|
||||
self.assertIn("operators/common/depth_data.py", names)
|
||||
self.assertIn("server/geometry/projection.py", names)
|
||||
self.assertIn("server/models/geometry.py", names)
|
||||
self.assertIn("server/jobs/remove_background.py", names)
|
||||
self.assertIn("server/jobs/refine_image_mask.py", names)
|
||||
self.assertIn("server/region/generate_selection.py", names)
|
||||
self.assertIn("server/jobs/generate_region_data.py", names)
|
||||
self.assertIn("server/jobs/generate_depth_plane.py", names)
|
||||
self.assertIn("server/geometry/generate_depth.py", names)
|
||||
self.assertIn("server/jobs/refine_image_region.py", names)
|
||||
self.assertIn("server/region/refine_region.py", names)
|
||||
self.assertIn("server/jobs/cutout.py", names)
|
||||
self.assertIn("server/jobs/depth_plane.py", names)
|
||||
self.assertIn("server/geometry/depth_texture.py", names)
|
||||
self.assertIn("server/geometry/prediction_artifacts.py", names)
|
||||
self.assertIn("server/geometry/normal_texture.py", names)
|
||||
self.assertNotIn(
|
||||
"server/geometry/generate_geometry_and_normal.py", names
|
||||
)
|
||||
self.assertNotIn("operators/common/image_selection.py", names)
|
||||
self.assertNotIn("server/selection/cutout_images.py", names)
|
||||
self.assertNotIn("server/selection/polygon_mask.py", names)
|
||||
@@ -139,21 +132,13 @@ class PackTest(unittest.TestCase):
|
||||
"wheels/blendjob-0.1.14-py3-none-any.whl",
|
||||
names,
|
||||
)
|
||||
self.assertFalse(
|
||||
any(name.startswith("blendjob/") for name in names)
|
||||
)
|
||||
self.assertFalse(any(name.startswith("blendjob/") for name in names))
|
||||
self.assertNotIn("anyimage/__init__.py", names)
|
||||
self.assertFalse(
|
||||
any(name.startswith("sources/") for name in names)
|
||||
)
|
||||
self.assertFalse(
|
||||
any(name.startswith("vendor/") for name in names)
|
||||
)
|
||||
self.assertFalse(any(name.startswith("sources/") for name in names))
|
||||
self.assertFalse(any(name.startswith("vendor/") for name in names))
|
||||
self.assertIn(f'platforms = ["{platform}"]', manifest)
|
||||
self.assertNotIn(
|
||||
"windows-x64"
|
||||
if platform != "windows-x64"
|
||||
else "macos-arm64",
|
||||
"windows-x64" if platform != "windows-x64" else "macos-arm64",
|
||||
manifest.split("platforms =", 1)[-1],
|
||||
)
|
||||
|
||||
@@ -168,9 +153,7 @@ class PackTest(unittest.TestCase):
|
||||
|
||||
def fake_run(command, check):
|
||||
self.assertTrue(check)
|
||||
(destination / "blendjob-0.1.14-py3-none-any.whl").write_bytes(
|
||||
b"wheel"
|
||||
)
|
||||
(destination / "blendjob-0.1.14-py3-none-any.whl").write_bytes(b"wheel")
|
||||
|
||||
with patch.object(pack.subprocess, "run", side_effect=fake_run) as run:
|
||||
wheels = pack.download_wheels("linux-x64", destination)
|
||||
@@ -185,6 +168,7 @@ class PackTest(unittest.TestCase):
|
||||
[wheel.name for wheel in wheels],
|
||||
["blendjob-0.1.14-py3-none-any.whl"],
|
||||
)
|
||||
|
||||
def test_rejects_unknown_platform(self):
|
||||
pack = load_pack()
|
||||
with self.assertRaisesRegex(ValueError, "Unsupported platform"):
|
||||
@@ -193,9 +177,7 @@ class PackTest(unittest.TestCase):
|
||||
def test_platforms_match_manifest(self):
|
||||
pack = load_pack()
|
||||
manifest = tomllib.loads(
|
||||
(pack.SOURCE_DIR / "blender_manifest.toml").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
(pack.SOURCE_DIR / "blender_manifest.toml").read_text(encoding="utf-8")
|
||||
)
|
||||
self.assertEqual(set(pack.PLATFORMS), set(manifest["platforms"]))
|
||||
self.assertEqual(
|
||||
@@ -203,5 +185,6 @@ class PackTest(unittest.TestCase):
|
||||
{"windows-x64", "macos-arm64", "linux-x64"},
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user