Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added warnings to for nodes with limited color depth #2090

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions backend/src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,21 @@ def register(
decorators: List[Callable] | None = None,
see_also: List[str] | str | None = None,
features: List[FeatureId] | FeatureId | None = None,
limited_to_8bpc: bool | str = False,
):
if not isinstance(description, str):
description = "\n\n".join(description)

if limited_to_8bpc:
description += "\n\n#### Limited color depth\n\n"
if isinstance(limited_to_8bpc, str):
description += f" {limited_to_8bpc}"
else:
description += (
"This node will internally convert input images to 8 bits/channel."
" This is generally only a problem if you intend to save the output with 16 bits/channel or higher."
)

def to_list(x: List[S] | S | None) -> List[S]:
if x is None:
return []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def nearest_valid(n: number) = floor(n / 8) * 8;
],
decorators=[cached],
features=web_ui,
limited_to_8bpc=True,
)
def image_to_image_node(
image: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def nearest_valid(n: number) = floor(n / 8) * 8;
],
decorators=[cached],
features=web_ui,
limited_to_8bpc=True,
)
def inpaint_node(
image: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def nearest_valid(n: number) = ceil(n / 64) * 64;
],
decorators=[cached],
features=web_ui,
limited_to_8bpc=True,
)
def outpaint_node(
image: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def nearest_valid(n: number) = max(1, floor(n));
],
decorators=[cached],
features=web_ui,
limited_to_8bpc=True,
)
def upscale_node(
image: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def estimate_cpu():
outputs=[
ImageOutput(image_type="""convenientUpscale(Input0, Input1)"""),
],
limited_to_8bpc=True,
)
def upscale_image_node(
img: np.ndarray, model: NcnnModelWrapper, tile_size: TileSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
),
ImageOutput("Mask", image_type=navi.Image(size_as="Input0"), channels=1),
],
limited_to_8bpc=True,
)
def remove_background_node(
img: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def upscale(
channels=3,
)
],
limited_to_8bpc=True,
)
def upscale_face_node(
img: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def iterator_helper_write_output_frame_node(
},
],
side_effects=True,
limited_to_8bpc="The video will be read and written as 8-bit RGB.",
)
async def video_frame_iterator_node(path: str, context: IteratorContext) -> None:
logger.debug(f"{ffmpeg_path=}, {ffprobe_path=}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class TiffColorDepth(Enum):
],
outputs=[],
side_effects=True,
limited_to_8bpc="Image will be saved with 8 bits/channel by default. Some formats support higher bit depths.",
)
def save_image_node(
img: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
inputs=[ImageInput()],
outputs=[],
side_effects=True,
limited_to_8bpc="The temporary file is an 8-bit PNG.",
)
def view_image_external_node(img: np.ndarray) -> None:
tempdir = mkdtemp(prefix="chaiNNer-")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
NumberInput("Mean Subtraction"),
],
outputs=[ImageOutput(image_type="Input0")],
limited_to_8bpc=True,
)
def threshold_adaptive_node(
img: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
assume_normalized=True,
)
],
limited_to_8bpc=True,
)
def resize_factor_node(
img: np.ndarray, scale: float, interpolation: InterpolationMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
assume_normalized=True,
)
],
limited_to_8bpc=True,
)
def resize_resolution_node(
img: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def compareCondition(b: uint): bool {
assume_normalized=True,
)
],
limited_to_8bpc=True,
)
def resize_to_side_node(
img: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
SliderInput("Radius", minimum=0, maximum=1000, default=1, scale="log"),
],
outputs=[ImageOutput(image_type="Input0")],
limited_to_8bpc=True,
)
def median_blur_node(
img: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
),
],
outputs=[ImageOutput(image_type="Input0")],
limited_to_8bpc=True,
)
def average_color_fix_node(
input_img: np.ndarray, ref_img: np.ndarray, scale_factor: float
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
NumberInput("Search radius", minimum=1, default=10, maximum=30, precision=0),
],
outputs=[ImageOutput(image_type="Input0")],
limited_to_8bpc=True,
)
def fast_nl_means_node(
img: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
assume_normalized=True,
)
],
limited_to_8bpc=True,
)
def add_caption_node(
img: np.ndarray, caption: str, size: int, position: CaptionPosition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class InpaintAlgorithm(Enum):
)
).with_never_reason("The given image and mask must have the same resolution.")
],
limited_to_8bpc=True,
)
def inpaint_node(
img: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def transform(x: number, y: number) {
assume_normalized=True,
)
],
limited_to_8bpc=True,
)
def rotate_node(
img: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def metal_to_spec(
channels=1,
),
],
limited_to_8bpc=True,
)
def metal_to_specular_node(
albedo: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def spec_to_metal(
channels=1,
),
],
limited_to_8bpc=True,
)
def specular_to_metal_node(
diff: np.ndarray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
outputs=[],
side_effects=True,
limited_to_8bpc="The image will be copied to clipboard with 8 bits/channel.",
)
def copy_to_clipboard_node(value: str | np.ndarray) -> None:
if isinstance(value, np.ndarray):
Expand Down