elias-ramzi / HAPPIER

This repo contains the official implementation of HAPPIER: Hierarchical Average Precision Training for Pertinent Image Retrieval (ECCV'22).
https://arxiv.org/abs/2207.04873
MIT License
21 stars 4 forks source link

AttributeError: 'NoneType' object has no attribute 'tb_lasti' #8

Closed Nicole998 closed 8 months ago

Nicole998 commented 9 months ago

Hi,Hello, I'm sorry to bother you, but I encountered an error while running run.py. I haven't changed any part of the code. When I tried to run the code"CUDA_VISIBLE_DEVICES='0' python happier/run.py", I had an error and the full traceback is as follows. Traceback (most recent call last): File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/hydra/_internal/utils.py", line 211, in run_and_report return func() File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/hydra/_internal/utils.py", line 368, in lambda: hydra.run( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/hydra/_internal/hydra.py", line 97, in run ret = run_job( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/hydra/core/utils.py", line 122, in run_job working_dir = str(OmegaConf.select(config, job_dir_key)) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/omegaconf.py", line 691, in select format_and_raise(node=cfg, key=key, value=None, cause=e, msg=str(e)) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/_utils.py", line 818, in format_and_raise _raise(ex, cause) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/_utils.py", line 716, in _raise raise ex.with_traceback(sys.exc_info()[2]) # set end OC_CAUSE=1 for full backtrace File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/omegaconf.py", line 683, in select return select_value( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/_impl.py", line 58, in select_value node = select_node( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/_impl.py", line 93, in select_node _root, _last_key, node = cfg._select_impl( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/base.py", line 429, in _select_impl value = root._maybe_resolve_interpolation( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/base.py", line 616, in _maybe_resolve_interpolation return self._resolve_interpolation_from_parse_tree( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/base.py", line 482, in _resolve_interpolation_from_parse_tree resolved = self.resolve_parse_tree( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/base.py", line 662, in resolve_parse_tree return visitor.visit(parse_tree) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/antlr4/tree/Tree.py", line 34, in visit return tree.accept(self) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/grammar/gen/OmegaConfGrammarParser.py", line 205, in accept return visitor.visitConfigValue(self) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/grammar_visitor.py", line 101, in visitConfigValue return self.visit(ctx.getChild(0)) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/antlr4/tree/Tree.py", line 34, in visit return tree.accept(self) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/grammar/gen/OmegaConfGrammarParser.py", line 339, in accept return visitor.visitText(self) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/grammar_visitor.py", line 301, in visitText return self._unescape(list(ctx.getChildren())) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/grammar_visitor.py", line 389, in _unescape text = str(self.visitInterpolation(node)) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/grammar_visitor.py", line 125, in visitInterpolation return self.visit(ctx.getChild(0)) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/antlr4/tree/Tree.py", line 34, in visit return tree.accept(self) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/grammar/gen/OmegaConfGrammarParser.py", line 911, in accept return visitor.visitInterpolationNode(self) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/grammar_visitor.py", line 158, in visitInterpolationNode return self.node_interpolation_callback(inter_key, self.memo) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/base.py", line 643, in node_interpolation_callback return self._resolve_node_interpolation(inter_key=inter_key, memo=memo) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/base.py", line 568, in _resolve_node_interpolation raise InterpolationToMissingValueError( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/base.py", line 561, in _resolve_node_interpolation parent, last_key, value = root_node._select_impl( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/base.py", line 412, in _selectimpl value, = _select_one( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/omegaconf/omegaconf.py", line 1087, in _select_one raise MissingMandatoryValue( omegaconf.errors.InterpolationToMissingValueError: MissingMandatoryValue while resolving interpolation: Missing mandatory value: experience.experiment_name full_key: hydra.run.dir object_type=dict During handling of the above exception, another exception occurred: Traceback (most recent call last): File "happier/run.py", line 172, in run() File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/hydra/main.py", line 49, in decorated_main _run_hydra( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/hydra/_internal/utils.py", line 367, in _run_hydra run_and_report( File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/hydra/_internal/utils.py", line 270, in run_and_report cur.tb_lasti = iter_tb.tb_lasti AttributeError: 'NoneType' object has no attribute 'tb_lasti'

I only changed the path data(data_dir) of sop. yaml in the code, nothing else has changed Could you please give some advice on how to fix this error?Thanks!

elias-ramzi commented 9 months ago

Hi, thank you for your message.

You need to provide an experiment_name in order to launch the code.

In your case, this would give:

CUDA_VISIBLE_DEVICES='0' python happier/run.py experience.experiment_name=test

Hope this helps. Do not hesitate to repost a comment if it still does not work.

Nicole998 commented 9 months ago

Oh,thanks for your reply! I have run the "CUDA_VISIBLE-DEVICES='0 'Python shipper/run. py experience. experiencename=test", but received a warning:

[2024-01-09 21:40:52,761][HAPPIER][WARNING] - Exiting trial, experiment test already exists[2024-01-09 21:40:52,762][HAPPIER][WARNING] - Its access: /share/DEEPLEARNING/datasets/image_retrieval/experiments/test

May I ask if it is necessary to modify the path? In this experiment, which paths need to be modified, such as what are the contents stored in ''/local/DEEPLEARNING/image_retrieval'' and path'/share/DEEPLEARNING/datasets/image_retrieval' respectively?

elias-ramzi commented 9 months ago

Yes, indeed you should modify some paths:

CUDA_VISIBLE_DEVICES='0' python happier/run.py \
'experience.experiment_name=test' \
'experience.log_dir=experiments/HAPPIER' \
'dataset.kwargs.data_dir=/path/to/data/'

The warning is because an experiment with the same name has already been launched.

Nicole998 commented 9 months ago

Thank you so much!I have solved this problem.

Nicole998 commented 9 months ago

I'm sorry to bother you again. After running the run. py file, the information in the run. log is [2024-01-13 17:24:28,164][HAPPIER][INFO] - Training with seed 0 [2024-01-13 17:24:28,167][HAPPIER][INFO] - Compose( Resize(size=256, interpolation=bilinear) RandomResizedCrop(size=(224, 224), scale=(0.16, 1), ratio=(0.75, 1.33), interpolation=bilinear) RandomHorizontalFlip(p=0.5) ToTensor() Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) ) [2024-01-13 17:24:28,167][HAPPIER][INFO] - Compose( Resize(size=[256, 256], interpolation=bilinear) CenterCrop(size=(224, 224)) ToTensor() Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) ) . Does this indicate that the model ran successfully? And I encountered an error while running CUDA_VISIBLE_DEVICES='0' python happier/evaluate.py --config \happier/config/default.yaml, with the error message being 01/13/2024 06:09:07 PM - INFO - Evaluating : happier/config/default.yaml Traceback (most recent call last): File "happier/evaluate.py", line 153, in <module> metrics = load_and_evaluate( File "happier/evaluate.py", line 44, in load_and_evaluate state = torch.load(lib.expand_path(path), map_location='cpu') File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/torch/serialization.py", line 593, in load return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args) File "/root/autodl-tmp/metric/.venv/lib/python3.8/site-packages/torch/serialization.py", line 762, in _legacy_load magic_number = pickle_module.load(f, **pickle_load_args) _pickle.UnpicklingError: could not find MARK Could you please give me some advice on how to fix this error?Thanks!

elias-ramzi commented 9 months ago

I am not sure about this one.

Maybe this can help:

https://stackoverflow.com/questions/35879096/pickle-unpicklingerror-could-not-find-mark