Skip to content

Commit fbd19a0

Browse files
committed
fix(image-utils): fix all functions
1 parent 21e748a commit fbd19a0

12 files changed

Lines changed: 1390 additions & 99 deletions

File tree

‎VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.13.2
1+
0.14

‎src/vicentin/deep_learning/train/GANTrainer.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(
2323
noise_dim: int = 100,
2424
n_imgs_val: int = 64,
2525
sample_path: str = "gan_samples",
26-
export_mode: Literal["save", "show", None] = "show",
26+
export_mode: Literal["save", "show", None] = None,
2727
fixed_z: Optional[torch.Tensor] = None,
2828
hyperparams: Optional[Dict[str, Any]] = None,
2929
device: Optional[torch.device] = None,

‎src/vicentin/deep_learning/train/VAETrainer.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(
2121
float16: bool = False,
2222
sample_path: str = "vae_samples",
2323
n_imgs_val: int = 8,
24-
export_mode: Literal["save", "show", None] = "show",
24+
export_mode: Literal["save", "show", None] = None,
2525
):
2626
super().__init__(
2727
models={"vae": model},

‎src/vicentin/image/__init__.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from . import utils
12
from . import differentiation
23
from . import regularization
3-
from . import utils
4+
from . import video

‎src/vicentin/image/img2graph.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
from typing import Any, Callable, Optional
12
from vicentin import Graph
23
from vicentin.image.utils import get_neighbors
34

45

5-
def _compute_edges(H, W, L, img, weight_func, neighborhood):
6+
def _compute_edges(
7+
H: int, W: int, L: int, img: Any, weight_func: Callable, neighborhood: int
8+
):
69
"""
710
Computes the weighted edges of a graph representation of an image.
811
@@ -14,7 +17,7 @@ def _compute_edges(H, W, L, img, weight_func, neighborhood):
1417
H (int): The height (number of rows) of the image.
1518
W (int): The width (number of columns) of the image.
1619
L (int): The depth (number of channels) of the image.
17-
img (numpy.ndarray or jnp.ndarray): A 1D, 2D, or 3D NumPy array representing the image.
20+
img (numpy.ndarray or torch.Tensor): A 1D, 2D, or 3D NumPy array representing the image.
1821
weight_func (callable): A function `f(u, v) -> float` that computes edge
1922
weights based on pixel values.
2023
neighborhood (int): The type of neighborhood connectivity:
@@ -51,7 +54,9 @@ def _compute_edges(H, W, L, img, weight_func, neighborhood):
5154
return edges
5255

5356

54-
def img2graph(img, weight_func=None, neighborhood=4):
57+
def img2graph(
58+
img: Any, weight_func: Optional[Callable] = None, neighborhood: int = 4
59+
):
5560
"""
5661
Converts a 1D, 2D, or 3D image into a graph representation.
5762
@@ -60,7 +65,7 @@ def img2graph(img, weight_func=None, neighborhood=4):
6065
are determined by a user-defined function (defaulting to squared intensity difference).
6166
6267
Args:
63-
img (numpy.ndarray or jnp.ndarray): An array of shape (N,), (N, M), or (N, M, L)
68+
img (numpy.ndarray or torch.Tensor): An array of shape (N,), (N, M), or (N, M, L)
6469
representing a 1D, 2D, or 3D image.
6570
weight_func (callable, optional): A function `f(u, v) -> float` that computes edge
6671
weights based on pixel values.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from .utils import (
2+
pad_image,
3+
correlate,
4+
convolve,
5+
gaussian_filter,
6+
img2patches,
7+
get_neighbors,
8+
)

0 commit comments

Comments
 (0)