Microsoft 오픈 소스 매직 OmniParser-v2.0 로컬 배포 자습서
파이썬 환경 설치하기
이전 버전인 파이썬 3.11.5를 설치했는데 여기서는 다루지 않겠지만 필요한 경우 온라인에서 튜토리얼을 찾을 수 있습니다.
Anaconda 설치
저는 이전에 설치한 버전인 conda 23.7.4를 사용하고 있는데, 여기서는 설명하지 않겠지만 필요한 경우 온라인에서 튜토리얼을 찾을 수 있습니다.
옴니파서 설치
git clone https://github.com/microsoft/OmniParser.git cd OmniParser
전용 환경 만들기
conda create -n "omni" python==3.11
conda activate omni
다음 명령을 실행하여 필요한 종속성 패키지를 다운로드합니다.
pip install -r requirements.txt
다운로드 microsoft/OmniParser-v2.0
모델 파일이 있지만 웹 사이트에 접속할 수 없습니다(https://huggingface.co), 그래서 저는https://hf-mirror.com/.

마이크로 소프트 / 옴니파서-v2.0 찾기

안으로 들어가면 icon_caption 및 icon_detect) 폴더를 클릭하고 각각에 있는 파일을 다운로드합니다.

주로 다음 6가지 문서가 있습니다.
icon_detect/train_args.yaml icon_detect/model.pt icon_detect/model.yaml icon_caption/config.json icon_caption/generation_config.json icon_caption/model.safetensors
프로젝트 디렉터리에 다음과 같이 새 디렉터리를 만듭니다.
mkdir -p weights/icon_detect mkdir -p weights/icon_caption_florence
완성된 결과는 다음과 같습니다:

이전에 다운로드한 파일에 해당하는 폴더에 파일을 다운로드합니다.

python gradio_demo.py 명령을 실행하면 잠시 기다린 후 다음 오류가 발생합니다.
[2025-02-25 20:11:26,669] [ WARNING] easyocr.py:80 - Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU. Traceback (most recent call last): File "D:DevelopmentToolsPythonLibsite-packagesurllib3connection.py", line 203, in _new_conn sock = connection.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagesurllib3utilconnection.py", line 85, in create_connection raise err File "D:DevelopmentToolsPythonLibsite-packagesurllib3utilconnection.py", line 73, in create_connection sock.connect(sa) TimeoutError: timed out The above exception was the direct cause of the following exception: Traceback (most recent call last): File "D:DevelopmentToolsPythonLibsite-packagesurllib3connectionpool.py", line 790, in urlopen response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagesurllib3connectionpool.py", line 491, in _make_request raise new_e File "D:DevelopmentToolsPythonLibsite-packagesurllib3connectionpool.py", line 467, in _make_request self._validate_conn(conn) File "D:DevelopmentToolsPythonLibsite-packagesurllib3connectionpool.py", line 1096, in _validate_conn conn.connect() File "D:DevelopmentToolsPythonLibsite-packagesurllib3connection.py", line 611, in connect self.sock = sock = self._new_conn() ^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagesurllib3connection.py", line 212, in _new_conn raise ConnectTimeoutError( urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x0000019B3B7505D0>, 'Connection to huggingface.co timed out. (connect timeout=10)') The above exception was the direct cause of the following exception: Traceback (most recent call last): File "D:DevelopmentToolsPythonLibsite-packagesrequestsadapters.py", line 486, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagesurllib3connectionpool.py", line 844, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagesurllib3utilretry.py", line 515, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /microsoft/Florence-2-base/resolve/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000019B3B7505D0>, 'Connection to huggingface.co timed out. (connect timeout=10)')) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:DevelopmentToolsPythonLibsite-packageshuggingface_hubfile_download.py", line 1376, in _get_metadata_or_catch_error metadata = get_hf_file_metadata( ^^^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packageshuggingface_hubutils_validators.py", line 114, in _inner_fn return fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packageshuggingface_hubfile_download.py", line 1296, in get_hf_file_metadata r = _request_wrapper( ^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packageshuggingface_hubfile_download.py", line 280, in _request_wrapper response = _request_wrapper( ^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packageshuggingface_hubfile_download.py", line 303, in _request_wrapper response = get_session().request(method=method, url=url, **params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagesrequestssessions.py", line 589, in request resp = self.send(prep, **send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagesrequestssessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packageshuggingface_hubutils_http.py", line 96, in send return super().send(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagesrequestsadapters.py", line 507, in send raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /microsoft/Florence-2-base/resolve/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000019B3B7505D0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: 3ae795ae-e87f-45e3-8c1b-26c359494139)') The above exception was the direct cause of the following exception: Traceback (most recent call last): File "D:DevelopmentToolsPythonLibsite-packagestransformersutilshub.py", line 342, in cached_file resolved_file = hf_hub_download( ^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packageshuggingface_hubutils_validators.py", line 114, in _inner_fn return fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packageshuggingface_hubfile_download.py", line 862, in hf_hub_download return _hf_hub_download_to_cache_dir( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packageshuggingface_hubfile_download.py", line 969, in _hf_hub_download_to_cache_dir _raise_on_head_call_error(head_call_error, force_download, local_files_only) File "D:DevelopmentToolsPythonLibsite-packageshuggingface_hubfile_download.py", line 1489, in _raise_on_head_call_error raise LocalEntryNotFoundError( huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "E:OmniParsergradio_demo.py", line 16, in <module> caption_model_processor = get_caption_model_processor(model_name="florence2", model_name_or_path="weights/icon_caption_florence") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:OmniParserutilutils.py", line 63, in get_caption_model_processor processor = AutoProcessor.from_pretrained("microsoft/Florence-2-base", trust_remote_code=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagestransformersmodelsautoprocessing_auto.py", line 305, in from_pretrained config = AutoConfig.from_pretrained( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagestransformersmodelsautoconfiguration_auto.py", line 1075, in from_pretrained config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagestransformersconfiguration_utils.py", line 594, in get_config_dict config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagestransformersconfiguration_utils.py", line 653, in _get_config_dict resolved_config_file = cached_file( ^^^^^^^^^^^^ File "D:DevelopmentToolsPythonLibsite-packagestransformersutilshub.py", line 385, in cached_file raise EnvironmentError( OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like microsoft/Florence-2-base is not the path to a directory containing a file named config.json. Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.
실수가 많은 것처럼 보이지만 실제로는 다음과 같습니다. https://huggingface.co 액세스 권한이 없는 이유입니다. 에서 constants.py 파일을 변경해 보겠습니다. https://huggingface.co 다음으로 교체https://hf-mirror.com.

이 때문에 여전히 확신이 서지 않아 온라인에서 튜토리얼을 찾아보고 상단에 설정 줄을 하나 더 추가했습니다.

python gradio_demo.py 명령을 다시 입력하면 아래와 같이 성공적으로 실행됩니다:

브라우저에 입력합니다:http://127.0.0.1:7861결과는 아래와 같습니다:

데스크톱의 스크린샷을 찍어 분석해 달라고 요청하세요:

© 저작권 정책
기사 저작권 AI 공유 서클 모두 무단 복제하지 마세요.
관련 문서
댓글 없음...