- Implemented the Image Perspective tool for editing image corners in Blender. - Created a new operator `EditImagePerspective` to handle the perspective transformation. - Added a preview feature for the perspective adjustment. - Introduced the `ImagePolylineTool` for editing image masks with polylines. - Developed backend support for Real-ESRGAN model inference, including ONNX integration. - Added functionality for image masking and background removal. - Created unit tests for the Real-ESRGAN ONNX model to ensure correct preprocessing and inference.
90 lines
3.0 KiB
Python
90 lines
3.0 KiB
Python
import bpy
|
|
|
|
from .runtime import DEFAULT_STORAGE_ROOT, runtime
|
|
from .properties import (
|
|
ai_setup_label,
|
|
ai_status,
|
|
device_enum_items,
|
|
model_catalog,
|
|
)
|
|
|
|
|
|
class AnyImagePreferences(bpy.types.AddonPreferences):
|
|
bl_idname = __package__
|
|
|
|
storage_root: bpy.props.StringProperty(
|
|
name="Storage Root",
|
|
description=(
|
|
"Shared user-writable storage for the environment, models and jobs; "
|
|
"all Blender versions can use the same directory"
|
|
),
|
|
subtype="DIR_PATH",
|
|
default=str(DEFAULT_STORAGE_ROOT),
|
|
)
|
|
device: bpy.props.EnumProperty(
|
|
name="Device",
|
|
description=(
|
|
"Inference device used by production tasks; only devices supported "
|
|
"on this machine are listed"
|
|
),
|
|
items=device_enum_items,
|
|
default=0,
|
|
)
|
|
|
|
def draw(self, _context):
|
|
layout = self.layout
|
|
layout.prop(self, "storage_root")
|
|
layout.prop(self, "device")
|
|
layout.separator()
|
|
status = ai_status()
|
|
layout.label(text=f"Environment: {runtime.environment_directory()}")
|
|
if not status["environment_ready"]:
|
|
layout.label(text="Environment is not installed", icon="ERROR")
|
|
setup_row = layout.row()
|
|
setup_row.enabled = not runtime.server_busy()
|
|
setup_row.operator(
|
|
"anyimage.setup_ai_environment",
|
|
text=ai_setup_label(status),
|
|
icon="IMPORT",
|
|
)
|
|
else:
|
|
layout.label(text="Environment is installed", icon="CHECKMARK")
|
|
if not status["ready"]:
|
|
required_row = layout.row()
|
|
required_row.enabled = not runtime.server_busy()
|
|
required_row.operator(
|
|
"anyimage.setup_ai_environment",
|
|
text=ai_setup_label(status),
|
|
icon="IMPORT",
|
|
)
|
|
layout.separator(type="LINE")
|
|
layout.label(text="Models")
|
|
models = model_catalog()
|
|
for family in ("moge2", "da3", "ben2", "upscale"):
|
|
for model in models:
|
|
if model.get("family") == family and (
|
|
family != "da3" or model.get("enabled")
|
|
):
|
|
self._draw_model(layout, model)
|
|
layout.separator()
|
|
layout.operator(
|
|
"anyimage.open_server_log",
|
|
text="Open Server Log",
|
|
icon="TEXT",
|
|
)
|
|
|
|
def _draw_model(self, layout, model):
|
|
row = layout.row(align=True)
|
|
row.label(text=model["label"])
|
|
if model.get("ready"):
|
|
row.label(text="Ready", icon="CHECKMARK")
|
|
return
|
|
download_row = row.row(align=True)
|
|
download_row.enabled = not runtime.server_busy()
|
|
operator = download_row.operator(
|
|
"anyimage.download_model",
|
|
text="Download",
|
|
icon="IMPORT",
|
|
)
|
|
operator.model = model["key"]
|