Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Running operator failed for reporting lots of modules are not found in clean env #1450

Open
1 task done
binbinlv opened this issue Jun 22, 2022 · 2 comments
Open
1 task done
Assignees
Labels
kind/bug Issues or changes related a bug priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now.
Milestone

Comments

@binbinlv
Copy link
Contributor

binbinlv commented Jun 22, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Running operator failed for reporting lots of modules are not found, like:
pkg_resources.DistributionNotFound: The 'av' distribution was not found and is required by the application
pkg_resources.DistributionNotFound: The 'opencv-python' distribution was not found and is required by the application
......

Expected Behavior

No errors

Steps To Reproduce

For example: Running the following script

import logging
import os
import time
import subprocess
from towhee import ops

logger = logging.getLogger()
log_path = 'action_classification.log'

# Test action-classification operators
action_classification = {
    'pytorchvideo': [
        {'model_name': 'c2d_r50'},
        {'model_name': 'i3d_r50'},
        {'model_name': 'slow_r50'},
        {'model_name': 'slowfast_r50'},
        {'model_name': 'slowfast_r101'},
        {'model_name': 'x3d_xs'},
        {'model_name': 'x3d_s'},
        {'model_name': 'x3d_m'},
        {'model_name': 'mvit_base_16x4'},
        {'model_name': 'mvit_base_32x3'},
    ],
    'actionclip': [
        {'model_name': 'clip_vit_b16'},
        {'model_name': 'clip_vit_b32'}
    ],
    'timesformer': [
        {'model_name': 'timesformer_k400_8x224'}
    ]
}


def test(data_path):
    if not os.path.isfile(data_path):
        subprocess.call(
            f'wget -O {data_path} https://dl.fbaipublicfiles.com/pytorchvideo/projects/archery.mp4',
            shell=True
        )

    video_decoder = ops.video_decode.ffmpeg()
    # Since the video_decoder returns generator, need to extract output from generator for repetitive usage
    input_data = [x for x in video_decoder(data_path)]
    handler = logging.FileHandler(log_path)
    logger.addHandler(handler)

    for k, v in action_classification.items():
        init_op = getattr(ops.action_classification, k)
        for args in v:
            try:
                op = init_op(**args)
                outs = op(input_data)
                assert outs[0][0] == 'archery'
                assert len(outs[1]) == 5
                assert outs[2].shape[0] > 0
                print('Success:', k, str(args))
                logger.info('Success %s - %s', k, str(args))
            except Exception as e:
                logger.error('Fail to run %s - %s', k, str(args))
                print(f'ERROR MESSAGE: {e}')
                pass
            time.sleep(5)
    print('Finished.')

if __name__ == '__main__':
    test('./archery.mp4')

Environment

- Towhee version(e.g. v0.1.3 or 8b23a93): latest pre-0.7
- OS(Ubuntu or CentOS):
- CPU/Memory:
- GPU:
- Others:

Anything else?

No response

@binbinlv binbinlv added kind/bug Issues or changes related a bug priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. labels Jun 22, 2022
@binbinlv binbinlv added this to the 0.7 milestone Jun 22, 2022
@binbinlv
Copy link
Contributor Author

I think this maybe for the fix for issue #1433.

@binbinlv
Copy link
Contributor Author

binbinlv commented Jun 23, 2022

Test it again, it is good in clean python env and clean cache. And this issue will occur when the cache for python3.8 is not be cleaned and when installing towhee in python 3.7, this is compatibility issue which will be fixed in next release. (#1452)

And the workaround is clean the cache when you want to use new python version and new env.

@binbinlv binbinlv modified the milestones: 0.7, 1.0-Backlog Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Issues or changes related a bug priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now.
Projects
None yet
Development

No branches or pull requests

2 participants