towhee-io / towhee

Towhee is a framework that is dedicated to making neural data processing pipelines simple and fast.
https://towhee.io
Apache License 2.0
3.2k stars 247 forks source link

[Bug]: ModuleNotFoundError: No module named 'parse_config' for video-text-embedding with collaborative-experts #1609

Closed binbinlv closed 2 years ago

binbinlv commented 2 years ago

Is there an existing issue for this?

Current Behavior

>>> towhee.dc([Entity(experts=experts, ind=ind, text=text)]) \
...     .video_text_embedding.collaborative_experts[('experts', 'ind', 'text'), ('text_embds', 'vid_embds')]().show()
huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
To disable this warning, you can either:
    - Avoid using `tokenizers` before the fork if possible
    - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
Cloning the repo: video-text-embedding/collaborative-experts... Be patient and waiting printing 'Successfully'.
huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
To disable this warning, you can either:
    - Avoid using `tokenizers` before the fork if possible
    - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
...
Successfully clone the repo: video-text-embedding/collaborative-experts.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/towhee/hparam/hyperparameter.py", line 198, in __call__
    return self._func(*args, **kws)
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/towhee/functional/data_collection.py", line 156, in wrapper
    return self.map(op)
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/towhee/functional/mixins/dag.py", line 11, in wrapper
    children = f(self, *arg, **kws)
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/towhee/functional/data_collection.py", line 315, in map
    if hasattr(unary_op, 'is_stateful') and unary_op.is_stateful:
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/towhee/engine/execution/stateful_execution.py", line 30, in is_stateful
    self.__check_init__()
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/towhee/engine/factory.py", line 93, in __check_init__
    self._op = op(self._name,
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/towhee/engine/factory.py", line 61, in op
    return loader.load_operator(operator_src, arg, kwargs, tag)
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/towhee/engine/operator_loader.py", line 162, in load_operator
    op = factory(function, arg, kws, tag)
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/towhee/engine/operator_loader.py", line 141, in load_operator_from_cache
    return self.load_operator_from_path(path, arg, kws)
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/towhee/engine/operator_loader.py", line 127, in load_operator_from_path
    return self.instance_operator(op, arg, kws) if op is not None else None
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/towhee/engine/operator_loader.py", line 172, in instance_operator
    return op(*arg, **kws) if kws is not None else op()
  File "/Users/binbin/.towhee/operators/video-text-embedding/collaborative_experts/main/collaborative_experts.py", line 38, in __init__
    self.ce_net_model = collaborative_experts.create_model(config, weights_path, device)
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/towhee/models/collaborative_experts/collaborative_experts.py", line 1242, in create_model
    checkpoint = torch.load(weights_path, map_location="cpu")
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/torch/serialization.py", line 713, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/torch/serialization.py", line 930, in _legacy_load
    result = unpickler.load()
  File "/Users/binbin/towhee-test-env-3.8-0.7.3/lib/python3.8/site-packages/torch/serialization.py", line 746, in find_class
    return super().find_class(mod_name, name)
ModuleNotFoundError: No module named 'parse_config'

Expected Behavior

No error

Steps To Reproduce

https://towhee.io/video-text-embedding/collaborative-experts

import torch
from towhee import Entity
import towhee

torch.manual_seed(42)

batch_size = 8
experts = {"audio": torch.rand(batch_size, 29, 128),
           "face": torch.rand(batch_size, 512),
           "i3d.i3d.0": torch.rand(batch_size, 1024),
           "imagenet.resnext101_32x48d.0": torch.rand(batch_size, 2048),
           "imagenet.senet154.0": torch.rand(batch_size, 2048),
           "ocr": torch.rand(batch_size, 49, 300),
           "r2p1d.r2p1d-ig65m.0": torch.rand(batch_size, 512),
           "scene.densenet161.0": torch.rand(batch_size, 2208),
           "speech": torch.rand(batch_size, 32, 300)
           }
ind = {
    "r2p1d.r2p1d-ig65m.0": torch.ones(batch_size,),
    "imagenet.senet154.0": torch.ones(batch_size,),
    "imagenet.resnext101_32x48d.0": torch.ones(batch_size,),
    "scene.densenet161.0": torch.ones(batch_size,),
    "audio": torch.ones(batch_size,),
    "speech": torch.ones(batch_size,),
    "ocr": torch.randint(low=0, high=2, size=(batch_size,)),
    "face": torch.randint(low=0, high=2, size=(batch_size,)),
    "i3d.i3d.0": torch.ones(batch_size,),
}

text = torch.randn(batch_size, 1, 37, 768)

towhee.dc([Entity(experts=experts, ind=ind, text=text)]) \
    .video_text_embedding.collaborative_experts[('experts', 'ind', 'text'), ('text_embds', 'vid_embds')]().show()

Environment

- Towhee version(e.g. v0.1.3 or 8b23a93):towhee 0.7.3.dev32 (models latest)
- OS(Ubuntu or CentOS):
- CPU/Memory:
- GPU:
- Others:

Anything else?

No response

binbinlv commented 2 years ago

@zc277584121 what is the progress now?

zc277584121 commented 2 years ago

It's caused by a pytorch issue: https://github.com/pytorch/pytorch/issues/3678

zc277584121 commented 2 years ago

I have updated this model to avoid this problem.

binbinlv commented 2 years ago

Fixed,so close it.

>>> towhee.dc([Entity(experts=experts, ind=ind, text=text)]) \
...     .video_text_embedding.collaborative_experts[('experts', 'ind', 'text'), ('text_embds', 'vid_embds')]().show()
...
<IPython.core.display.HTML object>