Giter VIP home page Giter VIP logo

m3d-vton's Introduction

M3D-VTON: A Monocular-to-3D Virtual Try-On Network

Official code for ICCV2021 paper "M3D-VTON: A Monocular-to-3D Virtual Try-on Network"

Paper | Supplementary | MPV3D Dataset | Pretrained Models

M3D-VTON

Requirements

python >= 3.8.0, pytorch == 1.6.0, torchvision == 0.7.0

Data Preparation

MPV3D Dataset

After downloading the MPV3D Dataset, please run the following script to preprocess the data:

python util/data_preprocessing.py --MPV3D_root path/to/MPV3D/dataset

Custom Data

If you want to process your own data, some more steps are needed (the → indicates the corresponding folder where the images should be put into):

  1. prepare an in-shop clothing image C (→ mpv3d_example/cloth) and a frontal person image P (→ mpv3d_example/image) with resolution of 320*512;

  2. obtain the mask of C (→ mpv3d_example/cloth-mask) by thresholding or using remove.bg;

  3. obtain the human segmentation layout (→ mpv3d_example/image-parse) by applying 2D-Human-Paring on P;

  4. obtain the human joints (→ mpv3d_example/pose) by applying OpenPose (25 keypoints) on P;

  5. run the data processing script python util/data_preprocessing.py --MPV3D_root mpv3d_example to automatically obtain the remaining inputs (pre-aligned clothing, palm mask, and image gradients);

  6. now the data preparation is finished and you should be able to run inference with the steps described in the next section "Running Inference".

Running Inference

We provide demo inputs under the mpv3d_example folder, where the target clothing and the reference person are like:

Demo inputs

with inputs from the mpv3d_example folder, the easiest way to get start is to use the pretrained models and sequentially run the four steps below:

1. Testing MTM Module

python test.py --model MTM --name MTM --dataroot mpv3d_example --datalist test_pairs --results_dir results

2. Testing DRM Module

python test.py --model DRM --name DRM --dataroot mpv3d_example --datalist test_pairs --results_dir results

3. Testing TFM Module

python test.py --model TFM --name TFM --dataroot mpv3d_example --datalist test_pairs --results_dir results

4. Getting colored point cloud and Remeshing

(Note: since the back-side person images are unavailable, in rgbd2pcd.py we provide a fast face inpainting function that produces the mirrored back-side image after a fashion. One may need manually inpaint other back-side texture areas to achieve better visual quality.)

python rgbd2pcd.py

