From 56f8fdc4a60c60933221dcc4afd811b1b4ab9664 Mon Sep 17 00:00:00 2001 From: Prince Canuma Date: Tue, 30 Apr 2024 20:57:13 +0200 Subject: [PATCH] rename model folder --- .../{llavaPhiMini3 => llavaPhi3}/README.md | 0 .../{llavaPhiMini3 => llavaPhi3}/__init__.py | 0 .../{llavaPhiMini3 => llavaPhi3}/language.py | 0 .../{llavaPhiMini3 => llavaPhi3}/llavaPhi.py | 0 .../{llavaPhiMini3 => llavaPhi3}/vision.py | 0 mlx_vlm/utils.py | 45 ++++++++++--------- 6 files changed, 23 insertions(+), 22 deletions(-) rename mlx_vlm/models/{llavaPhiMini3 => llavaPhi3}/README.md (100%) rename mlx_vlm/models/{llavaPhiMini3 => llavaPhi3}/__init__.py (100%) rename mlx_vlm/models/{llavaPhiMini3 => llavaPhi3}/language.py (100%) rename mlx_vlm/models/{llavaPhiMini3 => llavaPhi3}/llavaPhi.py (100%) rename mlx_vlm/models/{llavaPhiMini3 => llavaPhi3}/vision.py (100%) diff --git a/mlx_vlm/models/llavaPhiMini3/README.md b/mlx_vlm/models/llavaPhi3/README.md similarity index 100% rename from mlx_vlm/models/llavaPhiMini3/README.md rename to mlx_vlm/models/llavaPhi3/README.md diff --git a/mlx_vlm/models/llavaPhiMini3/__init__.py b/mlx_vlm/models/llavaPhi3/__init__.py similarity index 100% rename from mlx_vlm/models/llavaPhiMini3/__init__.py rename to mlx_vlm/models/llavaPhi3/__init__.py diff --git a/mlx_vlm/models/llavaPhiMini3/language.py b/mlx_vlm/models/llavaPhi3/language.py similarity index 100% rename from mlx_vlm/models/llavaPhiMini3/language.py rename to mlx_vlm/models/llavaPhi3/language.py diff --git a/mlx_vlm/models/llavaPhiMini3/llavaPhi.py b/mlx_vlm/models/llavaPhi3/llavaPhi.py similarity index 100% rename from mlx_vlm/models/llavaPhiMini3/llavaPhi.py rename to mlx_vlm/models/llavaPhi3/llavaPhi.py diff --git a/mlx_vlm/models/llavaPhiMini3/vision.py b/mlx_vlm/models/llavaPhi3/vision.py similarity index 100% rename from mlx_vlm/models/llavaPhiMini3/vision.py rename to mlx_vlm/models/llavaPhi3/vision.py diff --git a/mlx_vlm/utils.py b/mlx_vlm/utils.py index 9e7e68a..ee67662 100644 --- a/mlx_vlm/utils.py +++ b/mlx_vlm/utils.py @@ -23,6 +23,7 @@ PreTrainedTokenizer, PreTrainedTokenizerFast, ) +from transformers.image_utils import load_image from .models.base import BaseImageProcessor from .sample_utils import top_p_sampling @@ -562,28 +563,28 @@ def convert( upload_to_hub(mlx_path, upload_repo, hf_path) -def load_image(image_source): - """ - Helper function to load an image from either a URL or file. - """ - if image_source.startswith(("http://", "https://")): - try: - response = requests.get(image_source, stream=True) - response.raise_for_status() - return Image.open(response.raw) - except Exception as e: - raise ValueError( - f"Failed to load image from URL: {image_source} with error {e}" - ) - elif Path(image_source).is_file(): - try: - return Image.open(image_source) - except IOError as e: - raise ValueError(f"Failed to load image {image_source} with error: {e}") - else: - raise ValueError( - f"The image {image_source} must be a valid URL or existing file." - ) +# def load_image(image_source): +# """ +# Helper function to load an image from either a URL or file. +# """ +# if image_source.startswith(("http://", "https://")): +# try: +# response = requests.get(image_source, stream=True) +# response.raise_for_status() +# return Image.open(response.raw) +# except Exception as e: +# raise ValueError( +# f"Failed to load image from URL: {image_source} with error {e}" +# ) +# elif Path(image_source).is_file(): +# try: +# return Image.open(image_source) +# except IOError as e: +# raise ValueError(f"Failed to load image {image_source} with error: {e}") +# else: +# raise ValueError( +# f"The image {image_source} must be a valid URL or existing file." +# ) def prepare_inputs(image_processor, processor, image, prompt):