centroids-reid icon indicating copy to clipboard operation
centroids-reid copied to clipboard

Running inference gives AttributeError: Missing attribute "MODEL

Open majrblais opened this issue 2 years ago • 5 comments

(centro) [user@remote centroids-reid]$ python inference/create_embeddings.py --config_file="configs/256_resnet50.yml" GPU_IDS [1] DATASETS.ROOT_DIR './test/probe/' TEST.IMS_PER_BATCH 128 OUTPUT_DIR './output-dir' TEST.ONLY_TEST True MODEL.PRETRAIN_PATH './logs/market1501/256_resnet50/train_ctl_model/version_0/auto_checkpoints/resnet50-19c8e357.pth'

INFO:main:Preparing data using <class 'inference_utils.ImageDataset'> dataset class ./test/probe/ 8 ['./test/probe/ursula.jpg', './test/probe/angela.jpg', './test/probe/charles.jpg', './test/probe/biden.jpg', './test/probe/Yoshi.jpg', './test/probe/justin.jpg', './test/probe/macron.jpg', './test/probe/boris.jpg'] Traceback (most recent call last): File "/home/user/anaconda3/envs/centro/lib/python3.7/site-packages/pytorch_lightning/utilities/parsing.py", line 184, in getattr return self[key] KeyError: 'MODEL'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "inference/create_embeddings.py", line 76, in model = CTLModel.load_from_checkpoint(cfg.MODEL.PRETRAIN_PATH) File "/home/user/anaconda3/envs/centro/lib/python3.7/site-packages/pytorch_lightning/core/saving.py", line 158, in load_from_checkpoint model = cls._load_model_state(checkpoint, strict=strict, kwargs) File "/home/user/anaconda3/envs/centro/lib/python3.7/site-packages/pytorch_lightning/core/saving.py", line 198, in _load_model_state model = cls(_cls_kwargs) File "./train_ctl_model.py", line 29, in init super().init(cfg, **kwargs) File "./modelling/bases.py", line 70, in init self.backbone = Baseline(self.hparams) File "./modelling/baseline.py", line 50, in init last_stride = cfg.MODEL.LAST_STRIDE File "/home/user/anaconda3/envs/centro/lib/python3.7/site-packages/pytorch_lightning/utilities/parsing.py", line 186, in getattr raise AttributeError(f'Missing attribute "{key}"') from exp AttributeError: Missing attribute "MODEL"

I can run the training but anytime I run any of the inference I receive this error.

majrblais avatar May 31 '22 20:05 majrblais

That sounds very logical. I'm curious to check if the response from Amazon is causing this or if it is the XML to JSON that is causing this issue. It sounds like you are saying XML to JSON is the culprit. In any case, normalizing it sounds like a great idea. I probably won't get around to this soon. Feel free to submit a PR if you want it done soon.

On Thu, Nov 30, 2017 at 9:57 PM rmzg [email protected] wrote:

A problem I frequently run into is when the value of a given key somewhat randomly switches between an array value and an object value. In my most recent they key is the ItemLookupResponse.Items.Item which sometimes contains an array and sometimes contains a single object which tends to cause errors like TypeError: Cannot read property 'length' of undefined.

Obviously the reason why it switches is because sometimes there's multiple values and sometimes there's a single value, which is why you can't use a generic function to translate XML in to JSON since they're not the same type of structure.

This can be worked around in the requiring code with some annoyance but would make for much simpler code if it was fixed in the library code, which in this case means that Items.Item should always be an array.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dmcquay/node-apac/issues/91, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHIcS34oTn-SJAHji40e-R_V22Dx44Tks5s74c3gaJpZM4Qx3lM .

dmcquay avatar Dec 01 '17 07:12 dmcquay

Obviously it's the xml2js library doing it since you can't actually convert XML to JSON without throwing away a lot of the XML data. This is one of the most basic reasons to not use a generic converter.

rmzg avatar Dec 17 '17 00:12 rmzg

It's not due to this option? `const xml2js = require('xml2js')

const defaultXml2JsOptions = { explicitArray: false }`

jaribu avatar Jan 18 '18 13:01 jaribu

How can I change this just for test ?

jaribu avatar Feb 19 '18 14:02 jaribu

Change what?

rmzg avatar Feb 19 '18 22:02 rmzg

explicitArray: false to true

jaribu avatar Feb 20 '18 12:02 jaribu