Skip to content
Open
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
2 changes: 1 addition & 1 deletion fenn/cli/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _download_template(template_name: str, target_dir: Path, force: bool) -> Non
if e.response.status_code == 404: # ty: ignore[unresolved-attribute]
raise TemplateNotFoundError(
f"Template {Fore.LIGHTYELLOW_EX}{template_name}{Fore.RED} not found. "
f"Use {Fore.LIGHTYELLOW_EX}fenn pull --list{Fore.RED} to see available templates, "
f"Use {Fore.LIGHTYELLOW_EX}fenn list{Fore.RED} to see available templates, "
f"or visit {Fore.CYAN}https://github.com/{TEMPLATES_REPO}{Style.RESET_ALL}"
)
raise NetworkError(f"Failed to check template existence: {e}")
Expand Down
24 changes: 12 additions & 12 deletions fenn/experimental/vision/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def _normalize_0_1(array: np.ndarray) -> np.ndarray:
normalized_alpha = alpha_channel / dtype_max
else:
# Float type: if > 1, assume [0, 255] range, else already normalized
if alpha_channel.max() > 1.0:
if np.max(alpha_channel) > 1.0:
normalized_alpha = alpha_channel / 255.0
else:
normalized_alpha = alpha_channel
Expand All @@ -130,7 +130,7 @@ def _normalize_0_1(array: np.ndarray) -> np.ndarray:
normalized_alpha = alpha_channel / dtype_max
else:
# Float type: if > 1, assume [0, 255] range, else already normalized
if alpha_channel.max() > 1.0:
if np.max(alpha_channel) > 1.0:
normalized_alpha = alpha_channel / 255.0
else:
normalized_alpha = alpha_channel
Expand Down Expand Up @@ -198,7 +198,7 @@ def _normalize_minus1_1(array: np.ndarray) -> np.ndarray:
normalized_alpha = 2.0 * (alpha_channel / dtype_max) - 1.0
else:
# Float type: if > 1, assume [0, 255] range, else already in [0, 1]
if alpha_channel.max() > 1.0:
if np.max(alpha_channel) > 1.0:
normalized_alpha = 2.0 * (alpha_channel / 255.0) - 1.0
else:
# Already in [0, 1], map to [-1, 1]
Expand All @@ -223,7 +223,7 @@ def _normalize_minus1_1(array: np.ndarray) -> np.ndarray:
normalized_alpha = 2.0 * (alpha_channel / dtype_max) - 1.0
else:
# Float type: if > 1, assume [0, 255] range, else already in [0, 1]
if alpha_channel.max() > 1.0:
if np.max(alpha_channel) > 1.0:
normalized_alpha = 2.0 * (alpha_channel / 255.0) - 1.0
else:
# Already in [0, 1], map to [-1, 1]
Expand Down Expand Up @@ -290,8 +290,8 @@ def _normalize_imagenet_stats(array: np.ndarray) -> np.ndarray:
alpha_channel_original = array_float[:, 3:4, ...].copy()

# Auto-normalize only RGB channels to [0, 1] if needed
rgb_max = rgb_channels_float.max()
rgb_min = rgb_channels_float.min()
rgb_max = np.max(rgb_channels_float)
rgb_min = np.min(rgb_channels_float)

if rgb_min < 0.0:
if rgb_max <= 1.0:
Expand All @@ -306,8 +306,8 @@ def _normalize_imagenet_stats(array: np.ndarray) -> np.ndarray:
rgb_channels_float = rgb_channels_float / 255.0
else:
# Auto-normalize entire array to [0, 1] if values are outside expected [0, 1] range
array_max = array_float.max()
array_min = array_float.min()
array_max = np.max(array_float)
array_min = np.min(array_float)

if array_min < 0.0:
# Values are < 0, likely in [-1, 1] range
Expand Down Expand Up @@ -341,7 +341,7 @@ def _normalize_imagenet_stats(array: np.ndarray) -> np.ndarray:
normalized_alpha = alpha_channel_original / dtype_max
else:
# Float type: if > 1, assume [0, 255] range, else already in [0, 1]
if alpha_channel_original.max() > 1.0:
if np.max(alpha_channel_original) > 1.0:
normalized_alpha = alpha_channel_original / 255.0
else:
# Already in [0, 1], preserve as-is
Expand All @@ -359,7 +359,7 @@ def _normalize_imagenet_stats(array: np.ndarray) -> np.ndarray:
normalized_alpha = alpha_channel_original / dtype_max
else:
# Float type: if > 1, assume [0, 255] range, else already in [0, 1]
if alpha_channel_original.max() > 1.0:
if np.max(alpha_channel_original) > 1.0:
normalized_alpha = alpha_channel_original / 255.0
else:
# Already in [0, 1], preserve as-is
Expand Down Expand Up @@ -435,7 +435,7 @@ def _normalize_zscore(array: np.ndarray) -> np.ndarray:
normalized_alpha = alpha_channel / dtype_max
else:
# Float type: if > 1, assume [0, 255] range, else already in [0, 1]
if alpha_channel.max() > 1.0:
if np.max(alpha_channel) > 1.0:
normalized_alpha = alpha_channel / 255.0
else:
# Already in [0, 1], preserve as-is
Expand All @@ -459,7 +459,7 @@ def _normalize_zscore(array: np.ndarray) -> np.ndarray:
normalized_alpha = alpha_channel / dtype_max
else:
# Float type: if > 1, assume [0, 255] range, else already in [0, 1]
if alpha_channel.max() > 1.0:
if np.max(alpha_channel) > 1.0:
normalized_alpha = alpha_channel / 255.0
else:
# Already in [0, 1], preserve as-is
Expand Down