5

DeepStyle (Part 2 ): The Fashion GAN

 3 years ago
source link: https://towardsdatascience.com/deepstyle-part-2-4ca2ae822ba0?gi=c5b077330bb
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Building DCGAN to generate realistic, high-fashion clothing

If you haven't readPart 1, please read it first since this article assumes you have read Part 1 already.

Now assuming you have read Part 1, let’s go on.

Step 5 Run Faster R-CNN on Pinterest Database and Crop

After gathering the Pinterest database, now we can perform inference on these images using our previously trained Faster R-CNN. But before we do that, we need to first add the functionality where we will crop the detected object and save the resulting image , since this functionality is not provided right out of the box. You can do this by going to the github repo of this project and download the vis.py . Then, navigate to detectron/utils and replace the existing vis.py with the downloaded version. The new vis.py is the same with the one already provided but with one major difference — crop the object detected and save it in a directory.

The added code predicts the category for the detected object, and if the category is “Full” meaning full-body clothing, then it will crop the image and save it in the directory specified. We only save full-body clothing because we want to be able to generate full-body clothing as well, not only simple shirts or skirts.

After tiny modifications, we are ready to run our model on the Pinterest dataset! We can run inference on our Faster R-CNN previously trained by:

python tools/infer.py \
--im [path/to/image.jpg] \
--rpn-pkl [path/to/rpn/model.pkl] \
--rpn-cfg configs/12_2017_baselines/e2e_faster_rcnn_R-50-FPN_1x.yaml \
--output-dir [path/to/output/dir]

The [path/to/image.jpg] is the directory where we store our Pinterest images, --rpn-pkl is where we previously saved our model .pkl file, --rpn-cfg is where we stored our configs file, and finally, --output-dir is where we want to save our predictions. However, this --output-dir is not that important as it will contain the uncropped images with the predictions. Where we want to look for is the directory we specified in vis.py because that’s where the cropped images will be saved.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK