Skip to content

Commit

Permalink
Enforce naming conventions (#1968)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Jul 22, 2023
1 parent 2f63585 commit c3f5edb
Show file tree
Hide file tree
Showing 50 changed files with 51 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
node_type="iteratorHelper",
side_effects=True,
)
def ModelFileIteratorLoadModelNode(
def iterator_helper_load_model_node(
param_path: str, bin_path: str, root_dir: str, index: int
) -> Tuple[NcnnModelWrapper, str, str, str, int]:
model, _, model_name = load_model_node(param_path, bin_path)
Expand Down Expand Up @@ -71,7 +71,7 @@ def ModelFileIteratorLoadModelNode(
node_type="iterator",
side_effects=True,
)
async def ModelFileIteratorNode(directory: str, context: IteratorContext) -> None:
async def model_file_iterator_node(directory: str, context: IteratorContext) -> None:
logger.debug(f"Iterating over models in directory: {directory}")

model_path_node_id = context.get_helper(NCNN_ITERATOR_NODE_ID).id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
inputs=[NcnnModelInput()],
outputs=[NumberOutput("Scale", output_type="Input0.scale")],
)
def model_dim_node(model: NcnnModelWrapper) -> int:
def get_model_scale_node(model: NcnnModelWrapper) -> int:
return model.scale
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
node_type="iteratorHelper",
side_effects=True,
)
def ModelFileIteratorLoadModelNode(
def iterator_helper_load_model_node(
path: str, root_dir: str, index: int
) -> Tuple[OnnxModel, str, str, str, int]:
model, dirname, basename = load_model_node(path)
Expand Down Expand Up @@ -69,7 +69,7 @@ def ModelFileIteratorLoadModelNode(
node_type="iterator",
side_effects=True,
)
async def ModelFileIteratorNode(directory: str, context: IteratorContext) -> None:
async def model_file_iterator_node(directory: str, context: IteratorContext) -> None:
logger.debug(f"Iterating over models in directory: {directory}")

model_path_node_id = context.get_helper(ONNX_ITERATOR_NODE_ID).id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
ImageOutput("Mask", image_type=navi.Image(size_as="Input0"), channels=1),
],
)
def rembg_node(
def remove_background_node(
img: np.ndarray,
model: OnnxRemBg,
post_process_mask: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
node_type="iteratorHelper",
side_effects=True,
)
def ModelFileIteratorLoadModelNode(
def iterator_helper_load_model_node(
path: str, root_dir: str, index: int
) -> Tuple[PyTorchModel, str, str, str, int]:
model, dirname, basename = load_model_node(path)
Expand Down Expand Up @@ -69,7 +69,7 @@ def ModelFileIteratorLoadModelNode(
node_type="iterator",
side_effects=True,
)
async def ModelFileIteratorNode(directory: str, context: IteratorContext) -> None:
async def model_file_iterator_node(directory: str, context: IteratorContext) -> None:
logger.debug(f"Iterating over models in directory: {directory}")

model_path_node_id = context.get_helper(PYTORCH_ITERATOR_NODE_ID).id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def upscale(
)
],
)
def face_upscale_node(
def upscale_face_node(
img: np.ndarray,
face_model: PyTorchFaceModel,
background_img: Union[np.ndarray, None],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
inputs=[ModelInput()],
outputs=[NumberOutput("Scale", output_type="Input0.scale")],
)
def model_dim_node(model: PyTorchModel) -> int:
def get_model_scale_node(model: PyTorchModel) -> int:
return model.scale
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def list_glob(directory: str, globexpr: str, ext_filter: List[str]) -> List[str]
],
side_effects=True,
)
def ImageFileIteratorLoadImageNode(
def iterator_helper_load_image_node(
path: str, root_dir: str, index: int
) -> Tuple[np.ndarray, str, str, str, int]:
img, img_dir, basename = load_image_node(path)
Expand Down Expand Up @@ -106,7 +106,7 @@ def ImageFileIteratorLoadImageNode(
"chainner:image:load",
],
)
async def ImageFileIteratorNode(
async def image_file_iterator_node(
directory: str,
use_glob: bool,
is_recursive: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
],
side_effects=True,
)
def ImageFileIteratorLoadImageNodeA(
def iterator_helper_load_image_node(
path_a: str, path_b: str, root_dir_a: str, root_dir_b: str, index: int
) -> Tuple[np.ndarray, np.ndarray, str, str, str, str, str, str, int]:
img_a, img_dir_a, basename_a = load_image_node(path_a)
Expand Down Expand Up @@ -90,7 +90,7 @@ def ImageFileIteratorLoadImageNodeA(
"chainner:image:file_iterator",
],
)
async def PairedImageFileIteratorNode(
async def image_pairs_iterator_node(
directory_a: str, directory_b: str, context: IteratorContext
) -> None:
logger.debug(f"Iterating over images in directories: {directory_a}, {directory_b}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
side_effects=True,
)
def ImageSpriteSheetIteratorLoadImageNode(
def iterator_helper_load_image_node(
img: np.ndarray, index: int
) -> Tuple[np.ndarray, int]:
return img, index
Expand All @@ -46,7 +46,7 @@ def ImageSpriteSheetIteratorLoadImageNode(
outputs=[],
side_effects=True,
)
def ImageSpriteSheetIteratorAppendImageNode(
def iterator_helper_append_image_node(
img: np.ndarray, results: List[np.ndarray]
) -> None:
results.append(img)
Expand Down Expand Up @@ -92,7 +92,7 @@ def ImageSpriteSheetIteratorAppendImageNode(
],
side_effects=True,
)
async def ImageSpriteSheetIteratorNode(
async def spritesheet_iterator_node(
sprite_sheet: np.ndarray,
rows: int,
columns: int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Writer:
],
side_effects=True,
)
def VideoFrameIteratorFrameLoaderNode(
def iterator_helper_load_frame_as_image_node(
img: np.ndarray, idx: int, video_dir: str, video_name: str
) -> Tuple[np.ndarray, int, str, str]:
return img, idx, video_dir, video_name
Expand Down Expand Up @@ -113,7 +113,7 @@ def VideoFrameIteratorFrameLoaderNode(
outputs=[],
side_effects=True,
)
def VideoFrameIteratorFrameWriterNode(
def iterator_helper_write_output_frame_node(
img: np.ndarray,
save_dir: str,
video_name: str,
Expand Down Expand Up @@ -198,7 +198,7 @@ def VideoFrameIteratorFrameWriterNode(
],
side_effects=True,
)
async def SimpleVideoFrameIteratorNode(path: str, context: IteratorContext) -> None:
async def video_frame_iterator_node(path: str, context: IteratorContext) -> None:
logger.debug(f"{ffmpeg_path=}, {ffprobe_path=}")
logger.debug(f"Iterating over frames in video file: {path}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
outputs=[],
side_effects=True,
)
def open_image_node(img: np.ndarray) -> None:
def view_image_external_node(img: np.ndarray) -> None:
tempdir = mkdtemp(prefix="chaiNNer-")
logger.debug(f"Writing image to temp path: {tempdir}")
im_name = f"{time.time()}.png"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def with_lightness(img: np.ndarray, lightness: float) -> np.ndarray:
],
outputs=[ImageOutput(image_type="Input0")],
)
def hue_and_sat(
def hue_and_saturation_node(
img: np.ndarray,
hue: float,
saturation: float,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
inputs=[ImageInput()],
outputs=[ImageOutput(image_type="Input0", assume_normalized=True)],
)
def invert_node(img: np.ndarray) -> np.ndarray:
def invert_color_node(img: np.ndarray) -> np.ndarray:
c = get_h_w_c(img)[2]

# invert the first 3 channels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
],
outputs=[ImageOutput(image_type="Input0")],
)
def adaptive_threshold_node(
def threshold_adaptive_node(
img: np.ndarray,
maxval: float,
adaptive_method: int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
],
deprecated=True,
)
def merge_rgba_node(
def merge_channels_node(
im1: np.ndarray,
im2: Union[np.ndarray, None],
im3: Union[np.ndarray, None],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
),
],
)
def separate_rgba(
def separate_rgba_node(
img: np.ndarray,
) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
h, w, c = get_h_w_c(img)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
),
],
)
def split_transparency(img: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
def split_transparency_node(img: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
"""Split a multi-channel image into separate channels"""

img = as_target_channels(img, 4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
)
],
)
def border_crop_node(img: np.ndarray, amount: int) -> np.ndarray:
def crop_border_node(img: np.ndarray, amount: int) -> np.ndarray:
h, w, _ = get_h_w_c(img)

