- Introduced BEN2 model for background removal in the panel and properties. - Updated runtime to handle background removal commands and model downloads. - Implemented background removal logic in worker, including image processing and saving results. - Enhanced tests to cover new background removal features and ensure proper integration. - Updated version to 0.9.28 to reflect new features and improvements.
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
import importlib.util
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def load_module(name, relative_path):
|
|
specification = importlib.util.spec_from_file_location(
|
|
name,
|
|
PROJECT_ROOT / relative_path,
|
|
)
|
|
module = importlib.util.module_from_spec(specification)
|
|
specification.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
class ModelTest(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.models = load_module(
|
|
"snapform_models",
|
|
"src/snapform/models.py",
|
|
)
|
|
|
|
def test_base_model_is_default_friendly_apache_model(self):
|
|
model = self.models.get_model("BASE")
|
|
|
|
self.assertEqual(model.repository, "depth-anything/DA3-BASE")
|
|
self.assertEqual(model.license_name, "Apache 2.0")
|
|
|
|
def test_large_model_exposes_noncommercial_license(self):
|
|
model = self.models.get_model("LARGE_1_1")
|
|
|
|
self.assertEqual(model.license_name, "CC BY-NC 4.0")
|
|
|
|
def test_giant_models_expose_gaussian_head(self):
|
|
for model_key in ("GIANT_1_1", "NESTED_GIANT_LARGE_1_1"):
|
|
with self.subTest(model_key=model_key):
|
|
self.assertTrue(self.models.get_model(model_key).supports_gs)
|
|
|
|
def test_unknown_model_is_rejected(self):
|
|
with self.assertRaisesRegex(ValueError, "Unknown DA3 model"):
|
|
self.models.get_model("UNKNOWN")
|
|
|
|
def test_ben2_download_only_includes_required_hugging_face_files(self):
|
|
model = self.models.get_downloadable_model("BEN2_BASE")
|
|
|
|
self.assertEqual(model.repository, "PramaLLC/BEN2")
|
|
self.assertEqual(model.license_name, "MIT")
|
|
self.assertEqual(
|
|
model.download_patterns,
|
|
("config.json", "model.safetensors"),
|
|
)
|
|
self.assertNotIn("BEN2_BASE", self.models.MODELS)
|