LouieYang / deep-photo-styletransfer-tf

Tensorflow (Python API) implementation of Deep Photo Style Transfer
803 stars 186 forks source link

error for applying on multiple images in a for loop #14

Closed masih4 closed 6 years ago

masih4 commented 6 years ago

Hey, I am trying to apply this method for many images (i.e. have one reference style image and then have 50 input images that I want to change their styles). Simply I put the whole algorithm in a for loop. However, after a few loops in the for loop (i.e. after 5 loops for 5 input images) I get an error like this: raise ValueError("GraphDef cannot be larger than 2GB.") ValueError: GraphDef cannot be larger than 2GB.

Any ideas how to get rid of this erroe?

LouieYang commented 6 years ago

I think some modification should be applied to the function stylize in photo_style.py if you want to apply this method to multiple images by calling python once. An alternative way is to wrap the python in the shell script and call python multiple times.

masih4 commented 6 years ago

Thank you so much for replying that quickly. I am not sure if I get what you mean exactly. Can you make an example of that. Consider that I have 10 input images in one folder and one reference image and I want to apply this method on all of the input images. This one work for one image : python deep_photostyle.py --content_image_path ./examples/input/in11.png --style_image_path ./examples/style/tar11.png --content_seg_path ./examples/segmentation/in11.png --style_seg_path ./examples/segmentation/tar11.png --style_option 2 But how can I apply it automatically for all 10 images?

LouieYang commented 6 years ago

For example:

  1. Create a shell script multi_style.sh
  2. Add following lines to the shell script
    for i in {1..10}
    do
    python deep_photostyle.py \
        --content_image_path ./examples/input/$i.png \
        --style_image_path ./examples/style/tar11.png \
        --content_seg_path ./examples/segmentation/$i.png \
        --style_seg_path ./examples/segmentation/tar11.png \
        --style_option 2
    done
  3. Put the contents and segmentations in the right place
  4. Run the shell script
masih4 commented 6 years ago

Thank you so much. It seems that it works perfectly.