assert 2 * amount < h, "Cropped area would result in an image with no height"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)
],
)
def edge_crop_node(
def crop_edges_node(
img: np.ndarray, top: int, left: int, right: int, bottom: int
) -> np.ndarray:
h, w, _ = get_h_w_c(img)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
],
outputs=[ImageOutput(image_type="Input0")],
)
def bilateral_blur_node(
def surface_blur_node(
img: np.ndarray,
diameter: int,
sigma_color: int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
)
],
)
def image_convolve_node(
def convolve_node(
img: np.ndarray,
kernel_in: str,
padding: int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
outputs=[ImageOutput(image_type="Input0")],
)
def high_pass_filter_node(
def high_pass_node(
img: np.ndarray,
radius: float,
contrast: float,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
],
outputs=[ImageOutput(image_type="Input0")],
)
def fast_nlmeans_node(
def fast_nl_means_node(
img: np.ndarray,
h: float,
h_color: float,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class PaletteDitherAlgorithm(Enum):
],
outputs=[ImageOutput(image_type="Input0")],
)
def palette_dither_node(
def dither_palette_node(
img: np.ndarray,
palette: np.ndarray,
dither_algorithm: PaletteDitherAlgorithm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class KernelType(Enum):
],
outputs=[ImageOutput(image_type="Input0")],
)
def sharpen_hbf_node(
def high_boost_filter_node(
img: np.ndarray,
kernel_type: KernelType,
amount: float,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
],
outputs=[ImageOutput(image_type="Input0")],
)
def sharpen_node(
def unsharp_mask_node(
img: np.ndarray,
radius: float,
amount: float,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)
],
)
def caption_node(
def add_caption_node(
img: np.ndarray, caption: str, size: int, position: CaptionPosition
) -> np.ndarray:
"""Add caption an image"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def getHeight(i: any) = match i { Image => i.height, _ => -inf };
).with_never_reason("At least one layer must be an image"),
],
)
def blend_node(
def blend_images_node(
base: np.ndarray | Color,
ov: np.ndarray | Color,
blend_mode: BlendMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def getAdjustedHeight(img: Image | null) {
)
],
)
def stack_node(
def stack_images_node(
im1: np.ndarray,
im2: np.ndarray | None,
im3: np.ndarray | None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def conv(i: Image | null) = match i { Image => i, _ => any };
),
],
)
def z_stack(
def z_stack_images_node(
expression: Expression,
*inputs: np.ndarray | None,
) -> np.ndarray:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def quantize(img: np.ndarray, levels: int) -> np.ndarray:
ImageOutput(image_type=navi.Image(size_as="Input0", channels_as="Input1"))
],
)
def lut_node(
def apply_lut_node(
img: np.ndarray,
lut: np.ndarray,
) -> np.ndarray:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
)
],
)
def convert_color_node(
def change_colorspace_node(
img: np.ndarray, input_: int, output: int, alpha: bool
) -> np.ndarray:
"""Takes an image and changes the color mode it"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
TextOutput("Base64"),
],
)
def run(img: np.ndarray, size: int) -> Tuple[str, str]:
def generate_hash_node(img: np.ndarray, size: int) -> Tuple[str, str]:
"""Generate a hash from the input image. The digest size determines the length of the hash that is output."""
img = np.ascontiguousarray(to_uint8(img))
h = hashlib.blake2b(img, digest_size=size) # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
NumberOutput("Percentile", output_type="0..255"),
],
)
def image_statistic(
def image_statistics_node(
img: np.ndarray,
percentile: float,
) -> Tuple[float, float, float, float]:
Expand Down
Loading

0 comments on commit c3f5edb

Please sign in to comment.