add MLX_USE_MODELSCOPE env

This commit is contained in:
xingjun.wang 2025-01-06 00:04:06 +08:00
parent c4833a2f55
commit 9d86b5b744

View File

@ -1,5 +1,6 @@
# Copyright © 2023-2024 Apple Inc.
import os
import contextlib
import copy
import glob
@ -15,7 +16,10 @@ from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Type,
import mlx.core as mx
import mlx.nn as nn
from huggingface_hub import snapshot_download
if os.getenv('MLX_USE_MODELSCOPE', 'False').lower() == 'true':
from modelscope import snapshot_download
else:
from huggingface_hub import snapshot_download
from mlx.utils import tree_flatten, tree_reduce
from transformers import PreTrainedTokenizer