MasterBin-IIAU / Unicorn

[ECCV'22 Oral] Towards Grand Unification of Object Tracking
MIT License
953 stars 87 forks source link

Exception has occurred: RuntimeError YOU HAVE NOT SETUP YOUR local.py!!! #23

Closed blxie closed 2 years ago

blxie commented 2 years ago

It is a very nice working. When I try to reproduce this work, I encountered this problem. I'm tired of this. It is very annoying!!! Hope author give me a favor, thanks a lot!!!

Background: Test SOT on LaSOT.

blxie commented 2 years ago
Exception has occurred: RuntimeError
YOU HAVE NOT SETUP YOUR local.py!!!
 Go to "/data/users/proj/Unicorn/tools/../external/lib/test/evaluation/local.py" and set all the paths you need. Then try to run again.

During handling of the above exception, another exception occurred:

  File "/data/users/proj/Unicorn/external/lib/test/evaluation/environment.py", line 125, in env_settings
    env_module = importlib.import_module(env_module_name)
  File "/data/users/proj/Unicorn/external/lib/test/evaluation/local.py", line 1, in <module>
    from test.evaluation.environment import EnvSettings

During handling of the above exception, another exception occurred:

  File "/data/users/proj/Unicorn/external/lib/test/evaluation/environment.py", line 132, in env_settings
    raise RuntimeError(
  File "/data/users/proj/Unicorn/external/lib/test/evaluation/data.py", line 11, in __init__
    self.env_settings = env_settings()
  File "/data/users/proj/Unicorn/external/lib/test/evaluation/lasotdataset.py", line 20, in __init__
    super().__init__()
  File "/data/users/proj/Unicorn/external/lib/test/evaluation/datasets.py", line 58, in load_dataset
    dataset = getattr(
  File "/data/users/proj/Unicorn/external/lib/test/evaluation/datasets.py", line 68, in get_dataset
    dset.extend(load_dataset(name))
  File "/data/users/XieBailian/proj/Unicorn/tools/test.py", line 33, in run_tracker
    dataset = get_dataset(dataset_name)
  File "/data/users/proj/Unicorn/tools/test.py", line 75, in main
    run_tracker(args.tracker_name,
  File "/data/users/proj/Unicorn/tools/test.py", line 86, in <module>
    main()

debug,

env_module = importlib.import_module(env_module_name)
Traceback (most recent call last):
  File "/data/users/proj/Unicorn/tools/../external/lib/test/evaluation/local.py", line 1, in <module>
    from test.evaluation.environment import EnvSettings
ModuleNotFoundError: No module named 'test.evaluation'; 'test' is not a package
MasterBin-IIAU commented 2 years ago

@blxie Hi, could you please provide more details? For example, how did you run the project?

blxie commented 2 years ago

Thanks for your reply!!! I just run as the .md file. Here is my running cmd.

python3 tools/test.py unicorn_sot unicorn_track_tiny_mask --dataset lasot --threads 0

I use vscode debug, still cannot find the reason.

importlib — The implementation of import — Python 3.10.6 documentation image

It seems the program cannot correctly load the local.py dynamiclly created.

I have tried use the aforementioned solution, it doesnot work.

def env_settings():
    env_module_name = 'lib.test.evaluation.local'

    # try:
    #     importlib.invalidate_caches()
    #     env_module = importlib.import_module(env_module_name)
    #     return env_module.local_env_settings()
    # except:
    #     env_file = os.path.join(os.path.dirname(__file__), 'local.py')

    #     # Create a default file
    #     create_default_local_file()
    #     raise RuntimeError(
    #         'YOU HAVE NOT SETUP YOUR local.py!!!\n Go to "{}" and set all the paths you need. '
    #         'Then try to run again.'.format(env_file))

    spec = importlib.util.find_spec(env_module_name)

    if spec is None:
        print(f"can't find the {env_module_name} module")
        env_file = os.path.join(os.path.dirname(__file__), 'local.py')

        # Create a default file
        create_default_local_file()
        raise RuntimeError(
            'YOU HAVE NOT SETUP YOUR local.py!!!\n Go to "{}" and set all the paths you need. '
            'Then try to run again.'.format(env_file))

    else:
        # If you chose to perform the actual import ...
        env_module = importlib.util.module_from_spec(spec)
        # Adding the module to sys.modules is optional.
        import sys
        sys.modules[env_module_name] = env_module

        return env_module.local_env_settings()

Then I get another error,

Exception has occurred: AttributeError
module 'lib.test.evaluation.local' has no attribute 'local_env_settings'
  File "/data/users/proj/Unicorn/external/lib/test/evaluation/environment.py", line 155, in env_settings
    return env_module.local_env_settings()
  File "/data/users/proj/Unicorn/external/lib/test/evaluation/data.py", line 11, in __init__
    self.env_settings = env_settings()
  File "/data/users/proj/Unicorn/external/lib/test/evaluation/lasotdataset.py", line 20, in __init__
    super().__init__()
  File "/data/users/proj/Unicorn/external/lib/test/evaluation/datasets.py", line 58, in load_dataset
    dataset = getattr(
  File "/data/users/proj/Unicorn/external/lib/test/evaluation/datasets.py", line 68, in get_dataset
    dset.extend(load_dataset(name))
  File "/data/users/proj/Unicorn/tools/test.py", line 33, in run_tracker
    dataset = get_dataset(dataset_name)
  File "/data/users/proj/Unicorn/tools/test.py", line 75, in main
    run_tracker(args.tracker_name,
  File "/data/users/proj/Unicorn/tools/test.py", line 86, in <module>
    main()
MasterBin-IIAU commented 2 years ago

@blxie Hi, now we should have fixed this problem. Please use "git pull" to update to the latest version. Besides, there are some extra tips: (1) Now we have disabled the original try ... except ... block in environment.py. Thus the program will not overwrite the original local.py (2) Please double check the installation according to install.md. "YOLOX and some other packages" and "Deformable Attention" are required. (3) Please re-check the latest test.md for more details about using the provided weights.

Thanks for pointing out this potential issue. Good Luck :)

MasterBin-IIAU commented 2 years ago

By the way, now you should use "python3 tools/test.py unicorn_sot unicorn_track_tiny --dataset lasot --threads 0" as the testing command. More explanations can be found in test.md

blxie commented 2 years ago

Awesome! Thanks for your nice working again!!! I will try it later😁

blxie commented 2 years ago

It can run now! Thanks!!! @MasterBin-IIAU

(unicorn) xxx@xxx-server:~/xxx/proj/Unicorn$  cd /home/xxx/xxx/proj/Unicorn ; /usr/bin/env /home/xxx/anaconda3/envs/unicorn/bin/python /home/xxx/.vscode-server/extensions/ms-python.python-2022.12.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 40597 -- tools/test.py unicorn_sot unicorn_track_tiny --dataset lasot --threads 0 
Evaluating    1 trackers on   280 sequences
Tracker: unicorn_sot unicorn_track_tiny None ,  Sequence: airplane-1
Loading weights: /data/users/xxx/proj/Unicorn/datasets/../Unicorn_outputs/unicorn_track_tiny/latest_ckpt.pth
/home/xxx/anaconda3/envs/unicorn/lib/python3.9/site-packages/torch/utils/checkpoint.py:25: UserWarning: None of the inputs have requires_grad=True. Gradients will be None
  warnings.warn("None of the inputs have requires_grad=True. Gradients will be None")
/home/xxx/anaconda3/envs/unicorn/lib/python3.9/site-packages/torch/nn/functional.py:3631: UserWarning: Default upsampling behavior when mode=bicubic is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
  warnings.warn(
/home/xxx/anaconda3/envs/unicorn/lib/python3.9/site-packages/torch/nn/functional.py:3679: UserWarning: The default behavior for interpolate/upsample with float scale_factor changed in 1.6.0 to align with other frameworks/libraries, and now uses scale_factor directly, instead of relying on the computed output size. If you wish to restore the old behavior, please set recompute_scale_factor=True. See the documentation of nn.Upsample for details. 
  warnings.warn(
/home/xxx/anaconda3/envs/unicorn/lib/python3.9/site-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  /opt/conda/conda-bld/pytorch_1639180487213/work/aten/src/ATen/native/TensorShape.cpp:2157.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
FPS: 8.618514548151978
create tracking result dir: /data/users/xxx/proj/Unicorn/datasets/../test/tracking_results/unicorn_sot/unicorn_track_tiny
Tracker: unicorn_sot unicorn_track_tiny None ,  Sequence: airplane-9
Loading weights: /data/users/xxx/proj/Unicorn/datasets/../Unicorn_outputs/unicorn_track_tiny/latest_ckpt.pth