NVIDIA / FastPhotoStyle

Style transfer, deep learning, feature transform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Label Maps Question

dhpollack opened this issue · comments

Could you provide an example of using label maps? I have a 3-channel jpg as content, a 3 channel jpg as style, then 3 channel PNGs as label maps, but I get the following error:

Elapsed time in stylization: 0.020673
Traceback (most recent call last):
  File "demo.py", line 43, in <module>
    cuda=args.cuda,
  File "/home/ubuntu/repos/FastPhotoStyle/process_stylization.py", line 62, in stylization
    stylized_img = p_wct.transform(cont_img, styl_img, cont_seg, styl_seg)
  File "/home/ubuntu/repos/FastPhotoStyle/photo_wct.py", line 28, in transform
    self.__compute_label_info(cont_seg, styl_seg)
  File "/home/ubuntu/repos/FastPhotoStyle/photo_wct.py", line 67, in __compute_label_info
    o_cont_mask = np.where(cont_seg.reshape(cont_seg.shape[0] * cont_seg.shape[1]) == l)
ValueError: cannot reshape array of size 1555200 into shape (518400,)

Since there are no examples of using label maps, it's hard for me to figure out if my masks should be 1 channel PNGs or some other format. Perhaps I should also mention that my PNGs only have two labels (background and not background) which are 0 or 255 to create black and white PNG masks.

But an example of using the masks with the appropriate inputs would clear things up and I could quickly solve this problem on my own.

@dhpollack Just wondering if you find Example 2 in our USAGE page not helpful.

@dhpollack Remove mode='RGB' on Line 82 and 83 of photo_wct.py.

@Yijunmaverick thanks that fixed the problem

@mingyuliutw I actually hadn't seen that so thanks for pointing it out. I was creating my own masks from RLE encodings, so it would be easier to just have a sample mask rather than having to install LabelMe. However, I could have answered my own question, so thanks for noting that. I'll read the instructions more carefully next time :-)

@mingyuliutw @Yijunmaverick I created a PR (#56) to fix this problem