Normalize Path import style

This commit is contained in:
Aarni Koskela 2025-04-25 13:50:00 +03:00
parent 2039d0fc54
commit effff3273a
3 changed files with 14 additions and 14 deletions

View File

@ -1,6 +1,6 @@
import importlib
import pathlib
import typing as t
from pathlib import Path
import mlx.core as mx
import PIL.Image
@ -23,13 +23,13 @@ class GeneratedImage:
generation_time: float,
lora_paths: list[str],
lora_scales: list[float],
controlnet_image_path: str | pathlib.Path | None = None,
controlnet_image_path: str | Path | None = None,
controlnet_strength: float | None = None,
image_path: str | pathlib.Path | None = None,
image_path: str | Path | None = None,
image_strength: float | None = None,
masked_image_path: str | pathlib.Path | None = None,
depth_image_path: str | pathlib.Path | None = None,
redux_image_paths: list[str] | list[pathlib.Path] | None = None,
masked_image_path: str | Path | None = None,
depth_image_path: str | Path | None = None,
redux_image_paths: list[str] | list[Path] | None = None,
):
self.image = image
self.model_config = model_config
@ -78,7 +78,7 @@ class GeneratedImage:
def save(
self,
path: t.Union[str, pathlib.Path],
path: t.Union[str, Path],
export_json_metadata: bool = False,
overwrite: bool = False,
) -> None:
@ -129,7 +129,7 @@ class GeneratedImage:
@staticmethod
def _get_version_from_toml() -> str | None:
# Search for pyproject.toml by traversing up from the current working directory
current_dir = pathlib.Path(__file__).resolve().parent
current_dir = Path(__file__).resolve().parent
for parent in current_dir.parents:
pyproject_path = parent / "pyproject.toml"
if pyproject_path.exists():

View File

@ -1,7 +1,7 @@
import json
import logging
import pathlib
import typing as t
from pathlib import Path
import mlx.core as mx
import numpy as np
@ -113,7 +113,7 @@ class ImageUtil:
return array
@staticmethod
def load_image(path: str | pathlib.Path) -> PIL.Image.Image:
def load_image(path: str | Path) -> PIL.Image.Image:
return PIL.Image.open(path)
@staticmethod
@ -204,12 +204,12 @@ class ImageUtil:
@staticmethod
def save_image(
image: PIL.Image.Image,
path: t.Union[str, pathlib.Path],
path: t.Union[str, Path],
metadata: dict | None = None,
export_json_metadata: bool = False,
overwrite: bool = False,
) -> None:
file_path = pathlib.Path(path)
file_path = Path(path)
file_path.parent.mkdir(parents=True, exist_ok=True)
file_name = file_path.stem
file_extension = file_path.suffix

View File

@ -1,5 +1,5 @@
import pathlib
import sys
from pathlib import Path
from mflux.post_processing.image_util import ImageUtil
from mflux.ui.box_values import AbsoluteBoxValues, BoxValues
@ -8,7 +8,7 @@ from mflux.ui.cli.parsers import CommandLineParser
def main():
parser = CommandLineParser(description="Create expanded canvas and mask for outpainting")
parser.add_argument("image_path", type=pathlib.Path, help="Path to the input image file")
parser.add_argument("image_path", type=Path, help="Path to the input image file")
parser.add_image_outpaint_arguments(required=True)
args = parser.parse_args()