diff --git a/pyproject.toml b/pyproject.toml index 79f4c39..fe3af53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,6 @@ dependencies = [ "tokenizers>=0.20.3; python_version>='3.13'", # transformers -> tokenizers "toml>=0.10.2,<1.0", "torch>=2.3.1,<3.0; python_version<'3.13'", - "torchvision>=0.18.1,<0.22.0", # torch dev builds: pip install --pre --index-url https://download.pytorch.org/whl/nightly "torch>=2.6.0.dev20241106; python_version>='3.13'", "tqdm>=4.66.5,<5.0", diff --git a/src/mflux/post_processing/image_util.py b/src/mflux/post_processing/image_util.py index 7729745..599c9c8 100644 --- a/src/mflux/post_processing/image_util.py +++ b/src/mflux/post_processing/image_util.py @@ -8,7 +8,6 @@ import numpy as np import piexif import PIL.Image import PIL.ImageDraw -import torchvision.transforms.functional as F from mflux.config.runtime_config import RuntimeConfig from mflux.post_processing.generated_image import GeneratedImage @@ -302,6 +301,16 @@ class ImageUtil: std: list = [0.5, 0.5, 0.5], resample: int = PIL.Image.LANCZOS, ) -> mx.array: - image_np = F.to_tensor(image) - tensor = F.normalize(image_np, mean, std, False) - return mx.array(tensor) + # Convert PIL image to numpy array and normalize to [0, 1] + image_np = np.array(image).astype(np.float32) / 255.0 + + # Convert from HWC to CHW format + image_np = image_np.transpose(2, 0, 1) + + # Normalize using specified mean and std + mean_np = np.array(mean).reshape(-1, 1, 1) + std_np = np.array(std).reshape(-1, 1, 1) + image_np = (image_np - mean_np) / std_np + + # Convert to MLX array + return mx.array(image_np)