cuiaiyu / dressing-in-order

(ICCV'21) Official code of "Dressing in Order: Recurrent Person Image Generation for Pose Transfer, Virtual Try-on and Outfit Editing" by Aiyu Cui, Daniel McKee and Svetlana Lazebnik
https://cuiaiyu.github.io/dressing-in-order
Other
513 stars 127 forks source link

All sections below Setup produce errors in the demo #18

Closed AhmedHashish123 closed 2 years ago

AhmedHashish123 commented 2 years ago

Hello, I have reached the sections below "Setup" in the demo, but they produce an error when I try to run them.

"Pose Transfer" produces the following: TypeError Traceback (most recent call last)

in () 5 # generate 6 pimg, gimgs, oimgs, gen_img, pose = dress_in_order(model, pid, pose_id=pose_id) ----> 7 plot_img(pimg, gimgs, oimgs, gen_img, pose) in plot_img(pimg, gimgs, oimgs, gen_img, pose) 41 42 def plot_img(pimg=[], gimgs=[], oimgs=[], gen_img=[], pose=None): ---> 43 if pose != None: 44 import utils.pose_utils as pose_utils 45 print(pose.size()) TypeError: ne() received an invalid combination of arguments - got (NoneType), but expected one of: * (Tensor other) didn't match because some of the arguments have invalid types: (!NoneType!) * (Number other) didn't match because some of the arguments have invalid types: (!NoneType!) "Try-On: Tucking in" produces the following: RuntimeError Traceback (most recent call last) in () 6 7 # tuck in (dressing order: hair, top, bottom) ----> 8 pimg, gimgs, oimgs, gen_img, pose = dress_in_order(model, pid, gids=gids, order=[2,5,1]) 9 plot_img(pimg, gimgs, gen_img=gen_img, pose=pose) 10 in dress_in_order(model, pid, pose_id, gids, ogids, order, perturb) 89 seg = model.encode_single_attr(gimg[None], gparse[None], pose[None], to_pose[None], i=gid[2]) 90 gsegs[gid[2]] = seg ---> 91 gimgs += [gimg * (gparse == gid[2])] 92 93 # encode garment (overlay) RuntimeError: expected type torch.cuda.FloatTensor but got torch.cuda.ByteTensor "Layering - Single (dress in order)" produces the following error: RuntimeError Traceback (most recent call last) in () 2 ogids = [('print', 2, 5)] 3 # tuck in ----> 4 pimg, gimgs, oimgs, gen_img, pose = dress_in_order(model, pid, ogids=ogids) 5 plot_img(pimg, gimgs, oimgs, gen_img, pose) in dress_in_order(model, pid, pose_id, gids, ogids, order, perturb) 97 for gid in ogids: 98 oimg, oparse, pose = load_img(gid, ds) ---> 99 oimgs += [oimg * (oparse == gid[2])] 100 seg = model.encode_single_attr(oimg[None], oparse[None], pose[None], to_pose[None], i=gid[2]) 101 over_gsegs += [seg] RuntimeError: expected type torch.cuda.FloatTensor but got torch.cuda.ByteTensor "Layering - Multiple (dress in order)", "Texture Transfer", "Reshaping", "Content Removal" also produces the similar runtime error, I expect if one of them is fixed, the others will be as well, but I'm not sure what is causing the issue
cuiaiyu commented 2 years ago

Maybe you can run pimg, parse, from_pose = load_img(pid, ds) and print the size and type for pimg, parse, from_pose to first check whether all the data are loaded properly?

AhmedHashish123 commented 2 years ago

pimg size: torch.Size([3, 256, 176]) pimg type<class 'torch.Tensor'> parse size: torch.Size([256, 176]) parse type: <class 'torch.Tensor'> from_pose size: torch.Size([18, 256, 176]) from_pose type: <class 'torch.Tensor'>

I believe the problem with the first error { TypeError: ne() received an invalid combination of arguments - got (NoneType), but expected one of:

(Tensor other) didn't match because some of the arguments have invalid types: (!NoneType!) (Number other) didn't match because some of the arguments have invalid types: (!NoneType!) } is that a tensor is being compared to a None type { if pose != None: }

AhmedHashish123 commented 2 years ago

These are the variables that caused the second error:

gimg: tensor([[[0.7569, 0.7569, 0.7569, ..., 0.6706, 0.6706, 0.6706], [0.7569, 0.7569, 0.7569, ..., 0.6706, 0.6706, 0.6706], [0.7569, 0.7569, 0.7569, ..., 0.6706, 0.6706, 0.6706], ..., [0.7961, 0.7961, 0.7961, ..., 0.7490, 0.7412, 0.7490], [0.7961, 0.7961, 0.7961, ..., 0.7490, 0.7412, 0.7490], [0.7961, 0.7961, 0.7961, ..., 0.7490, 0.7490, 0.7490]],

    [[0.7569, 0.7569, 0.7569,  ..., 0.6863, 0.6863, 0.6863],
     [0.7569, 0.7569, 0.7569,  ..., 0.6863, 0.6863, 0.6863],
     [0.7569, 0.7569, 0.7569,  ..., 0.6863, 0.6863, 0.6863],
     ...,
     [0.7961, 0.7961, 0.7961,  ..., 0.7647, 0.7569, 0.7647],
     [0.7961, 0.7961, 0.7961,  ..., 0.7647, 0.7569, 0.7647],
     [0.7961, 0.7961, 0.7961,  ..., 0.7647, 0.7647, 0.7647]],

    [[0.7569, 0.7569, 0.7412,  ..., 0.6784, 0.6784, 0.6784],
     [0.7569, 0.7569, 0.7412,  ..., 0.6784, 0.6784, 0.6784],
     [0.7569, 0.7569, 0.7412,  ..., 0.6784, 0.6784, 0.6784],
     ...,
     [0.7961, 0.7961, 0.7961,  ..., 0.7569, 0.7490, 0.7569],
     [0.7961, 0.7961, 0.7961,  ..., 0.7569, 0.7490, 0.7569],
     [0.7961, 0.7961, 0.7961,  ..., 0.7569, 0.7569, 0.7569]]],
   device='cuda:0')

gimg type: <class 'torch.Tensor'> gparse: tensor([[0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], ..., [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0]], device='cuda:0', dtype=torch.uint8) gparse type: <class 'torch.Tensor'> gid[2]: 5 gid[2] type: <class 'int'>

The error is in this line: { gimgs += [gimg * (gparse == gid[2])] }

RuntimeError: expected type torch.cuda.FloatTensor but got torch.cuda.ByteTensor

fyviezhao commented 2 years ago

pimg size: torch.Size([3, 256, 176]) pimg type<class 'torch.Tensor'> parse size: torch.Size([256, 176]) parse type: <class 'torch.Tensor'> from_pose size: torch.Size([18, 256, 176]) from_pose type: <class 'torch.Tensor'>

I believe the problem with the first error { TypeError: ne() received an invalid combination of arguments - got (NoneType), but expected one of:

(Tensor other) didn't match because some of the arguments have invalid types: (!NoneType!) (Number other) didn't match because some of the arguments have invalid types: (!NoneType!) } is that a tensor is being compared to a None type { if pose != None: }

This can be solved by changing if pose != None to if type(pose) != type(None) in the plot_image funciton in the demo.ipynb.

fyviezhao commented 2 years ago

These are the variables that caused the second error:

gimg: tensor([[[0.7569, 0.7569, 0.7569, ..., 0.6706, 0.6706, 0.6706], [0.7569, 0.7569, 0.7569, ..., 0.6706, 0.6706, 0.6706], [0.7569, 0.7569, 0.7569, ..., 0.6706, 0.6706, 0.6706], ..., [0.7961, 0.7961, 0.7961, ..., 0.7490, 0.7412, 0.7490], [0.7961, 0.7961, 0.7961, ..., 0.7490, 0.7412, 0.7490], [0.7961, 0.7961, 0.7961, ..., 0.7490, 0.7490, 0.7490]],

    [[0.7569, 0.7569, 0.7569,  ..., 0.6863, 0.6863, 0.6863],
     [0.7569, 0.7569, 0.7569,  ..., 0.6863, 0.6863, 0.6863],
     [0.7569, 0.7569, 0.7569,  ..., 0.6863, 0.6863, 0.6863],
     ...,
     [0.7961, 0.7961, 0.7961,  ..., 0.7647, 0.7569, 0.7647],
     [0.7961, 0.7961, 0.7961,  ..., 0.7647, 0.7569, 0.7647],
     [0.7961, 0.7961, 0.7961,  ..., 0.7647, 0.7647, 0.7647]],

    [[0.7569, 0.7569, 0.7412,  ..., 0.6784, 0.6784, 0.6784],
     [0.7569, 0.7569, 0.7412,  ..., 0.6784, 0.6784, 0.6784],
     [0.7569, 0.7569, 0.7412,  ..., 0.6784, 0.6784, 0.6784],
     ...,
     [0.7961, 0.7961, 0.7961,  ..., 0.7569, 0.7490, 0.7569],
     [0.7961, 0.7961, 0.7961,  ..., 0.7569, 0.7490, 0.7569],
     [0.7961, 0.7961, 0.7961,  ..., 0.7569, 0.7569, 0.7569]]],
   device='cuda:0')

gimg type: <class 'torch.Tensor'> gparse: tensor([[0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], ..., [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0]], device='cuda:0', dtype=torch.uint8) gparse type: <class 'torch.Tensor'> gid[2]: 5 gid[2] type: <class 'int'>

The error is in this line: { gimgs += [gimg * (gparse == gid[2])] }

RuntimeError: expected type torch.cuda.FloatTensor but got torch.cuda.ByteTensor

Modifying gimgs += [gimg * (gparse == gid[2])] to gimgs += [gimg * (gparse == gid[2]).to(torch.float32)] can fix this error.

AhmedHashish123 commented 2 years ago

These are the variables that caused the second error: gimg: tensor([[[0.7569, 0.7569, 0.7569, ..., 0.6706, 0.6706, 0.6706], [0.7569, 0.7569, 0.7569, ..., 0.6706, 0.6706, 0.6706], [0.7569, 0.7569, 0.7569, ..., 0.6706, 0.6706, 0.6706], ..., [0.7961, 0.7961, 0.7961, ..., 0.7490, 0.7412, 0.7490], [0.7961, 0.7961, 0.7961, ..., 0.7490, 0.7412, 0.7490], [0.7961, 0.7961, 0.7961, ..., 0.7490, 0.7490, 0.7490]],

    [[0.7569, 0.7569, 0.7569,  ..., 0.6863, 0.6863, 0.6863],
     [0.7569, 0.7569, 0.7569,  ..., 0.6863, 0.6863, 0.6863],
     [0.7569, 0.7569, 0.7569,  ..., 0.6863, 0.6863, 0.6863],
     ...,
     [0.7961, 0.7961, 0.7961,  ..., 0.7647, 0.7569, 0.7647],
     [0.7961, 0.7961, 0.7961,  ..., 0.7647, 0.7569, 0.7647],
     [0.7961, 0.7961, 0.7961,  ..., 0.7647, 0.7647, 0.7647]],

    [[0.7569, 0.7569, 0.7412,  ..., 0.6784, 0.6784, 0.6784],
     [0.7569, 0.7569, 0.7412,  ..., 0.6784, 0.6784, 0.6784],
     [0.7569, 0.7569, 0.7412,  ..., 0.6784, 0.6784, 0.6784],
     ...,
     [0.7961, 0.7961, 0.7961,  ..., 0.7569, 0.7490, 0.7569],
     [0.7961, 0.7961, 0.7961,  ..., 0.7569, 0.7490, 0.7569],
     [0.7961, 0.7961, 0.7961,  ..., 0.7569, 0.7569, 0.7569]]],
   device='cuda:0')

gimg type: <class 'torch.Tensor'> gparse: tensor([[0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], ..., [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0]], device='cuda:0', dtype=torch.uint8) gparse type: <class 'torch.Tensor'> gid[2]: 5 gid[2] type: <class 'int'> The error is in this line: { gimgs += [gimg * (gparse == gid[2])] } RuntimeError: expected type torch.cuda.FloatTensor but got torch.cuda.ByteTensor

Modifying gimgs += [gimg * (gparse == gid[2])] to gimgs += [gimg * (gparse == gid[2]).to(torch.float32)] can fix this error.

Thank you. I will try your solutions. I will close the issue in the mean time and reopen it if the solution doesn't work.

xuCW1 commented 2 years ago

Hello,I had the same problem as you and tried the solutions above without success. Have you successfully solved it now?I really need your help, thank you!