WhoTHU / Adversarial_camou

21 stars 2 forks source link

AttributeError: 'PatchTrainer' object has no attribute 'seeds_tshirt'` #8

Open wang1528186571 opened 1 month ago

wang1528186571 commented 1 month ago

When i run "Visualize-Shirts.py" One training epoch has 376 images One test epoch has 130 images /home/wang/Anaconda3/envs/camou/lib/python3.8/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3190.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] max range is 19.587, max number of the bins is 461 max range is 6.927, max number of the bins is 202 Traceback (most recent call last): File "/home/wang/Desktop/wjl-project/Adversarial_camou-main/Visualize-Shirts.py", line 43, in <module> tex,tex_trouser = trainer.update_mesh(type='determinate') File "/home/wang/Desktop/wjl-project/Adversarial_camou-main/train.py", line 350, in update_mesh gb_tshirt = -(-(self.seeds_tshirt + 1e-20).log() + 1e-20).log() AttributeError: 'PatchTrainer' object has no attribute 'seeds_tshirt'

下面是train中的代码, def update_mesh(self, tau=0.3, type='gumbel'):

camouflage:

    prob_map = prob_fix_color(self.tshirt_point, self.coordinates, self.colors, self.h, self.w, blur=self.args.blur).unsqueeze(0)
    prob_trouser = prob_fix_color(self.trouser_point, self.coordinates_t, self.colors, self.h_t, self.w_t, blur=self.args.blur).unsqueeze(0)
    prob_map = self.camouflage_kernel(prob_map)
    prob_trouser = self.camouflage_kernel(prob_trouser)
    prob_map = prob_map.squeeze(0).permute(1, 2, 0)
    prob_trouser = prob_trouser.squeeze(0).permute(1, 2, 0)

    gb_tshirt = -(-(self.seeds_tshirt + 1e-20).log() + 1e-20).log()
    gb_trouser = -(-(self.seeds_trouser + 1e-20).log() + 1e-20).log()

    tex = gumbel_color_fix_seed(prob_map, gb_tshirt, self.colors, tau=tau, type=type)
    tex_trouser = gumbel_color_fix_seed(prob_trouser, gb_trouser, self.colors, tau=tau, type=type)

    tex = self.expand_kernel(self.color_transform(tex.permute(0, 3, 1, 2))).permute(0, 2, 3, 1)
    tex_trouser = self.expand_kernel(self.color_transform(tex_trouser.permute(0, 3, 1, 2))).permute(0, 2, 3, 1)

    self.mesh_tshirt.textures = TexturesUV(maps=tex, faces_uvs=self.faces, verts_uvs=self.verts_uv)
    self.mesh_trouser.textures = TexturesUV(maps=tex_trouser, faces_uvs=self.faces_trouser, verts_uvs=self.verts_uv_trouser)

    return tex, tex_trouser

我不知道问题出在哪个地方

WhoTHU commented 1 month ago

这个看起来是您没有按照train.py的代码来跑,也许是没有初始化PatchTrainer

wang1528186571 commented 1 month ago

这个看起来是您没有按照train.py的代码来跑,也许是没有初始化PatchTrainer

非常感谢你的回复,我用GPT写一个初始化就可以吗?还是用您项目里的代码

WhoTHU commented 1 month ago

请用项目里的代码

wang1528186571 commented 1 month ago

请用项目里的代码

非常感谢 我刚才又重新下载了代码 跑了一遍可能是刚开始跑代码的时候动了一些代码 现在已经可以正常运行了