- Implemented a preview tool for rectifying images with interactive aspect controls in `preview.py`. - Added tests for depth metadata loading to ensure consistent schema usage in `test_depth_metadata.py`. - Developed comprehensive tests for cutout calibration processes in `test_cutout_calibration.py`, including stability checks and depth calibration. - Created tests for frame compositing operations in `test_frame_compositing.py`, ensuring correct handling of depth and transparency. - Introduced material slot inheritance functionality in `material_slots.py` to manage geometry material assignments. - Built shared shader nodes for material processing in `shader.py`, including roughness and bump mapping setups.
57 lines
1.4 KiB
Python
57 lines
1.4 KiB
Python
from tests.support.paths import PROJECT_ROOT
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def load_server_module(name):
|
|
addon_directory = PROJECT_ROOT / "src" / "anyimage"
|
|
sys.path.insert(0, str(addon_directory))
|
|
try:
|
|
return __import__(f"server.{name}", fromlist=[name])
|
|
finally:
|
|
sys.path.remove(str(addon_directory))
|
|
|
|
|
|
class FakeModels:
|
|
def __init__(self, directory="BEN2-ONNX"):
|
|
self.model_directory = Path(directory)
|
|
|
|
def directory(self, _model):
|
|
return self.model_directory
|
|
|
|
def get_background(self, _model_directory, _device):
|
|
from server.models.onnx_ben2 import create_session
|
|
|
|
return create_session(self.model_directory, "cpu"), 0.0
|
|
|
|
|
|
def get_upscale(self, _model_directory, _device):
|
|
return object()
|
|
|
|
|
|
class FakeJobContext:
|
|
def __init__(self, directory, job_type, models=None):
|
|
self.directory = Path(directory)
|
|
self.job_type = job_type
|
|
self.models = models or FakeModels()
|
|
self.status = {}
|
|
self.logs = []
|
|
|
|
def resource(self, name):
|
|
if name != "model_manager":
|
|
raise KeyError(name)
|
|
return self.models
|
|
|
|
def progress(self, progress, message, **details):
|
|
self.status = {
|
|
"progress": progress,
|
|
"message": message,
|
|
**details,
|
|
}
|
|
|
|
def log(self, message, *, level="INFO"):
|
|
self.logs.append((level, message))
|
|
|
|
def check_cancelled(self):
|
|
return None
|