-
Notifications
You must be signed in to change notification settings - Fork 4
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
路径相关的问题 #1
Comments
@diehualong 上图是在windows电脑上将高光谱变成三波段图像保存到hanchuan_15文件夹,下图是在Linux服务器上读取文件夹中的图片,为了与原有高光谱数据集区分,该hanchuan_15文件夹放在whu_hi新建的whuhi_image_2percent文件夹下 |
作者您好。我在调试训练的时候,出现了whuhi_image_2percent文件夹。文件夹里的图片怎么获取呢?是否可以提供完整的源代码? |
@19979548798 注释掉,DCN-T用不到这俩 |
@19979548798 请问这是哪个文件里边的? |
@19979548798 第一张图,你把WHU-Hi数据集下下来看看他的文件夹结构就知道了; 第二、三张图,swin这个模型代码应该是从我们其他用了mmseg, mmcv系列的项目中拿过来的,而我的项目都共用一套环境,所以可能我没发现报错,这个解决方法有两种,第一种是你参考一下我github首页这几个跟遥感大模型相关的仓库,就知道mmcv和mmseg怎么用了,第二种是,load_checkpoint其实和torch.load是一个意思,这部分代码你重构一下 |
|
@19979548798 可以参考一下swin.py def init_weights(self, pretrained):
ckpt = torch.load(pretrained, map_location='cpu')
if 'state_dict' in ckpt:
_state_dict = ckpt['state_dict']
elif 'model' in ckpt:
_state_dict = ckpt['model']
else:
_state_dict = ckpt
state_dict = OrderedDict()
for k, v in _state_dict.items():
if k.startswith('backbone.'):
state_dict[k[9:]] = v
else:
state_dict[k] = v
# strip prefix of state_dict
if list(state_dict.keys())[0].startswith('module.'):
state_dict = {k[7:]: v for k, v in state_dict.items()}
# reshape absolute position embedding
if state_dict.get('absolute_pos_embed') is not None:
absolute_pos_embed = state_dict['absolute_pos_embed']
N1, L, C1 = absolute_pos_embed.size()
N2, C2, H, W = self.absolute_pos_embed.size()
if N1 != N2 or C1 != C2 or L != H * W:
warnings.warn('Error in loading absolute_pos_embed, pass')
else:
state_dict['absolute_pos_embed'] = absolute_pos_embed.view(
N2, H, W, C2).permute(0, 3, 1, 2).contiguous()
# interpolate position bias table if needed
relative_position_bias_table_keys = [
k for k in state_dict.keys()
if 'relative_position_bias_table' in k
]
for table_key in relative_position_bias_table_keys:
table_pretrained = state_dict[table_key]
table_current = self.state_dict()[table_key]
L1, nH1 = table_pretrained.size()
L2, nH2 = table_current.size()
if nH1 != nH2:
warnings.warn(f'Error in loading {table_key}, pass')
elif L1 != L2:
S1 = int(L1**0.5)
S2 = int(L2**0.5)
table_pretrained_resized = F.interpolate(
table_pretrained.permute(1, 0).reshape(1, nH1, S1, S1),
size=(S2, S2),
mode='bicubic')
state_dict[table_key] = table_pretrained_resized.view(
nH2, L2).permute(1, 0).contiguous()
# print('##############')
# print(self.state_dict().keys())
# print('$$$$$$$$$$$$$$')
# print(state_dict.keys())
# load state_dict
msg = self.load_state_dict(state_dict, False)
print(msg) |
@19979548798 。。你看论文了吗,将高光谱数据集转换成RGB图像是我们的创新点之一,原始WHU-Hi当然没有,这部分代码我放在jupyter notebook里了,你看看readme |
@19979548798 |
作者您好。我在阅读代码的过程中,发现处理数据集后保存的文件夹名称是hanchuan_15等。如下图所示。
但是,在训练部分代码中,读取数据集的路径中出现了一个whuhi_image_2percent的文件夹,这个文件夹是怎么得到的呢?
The text was updated successfully, but these errors were encountered: