hustvl / EVA-X

[arXiv'24] EVA-X: A foundation model for general chest X-ray analysis with self-supervised learning
47 stars 1 forks source link

'EVA_X' object has no attribute '_pos_embed' #1

Open 972497768 opened 6 months ago

972497768 commented 6 months ago

When I run the eva_x_tiny_patch16() model, the following error occurs:

'EVA_X' object has no attribute '_pos_embed' File "F:\networks\eva.py", line 106, in forward_features x, rot_pos_embed = self._pos_embed(x) File "F:\networks\eva.py", line 124, in forward x = self.forward_features(x) File "F:\networks\eva.py", line 201, in summary(net, (3, 224,224))

Ambitious-idiot commented 6 months ago

Hi, thank you for submitting the issue.

This issue may be due to not following the installation steps provided in README. Please ensure that you have correctly installed all the necessary dependencies. If you still encounter the issue after installation, please provide more detailed information, such as code snippets and the full error log, so we can help you troubleshoot further.

njan-creative commented 1 month ago

Can you provide a colab with an example inference on an image.

A-Big-Brain commented 3 weeks ago

I have installed the timm package, but I also get this error. The following is my test code. Thank you!

import torch from support_EVAX import eva_x_tiny_patch16, eva_x_small_patch16, eva_x_base_patch16

eva_x_ti_pt = '../pretrained_weights/eva_x_tiny_patch16_merged520k_mim.pt' model = eva_x_tiny_patch16(pretrained=eva_x_ti_pt)

img = torch.rand(10, 3, 224, 224)

y = model(img)

A-Big-Brain commented 3 weeks ago

The following is the error information.

D:\ProgramData\anaconda3\envs\py311_torch\Lib\site-packages\torch\functional.py:513: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at C:\cb\pytorch_1000000000000\work\aten\src\ATen\native\TensorShape.cpp:3610.) return _VF.meshgrid(tensors, kwargs) # type: ignore[attr-defined] F:\Project02_pneumonia\Model\model04_EVAX\EVA-X-main\support_EVAX.py:134: FutureWarning: You are using torch.load with weights_only=False (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only will be flipped to True. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=True for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. eva_ckpt = checkpoint_filter_fn(torch.load(pretrained, map_location='cpu'), _IncompatibleKeys(missing_keys=['head.weight', 'head.bias'], unexpected_keys=[]) Traceback (most recent call last): File "D:\ProgramData\anaconda3\envs\py311_torch\Lib\site-packages\IPython\core\interactiveshell.py", line 3577, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in runfile('F:\Project02_pneumonia\Model\model04_EVAX\EVA-X-main\AA99_01_test.py', wdir='F:\Project02_pneumonia\Model\model04_EVAX\EVA-X-main') File "D:\Program Files\JetBrains\PyCharm 2024.2.1\plugins\python-ce\helpers\pydev_pydev_bundle\pydev_umd.py", line 197, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Program Files\JetBrains\PyCharm 2024.2.1\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "F:\Project02_pneumonia\Model\model04_EVAX\EVA-X-main\AA99_01_test.py", line 9, in y = model(img) ^^^^^^^^^^ File "D:\ProgramData\anaconda3\envs\py311_torch\Lib\site-packages\torch\nn\modules\module.py", line 1553, in _wrapped_call_impl return self._call_impl(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ProgramData\anaconda3\envs\py311_torch\Lib\site-packages\torch\nn\modules\module.py", line 1562, in _call_impl return forward_call(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\Project02_pneumonia\Model\model04_EVAX\EVA-X-main\support_EVAX.py", line 118, in forward x = self.forward_features(x) ^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\Project02_pneumonia\Model\model04_EVAX\EVA-X-main\support_EVAX.py", line 104, in forward_features x, rot_pos_embed = self._pos_embed(x) ^^^^^^^^^^^^^^^ File "D:\ProgramData\anaconda3\envs\py311_torch\Lib\site-packages\torch\nn\modules\module.py", line 1729, in getattr raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'") AttributeError: 'EVA_X' object has no attribute '_pos_embed'