sangyun884 / HR-VITON

Official PyTorch implementation for the paper High-Resolution Virtual Try-On with Misalignment and Occlusion-Handled Conditions (ECCV 2022).
825 stars 171 forks source link

How to create image-parse images #76

Open furkan59 opened 1 year ago

furkan59 commented 1 year ago

I have human images but how can I create image-parse images in folder "VITON-HD\data\train\image-parse-v3".

KIRAN-MK-211 commented 1 year ago

https://colab.research.google.com/drive/1JOwOPaChoc9GzyBi5FUEYTSaP2qxJl10?usp=sharing#scrollTo=VtZDKLL8jWLr You can refer this notebook. results are not exactly same as shown in the paper, but works well.

garychan22 commented 11 months ago

I think the problem is how to get the exact training data of VITON-HD according to the documentation

I saved a parse map image using PIL.Image with P mode. The color of the parse map image in our dataset(VITON-HD) is just for the visualization, it has 0~19 uint values.

Should we just change this line https://github.com/Engineering-Course/CIHP_PGN/blob/master/test_pgn.py#L194C11-L194C11

cv2.imwrite('{}/{}.png'.format(parsing_dir, img_id), parsing_[0,:,:,0])

to

Image.fromarray(parsing_[0,:,:,0]).convert("P").save('{}/{}.png'.format(parsing_dir, img_id))
furkan59 commented 11 months ago

This one seems fine thanks https://colab.research.google.com/drive/1JOwOPaChoc9GzyBi5FUEYTSaP2qxJl10?usp=sharing#scrollTo=VtZDKLL8jWLr

garychan22 commented 11 months ago

but the results produced by this https://colab.research.google.com/drive/1JOwOPaChoc9GzyBi5FUEYTSaP2qxJl10?usp=sharing#scrollTo=VtZDKLL8jWLr are far from the ones in viton regardless of the color

example here

the one in viton 00000_00

the one produced by the referred package, where the torso is missing and mistakenly classified into background 00000_00

triminh12042002 commented 8 months ago

According to the processing part of the HR-VITON code: https://github.com/sangyun884/HR-VITON/blob/main/Preprocessing.md

Check https://github.com/Engineering-Course/CIHP_PGN for human parsing. I inferenced a parse map on 256x192 resolution, and upsample it to 1024x768. Then you can see that it has a alias artifact, so I smooth it using "torchgeometry.image.GaussianBlur((15, 15), (3, 3))". I saved a parse map image using PIL.Image with P mode. The color of the parse map image in our dataset(VITON-HD) is just for the visualization, it has 0~19 uint values.

Using repo https://github.com/Engineering-Course/CIHP_PGN and with the human image you can use the inf_pgn.py to generate the segmentation results with the trained models. Before it, you must setup:

  1. Install requirements package, you should use virtual env with python3.7 like conda to install these package: a. pip install -r requirements.pip b. pip install --upgrade pip c. pip install protobuf==3.20.1 d. run the command: python3 inf_pgn.py (to make sure your code already run first)
  2. Download pretrained model https://drive.google.com/file/d/1Mqpse5Gen4V4403wFEpv3w3JAsWw2uhk/view?usp=drive_open and store to checkpoint/ folder (instruction: https://github.com/Engineering-Course/CIHP_PGN?tab=readme-ov-file#pre-trained-models)
  3. Add your image to folder image (datasets/images)
  4. Adjust the code in file inf_pgn.py to store the result image with "P" mode: Add parsing_im = parsing_im.convert('P') before the line 198 parsing_im.save('{}/{}_vis.png'.format(parsing_dir, img_id))

Now run the command: python3 inf_pgn.py The output image path will be in folder datasets/output This result will be use for the image-parse-v3 folder of VITON - HD dataset

whiterose199187 commented 8 months ago

hi @triminh12042002

I tries this approach but looks like that repo is using pretty old versions of tensorflow. How did you get it to work? Did you use python 2.x ?

triminh12042002 commented 8 months ago

whiterose199187 No, I'm using python 3.7 According to file requirements.pip, the repo used Tensorflow 1.5 so we need python3.7 or lower to install it. I think u should use conda to create an env with python3.7 and install the requirements package as step 1

kapoorkhushi03 commented 1 month ago

@whiterose199187 were u able to implement viton-HD?