Now you should get the point cloud file prepared for remeshing under results/aligned/pcd/test_pairs/*.ply. MeshLab can be used to remesh the predicted point cloud, with two simple steps below:

  • Normal Estimation: Open MeshLab and load the point cloud file, and then go to Filters --> Normals, Curvatures and Orientation --> Compute normals for point sets

  • Possion Remeshing: Go to Filters --> Remeshing, Simplification and Reconstruction --> Surface Reconstruction: Screen Possion (set reconstruction depth = 9)

Now the final 3D try-on result should be obtained:

Try-on Result

Training on MPV3D Dataset

With the pre-processed MPV3D dataset, you can train the model from scratch by folllowing the three steps below:

1. Train MTM module

python train.py --model MTM --name MTM --dataroot path/to/MPV3D/data --datalist train_pairs --checkpoints_dir path/for/saving/model

then run the command below to obtain the --warproot (here refers to the --results_dir) which is necessary for the other two modules:

python test.py --model MTM --name MTM --dataroot path/to/MPV3D/data --datalist train_pairs --checkpoints_dir path/to/saved/MTMmodel --results_dir path/for/saving/MTM/results

2. Train DRM module

python train.py --model DRM --name DRM --dataroot path/to/MPV3D/data --warproot path/to/MTM/warp/cloth --datalist train_pairs --checkpoints_dir path/for/saving/model

3. Train TFM module

python train.py --model TFM --name TFM --dataroot path/to/MPV3D/data --warproot path/to/MTM/warp/cloth --datalist train_pairs --checkpoints_dir path/for/saving/model

(See options/base_options.py and options/train_options.py for more training options.)

License

The use of this code and the MPV3D dataset is RESTRICTED to non-commercial research and educational purposes.

Citation

If our code is helpful to your research, please cite:

@InProceedings{M3D-VTON,
    author    = {Zhao, Fuwei and Xie, Zhenyu and Kampffmeyer, Michael and Dong, Haoye and Han, Songfang and Zheng, Tianxiang and Zhang, Tao and Liang, Xiaodan},
    title     = {M3D-VTON: A Monocular-to-3D Virtual Try-On Network},
    booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
    month     = {October},
    year      = {2021},
    pages     = {13239-13249}
}

m3d-vton's People

Contributors

dariussingh avatar fyviezhao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

m3d-vton's Issues

Error in output files (.ply)

Hi. I ran the repo on the test dataset. I am unable to visualize the output files (.ply) in blender/Online 3D viewer. The errors are "Invalid header ('end_header' line not found!) Invalid file" and "unable to import model, face not present" , respectively.

warp cloth

I 'm sorry to bother you again. You are so kind-hearted, thank you again.
I just happened the probelm that warp cloth saved by MTM model seems smaller when i train MTM in MPV3D Dataset with the same param configures. But the warp cloth generated by your pretrained MTM model is larger. I analysis for a long time, but i can't find the reason. Please help me! Best wish with you.

DRM and TFM

thanks for your reply. this is great job! i have another question that what's the DRM and TFM's network? i can't find any detailed description in papers. are they using gan network? what can i refer to. i look forward to your reply, thank u.

Error when run on Custom data

Thank you for perfect repository
I am following the readme to run on custom dataset but i get this error (man_person.png is my input image)
when I run MTM model

FileNotFoundError: [Errno 2] No such file or directory: 'mpv3d_example/depth/man_person_depth.npy'

Can you help me fix this error?

certain part blurred in mesh

Hi, this is absolutely amazing work! I tried to run the test demo according to all your instructions and here is the result I obtained.
May I know if these small artifacts present in the mesh are normal? If so, what might be the reason causing these artifacts?

drawing

drawing

stack expects each tensor

File ".../utils/util.py", line 100, in depth2normal_ortho
p = torch.stack([x_cord, y_cord, depth], dim=3) # (B,H,W,3)
RuntimeError: stack expects each tensor to be equal size, but got [8, 256, 192] at entry 0 and [5, 256, 192] at entry 2

I've got this error when I used batch size 8 for DRM.

What is the batch size for DRM?

Thanks for your quick answer.

How to extract double depth map in .npy format from 2D images

Thanks for your interesting paper called "M3D-VTON: A Monocular-to-3D Virtual Try-On Network". I'm also involved in such a similar area and I need to know how could I extract the ground truth depth (.npy files) for 2D images. Could you please guide me in this regard?
My next question is that how you catch the camera specification from 2D images?

mesh results

Hi,

Thanks for your work.

When I used your images with the same resolution, the output of rgbd2pcl which is .ply is not completely painted and there are some parts that are masked. Is there anything that should apply after the rgbd2pck before mesh lab?

'add_gan_loss' is not in the command line for training

Hi,

why the store action is true in DRM? It does not include in the command line for training. However, FND and BND are dependent on this argument.

parser.add_argument('--add_gan_loss', action='store_true', help='if specified, use gan loss')

Thanks

How to run on custom images and clothing

Can you please let me know how to create custom data for testing?
I see this has many files mpv3d_example.
Also does your code hav anything to do with SMPL
I assume the end result is just the 3d model with no SMPL and with poses
Correct?

strange results when use color point clouds to reconstruct mesh

Hi ,Zhao, Thanks for sharing your interesting work. I downloaded M3D dataset and tried to run python rgbd2pcd.py to get point clouds using depth maps of the dataset. I set flag label='gt' , but got a strange result.
Here is the front-view rgb.png and the generated rgb_back.png

rgb_front

rgb_back

And here is the mesh I got following your instructions on MeshLab.
image

Besides, why we use fd = -1.0 * (2.0 * fd - 1.0) rather than fd = 2.0 * fd - 1.0 to transform the fd coordinates? Can you give me some tips to fix that ? really thank.

Runtime error of channels

Hello there, first of all thank you for this project/source code. I didn't face any issue regarding this. However, I could not understand the this issue related to custom data. The custom t-shirt is perfectly working on your dataset but not mine. I have create custom dataset of image but not working. Please revert whenever you get time. Thank You.

Screenshot 2022-08-23 at 11 39 16 AM

mesh outputs

Hi,
How did you use gif maker of the mesh results to create gif output?

rgbd2pc could also work for lower resolution?
The .ply for my case is incomplete.

Thanks for your swift response.

depth generate

hi,thans for your great job. i am very curious about this project and how to generate depth. Is there some code to refer. hope your reply!

GPU Error when running the test examples

We are getting graphic card related error.
Here are my system info

pavan@u-20:~/.../M3D-VTON$ sudo dmidecode -t 1
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.0.0 present.

Handle 0x000C, DMI type 1, 27 bytes
System Information
	Manufacturer: LENOVO
	Product Name: 20JUS05X00
	Version: ThinkPad L470 W10DG
	Serial Number: PF11SM82
	UUID: 31f6b94c-2fd0-11b2-a85c-ed0533b508ea
	Wake-up Type: Power Switch
	SKU Number: LENOVO_MT_20JU_BU_Think_FM_ThinkPad L470 W10DG
	Family: ThinkPad L470 W10DG

pavan@u-20:~/.../M3D-VTON$
pavan@u-20:~/.../M3D-VTON$ inxi -G
Graphics:  Device-1: Intel Skylake GT2 [HD Graphics 520] driver: i915 v: kernel 
           Display: x11 server: X.Org 1.20.13 driver: i915 resolution: 1366x768~60Hz 
           OpenGL: renderer: Mesa Intel HD Graphics 520 (SKL GT2) v: 4.6 Mesa 21.2.6 
pavan@u-20:~/.../M3D-VTON$ 

pavan@u-20:~/.../M3D-VTON$ python3 test.py --model MTM --name MTM --dataroot mpv3d_example --datalist test_pairs --results_dir results
                  verbose: False                         
----------------- End -------------------
Traceback (most recent call last):
  File "test.py", line 25, in <module>
    opt = TestOptions().parse()  # get test options
  File "/home/pavan/Documents/aux/tmp-git/virtual-try-on/M3D-VTON/options/base_options.py", line 130, in parse
    torch.cuda.set_device(opt.gpu_ids[0])
  File "/home/pavan/.local/lib/python3.8/site-packages/torch/cuda/__init__.py", line 313, in set_device
    torch._C._cuda_setDevice(device)
  File "/home/pavan/.local/lib/python3.8/site-packages/torch/cuda/__init__.py", line 216, in _lazy_init
    torch._C._cuda_init()
RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx
pavan@u-20:~/.../M3D-VTON$

is it possible to run it on my machine? I have attached my machine info also.

RuntimeError error of Channels with Custom Test Data

I prepared my custom test data

  1. https://github.com/kaijung/M3D-VTON/blob/main/mpv3d_example/image/BAEL-K11%403%3Dperson_whole_front.png image P 320*512
  2. https://github.com/kaijung/M3D-VTON/blob/main/mpv3d_example/image-parse/BAEL-K11%403%3Dperson_whole_front_label.png 2D-Human-Paring on P;
  3. https://github.com/kaijung/M3D-VTON/blob/main/mpv3d_example/pose/BAEL-K11%403%3Dperson_whole_front_keypoints.json OpenPose (25 keypoints) on P;

and has ran the command

python util/data_preprocessing.py --MPV3D_root mpv3d_example 

with mpv3d_example/train_pairs.txt https://github.com/kaijung/M3D-VTON/blob/main/mpv3d_example/train_pairs.txt

and then ran the MTM command

python test.py --model MTM --name MTM --dataroot mpv3d_example --datalist test_pairs --results_dir results

and got RuntimeError

dataset [AlignedMPV3dDataset] was created
initialize network with normal
model [MTMModel] was created
loading the model from pretrained/aligned/MTM/latest_net_MTM.pth
---------- Networks initialized -------------
[Network MTM] Total number of parameters : 40.003 M
-----------------------------------------------
/usr/local/lib/python3.8/dist-packages/torch/nn/functional.py:4227: UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details.
  warnings.warn(
Traceback (most recent call last):
  File "test.py", line 63, in <module>
    model.test()            # run inference
  File "/content/M3D-VTON/models/base_model.py", line 110, in test
    self.forward()
  File "/content/M3D-VTON/models/MTM_model.py", line 151, in forward
    self.output = self.netMTM(self.agnostic, self.c)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/content/M3D-VTON/models/networks.py", line 768, in forward
    featureA = self.extractionA(inputA) # featureA: size (batch_size,512,32,20)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/content/M3D-VTON/models/networks.py", line 99, in forward
    return self.model(x)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/container.py", line 204, in forward
    input = module(input)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/conv.py", line 463, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/conv.py", line 459, in _conv_forward
    return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Given groups=1, weight of size [64, 29, 4, 4], expected input[1, 30, 512, 320] to have 29 channels, but got 30 channels instead
[ ]

Error when train the model

During training, this error occurs!Do you know how to solve?
154000356-60f0c911-7e81-41ad-9716-766b80650ac5
After I declared the variable I got another error
154394009-75ce6375-6c4a-41fa-b2f4-b94e7e2016cf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.