Repository: towhee-io/towhee

Issue #679: [Bug]: Pipeline "towhee/image-embedding-regnety-120" crashed when embedding an image
Created: 2022-02-23T07:37:43Z
Is there an existing issue for this?

 I have searched the existing issues

Current Behavior
Pipeline "towhee/image-embedding-regnety-120" crashed when embedding an image
>>> embedding_pipeline = pipeline('towhee/image-embedding-regnety-120')
正克隆到 '/Users/binbin/.towhee/pipelines/towhee/image_embedding_regnety_120/main'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 0), reused 0 (delta 0), pack-reused 0
接收对象中: 100% (7/7), 完成.
>>> embedding = embedding_pipeline(img_path)
正克隆到 '/Users/binbin/.towhee/operators/towhee/image_decoder/main'...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 16 (delta 3), reused 0 (delta 0), pack-reused 0
接收对象中: 100% (16/16), 完成.
处理 delta 中: 100% (3/3), 完成.
Requirement already satisfied: opencv-python in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from -r /Users/binbin/.towhee/operators/towhee/image_decoder/main/requirements.txt (line 1)) (4.5.4.60)
Requirement already satisfied: requests in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from -r /Users/binbin/.towhee/operators/towhee/image_decoder/main/requirements.txt (line 2)) (2.26.0)
Requirement already satisfied: numpy in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from -r /Users/binbin/.towhee/operators/towhee/image_decoder/main/requirements.txt (line 3)) (1.19.5)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from requests->-r /Users/binbin/.towhee/operators/towhee/image_decoder/main/requirements.txt (line 2)) (1.26.7)
Requirement already satisfied: idna<4,>=2.5 in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from requests->-r /Users/binbin/.towhee/operators/towhee/image_decoder/main/requirements.txt (line 2)) (3.3)
Requirement already satisfied: certifi>=2017.4.17 in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from requests->-r /Users/binbin/.towhee/operators/towhee/image_decoder/main/requirements.txt (line 2)) (2021.10.8)
Requirement already satisfied: charset-normalizer~=2.0.0 in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from requests->-r /Users/binbin/.towhee/operators/towhee/image_decoder/main/requirements.txt (line 2)) (2.0.9)
WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
You should consider upgrading via the '/Users/binbin/Towhee_projects/towhee-test-env/bin/python3 -m pip install --upgrade pip' command.
正克隆到 '/Users/binbin/.towhee/operators/towhee/timm_image_embedding/main'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 14 (delta 4), reused 0 (delta 0), pack-reused 0
接收对象中: 100% (14/14), 完成.
处理 delta 中: 100% (4/4), 完成.
Requirement already satisfied: numpy in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from -r /Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/requirements.txt (line 1)) (1.19.5)
Requirement already satisfied: timm>=0.5.4 in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from -r /Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/requirements.txt (line 2)) (0.5.4)
Requirement already satisfied: torch>=1.4 in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from timm>=0.5.4->-r /Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/requirements.txt (line 2)) (1.9.0)
Requirement already satisfied: torchvision in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from timm>=0.5.4->-r /Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/requirements.txt (line 2)) (0.10.0)
Requirement already satisfied: typing-extensions in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from torch>=1.4->timm>=0.5.4->-r /Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/requirements.txt (line 2)) (3.7.4.3)
Requirement already satisfied: pillow>=5.3.0 in /Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages (from torchvision->timm>=0.5.4->-r /Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/requirements.txt (line 2)) (8.3.1)
WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
You should consider upgrading via the '/Users/binbin/Towhee_projects/towhee-test-env/bin/python3 -m pip install --upgrade pip' command.
2022-02-23 15:32:46,359 - 123145485737984 - thread_pool_task_executor.py-thread_pool_task_executor:75 - ERROR: Traceback (most recent call last):
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/towhee/engine/thread_pool_task_executor.py", line 68, in execute
    op = self._op_pool.acquire_op(runner.hub_op_id, runner.op_args, runner.tag)
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/towhee/engine/operator_pool.py", line 102, in acquire_op
    op = self._op_loader.load_operator(hub_op_id, op_args, tag)
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/towhee/engine/operator_loader.py", line 142, in load_operator
    op = factory(function, args, tag)
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/towhee/engine/operator_loader.py", line 118, in load_operator_from_cache
    return self.load_operator_from_path(path, args)
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/towhee/engine/operator_loader.py", line 108, in load_operator_from_path
    return self.instance_operator(op, args) if op is not None else None
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/towhee/engine/operator_loader.py", line 152, in instance_operator
    return op(**args) if args is not None else op()
  File "/Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/timm_image_embedding.py", line 25, in __init__
    self.model = create_model(model_name, pretrained=True, num_classes=0)
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/timm/models/factory.py", line 74, in create_model
    model = create_fn(pretrained=pretrained, **kwargs)
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/timm/models/regnet.py", line 482, in regnety_120
    return _create_regnet('regnety_120', pretrained, **kwargs)
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/timm/models/regnet.py", line 345, in _create_regnet
    return build_model_with_cfg(
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/timm/models/helpers.py", line 465, in build_model_with_cfg
    load_pretrained(
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/timm/models/helpers.py", line 189, in load_pretrained
    state_dict = load_state_dict_from_url(pretrained_url, progress=progress, map_location='cpu')
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/torch/hub.py", line 557, in load_state_dict_from_url
    return torch.load(cached_file, map_location=map_location)
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/torch/serialization.py", line 608, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/torch/serialization.py", line 794, in _legacy_load
    deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: unexpected EOF, expected 765501 more bytes. The file might be corrupted.

2022-02-23 15:32:46,360 - 123145485737984 - thread_pool_task_executor.py-thread_pool_task_executor:76 - ERROR: unexpected EOF, expected 765501 more bytes. The file might be corrupted.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/towhee/__init__.py", line 73, in __call__
    out_df = self._pipeline(in_df)
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/towhee/engine/pipeline.py", line 107, in __call__
    graph_ctx.join()
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/towhee/engine/graph_context.py", line 99, in join
    op.join()
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/towhee/engine/operator_context.py", line 146, in join
    runner.join()
  File "/Users/binbin/Towhee_projects/towhee-test-env/lib/python3.8/site-packages/towhee/engine/operator_runner/runner_base.py", line 218, in join
    self._end_event.wait()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/threading.py", line 558, in wait
    signaled = self._cond.wait(timeout)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/threading.py", line 302, in wait
    waiter.acquire()
KeyboardInterrupt

Expected Behavior
No crash and embedding successfully
Steps To Reproduce
1. install towhee
towhee: 0.4.1.dev86
Name: timm
Version: 0.5.4
2. 

from towhee import pipeline
img_path = '/Users/binbin/Towhee_projects/2021825-19039.jpg'
embedding_pipeline = pipeline('towhee/image-embedding-regnety-120')
Environment
- Towhee version(e.g. v0.1.3 or 8b23a93):0.4.1.dev86
- OS(Ubuntu or CentOS):Mac
- CPU/Memory:
- GPU:
- Others:
Anything else?
No response

Duplicate issue #715: [Bug]: Pipeline "towhee/image-embedding-xcit-large-24-p16-384-dist" is crashed when embedding an image reporting "RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory"
Created: 2022-02-28T10:35:59Z
Is there an existing issue for this?

 I have searched the existing issues

Current Behavior
Pipeline "towhee/image-embedding-xcit-large-24-p16-384-dist" is crashed when embedding an image reporting "RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory"
Expected Behavior
Embedded succesfully
Steps To Reproduce
from towhee import pipeline
img_path = '/Users/binbin/Towhee_projects/2021825-19039.jpg'
embedding_pipeline = pipeline('towhee/image-embedding-xcit-large-24-p16-384-dist')


### Environment

```markdown
- Towhee version(e.g. v0.1.3 or 8b23a93):
- OS(Ubuntu or CentOS): mac OS (tim: 0.5.4)
- CPU/Memory:
- GPU:
- Others:

Anything else?
error trace:
Requirement already satisfied: numpy in /Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages (from -r /Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/requirements.txt (line 1)) (1.19.5)
Requirement already satisfied: timm>=0.5.4 in /Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages (from -r /Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/requirements.txt (line 2)) (0.5.4)
Requirement already satisfied: torch>=1.4 in /Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages (from timm>=0.5.4->-r /Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/requirements.txt (line 2)) (1.9.0)
Requirement already satisfied: torchvision in /Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages (from timm>=0.5.4->-r /Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/requirements.txt (line 2)) (0.10.0)
Requirement already satisfied: typing-extensions in /Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages (from torch>=1.4->timm>=0.5.4->-r /Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/requirements.txt (line 2)) (4.1.1)
Requirement already satisfied: pillow>=5.3.0 in /Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages (from torchvision->timm>=0.5.4->-r /Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/requirements.txt (line 2)) (8.3.1)
2022-02-28 18:31:34,656 - 123145509978112 - thread_pool_task_executor.py-thread_pool_task_executor:75 - ERROR: Traceback (most recent call last):
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/towhee/engine/thread_pool_task_executor.py", line 68, in execute
    op = self._op_pool.acquire_op(runner.hub_op_id, runner.op_args, runner.tag)
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/towhee/engine/operator_pool.py", line 102, in acquire_op
    op = self._op_loader.load_operator(hub_op_id, op_args, tag)
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/towhee/engine/operator_loader.py", line 142, in load_operator
    op = factory(function, args, tag)
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/towhee/engine/operator_loader.py", line 118, in load_operator_from_cache
    return self.load_operator_from_path(path, args)
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/towhee/engine/operator_loader.py", line 108, in load_operator_from_path
    return self.instance_operator(op, args) if op is not None else None
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/towhee/engine/operator_loader.py", line 152, in instance_operator
    return op(**args) if args is not None else op()
  File "/Users/binbin/.towhee/operators/towhee/timm_image_embedding/main/timm_image_embedding.py", line 25, in __init__
    self.model = create_model(model_name, pretrained=True, num_classes=0)
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/timm/models/factory.py", line 74, in create_model
    model = create_fn(pretrained=pretrained, **kwargs)
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/timm/models/xcit.py", line 644, in xcit_large_24_p16_384_dist
    model = _create_xcit('xcit_large_24_p16_384_dist', pretrained=pretrained, **model_kwargs)
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/timm/models/xcit.py", line 475, in _create_xcit
    model = build_model_with_cfg(
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/timm/models/helpers.py", line 465, in build_model_with_cfg
    load_pretrained(
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/timm/models/helpers.py", line 189, in load_pretrained
    state_dict = load_state_dict_from_url(pretrained_url, progress=progress, map_location='cpu')
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/torch/hub.py", line 557, in load_state_dict_from_url
    return torch.load(cached_file, map_location=map_location)
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/torch/serialization.py", line 600, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/torch/serialization.py", line 242, in __init__
    super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

2022-02-28 18:31:34,656 - 123145509978112 - thread_pool_task_executor.py-thread_pool_task_executor:76 - ERROR: PytorchStreamReader failed reading zip archive: failed finding central directory
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/towhee/__init__.py", line 73, in __call__
    out_df = self._pipeline(in_df)
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/towhee/engine/pipeline.py", line 107, in __call__
    graph_ctx.join()
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/towhee/engine/graph_context.py", line 99, in join
    op.join()
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/towhee/engine/operator_context.py", line 146, in join
    runner.join()
  File "/Users/binbin/Towhee_projects/towhee-test-env-3.8/lib/python3.8/site-packages/towhee/engine/operator_runner/runner_base.py", line 220, in join
    self._end_event.wait()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/threading.py", line 558, in wait
    signaled = self._cond.wait(timeout)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/threading.py", line 302, in wait

Closing comment (2022-02-28T19:30:22Z): I believe it is similar to #679 . There is an error loading in the model that was supposed to be downloaded. Ill look into adding an error message within the operator.