jhc13 / taggui

Tag manager and captioner for image datasets
GNU General Public License v3.0
692 stars 32 forks source link

Unable to run Florence-2 offline #229

Closed Baku-Rue closed 2 months ago

Baku-Rue commented 3 months ago

When connected online the model run just fine, however as soon as I disconnect I get a "failed to resolve hugging.co". I can run other models offline but not this newer one. Is there any way around this restriction?

Loading microsoft/Florence-2-large... Traceback (most recent call last): File "C:\AI\TagGui\taggui\taggui\lib\site-packages\urllib3\connection.py", line 203, in _new_conn sock = connection.create_connection( File "C:\AI\TagGui\taggui\taggui\lib\site-packages\urllib3\util\connection.py", line 60, in create_connection for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\socket.py", line 955, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket . gaierror : [Errno 11001] getaddrinfo failed The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\AI\TagGui\taggui\taggui\lib\site-packages\urllib3\connectionpool.py", line 791, in urlopen response = self._make_request( File "C:\AI\TagGui\taggui\taggui\lib\site-packages\urllib3\connectionpool.py", line 492, in _make_request raise new_e File "C:\AI\TagGui\taggui\taggui\lib\site-packages\urllib3\connectionpool.py", line 468, in _make_request self._validate_conn(conn) File "C:\AI\TagGui\taggui\taggui\lib\site-packages\urllib3\connectionpool.py", line 1097, in _validate_conn conn.connect() File "C:\AI\TagGui\taggui\taggui\lib\site-packages\urllib3\connection.py", line 611, in connect self.sock = sock = self._new_conn() File "C:\AI\TagGui\taggui\taggui\lib\site-packages\urllib3\connection.py", line 210, in _new_conn raise NameResolutionError(self.host, self, e) from e urllib3.exceptions . NameResolutionError : <urllib3.connection.HTTPSConnection object at 0x000001CB53B25C90>: Failed to resolve 'huggingface.co' ([Errno 11001] getaddrinfo failed) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\AI\TagGui\taggui\taggui\lib\site-packages\requests\adapters.py", line 667, in send resp = conn.urlopen( File "C:\AI\TagGui\taggui\taggui\lib\site-packages\urllib3\connectionpool.py", line 845, in urlopen retries = retries.increment( File "C:\AI\TagGui\taggui\taggui\lib\site-packages\urllib3\util\retry.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-large/resolve/main/model.safetensors (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x000001CB53B25C90>: Failed to resolve 'huggingface.co' ([Errno 11001] getaddrinfo failed)")) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\AI\TagGui\taggui\taggui\auto_captioning\captioning_thread.py", line 532, in run raise exception File "C:\AI\TagGui\taggui\taggui\auto_captioning\captioning_thread.py", line 528, in run self.run_captioning() File "C:\AI\TagGui\taggui\taggui\auto_captioning\captioning_thread.py", line 415, in run_captioning processor, model = self.load_processor_and_model(device, model_type) File "C:\AI\TagGui\taggui\taggui\auto_captioning\captioning_thread.py", line 271, in load_processor_and_model model = model_class.from_pretrained( File "C:\AI\TagGui\taggui\taggui\lib\site-packages\transformers\models\auto\auto_factory.py", line 558, in from_pretrained return model_class.from_pretrained( File "C:\AI\TagGui\taggui\taggui\lib\site-packages\transformers\modeling_utils.py", line 3415, in from_pretrained if not has_file(pretrained_model_name_or_path, safe_weights_name, has_file_kwargs): File "C:\AI\TagGui\taggui\taggui\lib\site-packages\transformers\utils\hub.py", line 629, in has_file r = requests.head(url, headers=headers, allow_redirects=False, proxies=proxies, timeout=10) File "C:\AI\TagGui\taggui\taggui\lib\site-packages\requests\api.py", line 100, in head return request("head", url, kwargs) File "C:\AI\TagGui\taggui\taggui\lib\site-packages\requests\api.py", line 59, in request return session.request(method=method, url=url, kwargs) File "C:\AI\TagGui\taggui\taggui\lib\site-packages\requests\sessions.py", line 589, in request resp = self.send(prep, send_kwargs) File "C:\AI\TagGui\taggui\taggui\lib\site-packages\requests\sessions.py", line 703, in send r = adapter.send(request, **kwargs) File "C:\AI\TagGui\taggui\taggui\lib\site-packages\requests\adapters.py", line 700, in send raise ConnectionError(e, request=request) requests.exceptions . ConnectionError : HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /microsoft/Florence-2-large/resolve/main/model.safetensors (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x000001CB53B25C90>: Failed to resolve 'huggingface.co' ([Errno 11001] getaddrinfo failed)"))

geroldmeisinger commented 3 months ago

@jhc13 I can confirm this. It also happens with: internlm family THUDM/cogvlm2-llama3-chat-19B-int4 (and possibly some other models)

some work without internet though: vikhyatk/moondream2 vikhyatk/moondream1 microsoft/kosmos-2-patch14-224 THUDM/cogvlm-chat-hf THUDM/cogagent-vqa-hf llava-hf family (didn't try 34b though)

that may very well be a bug in hf downloader?

geroldmeisinger commented 3 months ago

@Baku-Rue thank you for bringing this to our attention. however it seems to be a bug in the hf downloader. I can reproduce the error with the following snippet.

from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("microsoft/Florence-2-base", trust_remote_code=True)

could you please report in upstream! (ask here if you need help)