PoshakNet: Framework for matching dresses from real-life photos using GAN and Siamese Network

PoshakNet: Framework for matching dresses from real-life photos using GAN and Siamese Network

Abhigyan Khaund Indian Institute of Technology, Mandi
   Daksh Thapar Indian Institute of Technology, Mandi
   Aditya Nigam Indian Institute of Technology, Mandi
1email: {b16082,d18033}@students.iitmandi.ac.in, aditya@iitmandi.ac.in

Online garment shopping has gained many customers in recent years. Describing a dress using keywords does not always yield the proper results, which in turn leads to dissatisfaction of customers. A visual search based system will be enormously beneficent to the industry. Hence, we propose a framework that can retrieve similar clothes that can be found in an image. The first task is to extract the garment from the input image (street photo). There are various challenges for that, including pose, illumination, and background clutter. We use a Generative Adversarial Network for the task of retrieving the garment that the person in the image was wearing. It has been shown that GAN can retrieve the garment very efficiently despite the challenges of street photos. Finally, a siamese based matching system takes the retrieved cloth image and matches it with the clothes in the dataset, giving us the top matches. We take a pre-trained inception-ResNet v1 module as a siamese network (trained using triplet loss for face detection) and fine-tune it on the shopping dataset using center loss. The dataset has been collected inhouse. For training the GAN, we use the LookBook dataset [14], which is publically available.

Deep Learning GAN e-commerce. Siamese Dress Retrieval

1 Introduction

Clothes are like an extended body part of human beings. Every human being spends hours every day to make themselves look good in the best attire. To achieve this, we spent a lot of time buying clothes that we fancy. Recent years have seen a tremendous rise in e-commerce ventures and their sales. Clothes shopping has led these sales after electronics. This wave of online apparel shopping is due to the involvement of tech giants like Amazon, Flipkart, Myntra, and others. Users of these platforms generally search for clothes using some static and manually selected keywords that describe the shape or color of the dress. However, it is not always that searching through such keywords leads users directly to the desired dress.

Motivation: More often than not, we tend to search for clothes that we see others wearing, and we find it challenging to frame that dress in terms of the available keywords. It is difficult to describe multi-colored apparel, and with so many new fashion designs hitting the market, it is sometimes confusing to pinpoint the dress type worn. These issues result in users not being able to search for the desired dress in the shopping sites and often getting unwanted results. This is the major drawback of any keyword based matching algorithms and can be solved if the products can be described using visual clues. We base our search model not on keywords but directly on the image content. We take a picture of the dress the user wants to find matches for and run a matching process to determine the closest matches to the dress from the shopping portal, reducing the dependence on being able to search and shop with exact keywords and textual descriptions.

Figure 1: An example showing the end-to-end working of the street-to-shop problem.
Figure 2: (a) Illustration of various challenges to content-based clothes retrieval. (b) Cropped picture from bounding box with unwanted body elements.

Challenges: How do we get a visual representation of the dress in a way that we can accurately do its matching with the available shopping products? If we directly use a person’s picture for matching, it is bound to fail, as such photos have a varying background, inconsistent lighting, and different positions of the person’s posture, which may lead to an obscured view of the dress. One easy solution to this problem is to crop the image using object detection to retrieve only the bounding box for the dress of the person from the image [15]. This approach is unable to remove certain unwanted portions like arms, hand, neck, or hair in the cropped portion. If the person is also at an angle that causes the dress to be not fully visible, this approach only gets the visible part of the dress due to object detection. These issues cause significant performance degradation and may ruin a user’s shopping experience and leave them completely unsatisfied. To handle this problem, we should be able to generate the image of the dress directly from the image without any unwanted background or noise. That is, when the user provides an image of a person, a new image is produced consisting only of the dress of the person. The extraction should be independent of the posture of the person in the image, background, or any other noise.

Problem Statement: This work focuses on solving addressing above mentioned issues as a bi-phase problem and providing a single pipeline (shown in Fig. 2) that does an end-to-end work for solving this issue of street-to-shop. The proposal consists of two phases:

  1. Content-Based Clothes Retrieval(CBCR) - Given an input street query photo with a single person in it, generate an image using a generative network with only the dress of the person worn in the input image.

  2. Clothes Matching Network(CMN) - Use the generated image to find a match in the shopping products dataset using a matching convolution network and show the users top k matches.

        Clothes Retrieval Product Similarity Street To Shop
        Manual semantic attributes annotation, manual effort, dependent on correctness of semantic attributes [11]. Siamese Networks most popular to measure similarity of two images. Retrieving clothes from daily photos and matching similar looking (or identical) products is called Street to Shop.
        Deep learning models to handle cross-scenario variations, learn distinct features [1, 4, 5]. Fine-grained object retrieval matching with triplet based ranking loss [6, 12]. Align body parts in the street photo with shop photo, works in constrained environment, distorted results in real-life scenarios [8].
        Object detection to get dress’s bounding box [7, 3]. Face matching using triplet loss to train [9]. Use image annotation and a bounding box of the query product, lot of human interference required [3].
        Generative Adversarial Nets(GAN) [2] generate clothes from person’s picture [14, 15]. Bounding box introduces unwanted human parts and background in the picture, contrast to clean shopping product image.
Table 1: Summary of the work in relevant literature.

Contributions: This paper addresses the Street to Shop problem as a bi-phase problem using deep learning methods. Clothes retrieval is considered the first phase and is approached by attempting to generate a new image of the clothes from the input image. This generation is independent of the human posture or background of the input image. Then, we explore siamese networks to establish similarity between the generated and shopping image. This invloves learning similarity in the clothing domain for the network.

Specific contributions are:

  • Creation of a dataset, a shopping dataset that contains clean product images of the front view of the dress without any human part. Additionally, this dataset is classified based on fixed attributes manually. We will make the dataset publically available post-acceptance.

  • Transfer learning of a siamese network trained on face dataset to the clothing domain using center loss. To the best of our knowledge, this is the first attempt where a siamese network has been fine-tuned to generate top recommendations of clean product images without any human or mannequin body similar to a query image.

  • Exploring the utility of using a generative network for the clothes retrieval phase of the street to shop problem, constructing clean dress images invariant of the human pose, background, dress occlusion, and lighting in the input image.

The remaining paper is organized as: Section 2 describes the proposed methodology. Section 3 discuss the experimental analysis and Section 4 presents the conclusion and scope of future work.

2 Proposed Methodology

(a) (a)
(b) (b)
Figure 3: (a) A Generative Network that is used generate the clean image of the product the person is wearing. (b) A matching network that matches the generated image with the images from the dataset.

This section covers the detailed description of the methodology proposed in this work. Our methodology is divided into 2 phases, clothes retrieval, and product matching.

2.1 Phase 1: Content-Based Clothes Retrieval(CBCR)

The first phase requires to generate an image of a dress from a street image containing a person wearing the dress. We propose a network that is invariant of the pose of the person and does not depend on the lighting conditions. It is also able to work if parts of the dress are occluded. The proposed idea is related to generative image models wherein we generate a final result as an image directly from an input image. There are two types of image-generative models, one with generative parametric approaches and one with adversarial approaches. In this work, we have used the adversarial approach. The adversarial approach was proposed by Goodfellow et al. as Generative Adversarial Nets (GAN) [2]. We want to use a GAN that works in the clothes domain and can generate clothes from the provided image. One approach to this is to do a pixel-level domain transfer in the GAN [14] on the clothes domain. We make use of [14] trained on the LookBook dataset. Using the generative network, we produce an image containing only the dress of size .

        Layers Filters Number of Filters Stride Padding
        Convolution 1 5x5x{3,3,6} 128 2 2
        Convolution 2 5x5x128 256 2 2
        Convolution 3 5x5x256 512 2 2
        Output Layer 1x1x1024 {64, 1, 1} 1 0
Table 2: Network layers of the {encoder, real/fake discriminator, domain discriminator} of Generative Network. [14]
        Layer Filter Number of Filters Stride
        Convolution 1 1x1x64 4x4x1024 1
        Conv2DTranspose. 1 5×5×512 1024 2
        Conv2DTranspose. 2 5×5×256 512 2
        Conv2DTranspose. 3 5×5×128 256 2
        Conv2DTranspose. 4 5×5×3 128 2
Table 3: Network layers of the decoder of Generative Network. [14]

The architecture proposed involved in [14] involves a converter network and a discriminator network. The converter is a network consisting of two parts encoder and decoder. Both the encoder and decoder are composed of convolutional and transpose-convolutional layers, respectively. The encoder condenses the input to a 64-dimension capturing the semantic attributes, and the decoder then constructs the relevant target image from it. Table 2 and Table 3 describes the architectures of the encoder and decoder respectively. In the encoder network, the first four layers have L-ReLU as activation function, while the decoder network uses ReLU as the activation function in the first four layers.

On top of the converter network, it uses two discriminator networks, which behave as an adversary and guide the converter network. The first discriminator network is used to differentiate between fake and real images, fake being the one generated by the converter, and real are the actual dataset images. The second is a domain discriminator , which produces a scalar probability specifying whether the input image and the generated image are associated or not. In case of an unrealistic generated image, the real/fake discriminator backpropagates a loss while in case of a generated image irrelevant to the input, the domain discriminator backpropagates a loss.

The real/fake discriminator loss is a binary cross entropy loss, defined as -


Here, is 1 if (input) is a real image from training set and 0 if is a fake image drawn by the generator. The domain discriminator loss is also defined similarly -


Here is the source image and is 1 if (input) is a ground truth target and 0 if is a irrelevant target or an inference from converter.

Considering both eqn. 1 and 2, the loss of the converter network is defined as -


where is a random selection with equal probability among the ground truth, inference and irrelevant target.

2.2 Phase 2: Clothes Matching Network(CMN)

In this phase, we solve the matching problem using deep learning techniques. We use a pre-trained Inception ResNet v1 model [10], trained over face dataset using triplet loss function [9] and do transfer learning on top of it. The pre-trained model is capable of mapping an input image to a 128-d feature space, where each point lies on a unit radius hypersphere centered at the origin. Initially, it is trained to face datasets, but we have to retrain it in order to create a similarity measure for clothes. Hence, we fine-tuned the Inception ResNet v1 of Facenet using the shopping dataset (described in section 3.1) we created. The fine-tuning is done on joint supervision of softmax loss and center loss function [13]. The center loss helps learn a center for the deep features of each class, moving the features of the same class to their centers. Softmax helps enlarge the inter-class difference and the center loss help reduce the intra-class feature distance.

The softmax loss function is defined as,


In Eq. 4, denotes the deep feature from the th class. is the value of column of the weight matrix of the the last layer and is the bias of that layer. is the size of mini-batch and denotes the number of classes.

To minimise intra-class variations of different classes, center loss [13] is defined as,


Here, is the class center of the deep features. and are as defined for Eq. 4.

For joint supervision, the softmax loss(4) and center loss(5) are added to form the final loss to train the CNNs, = + where is a scalar for balancing the two loss functions. The model is fine-tuned for 10 epochs with value of 0.95. For extracting the products that are similar to the image generated in phase1, we use a siamese based matching framework. The trained inception-ResNet v1 model is used to create a feature embedding of the generated image. This embedding is then matched with the embeddings of all the images that are present in the dataset by computing distance score. The output score for each pair of the input image and the products are sorted, and the top results are shown as nearest to the input dress.

Justification: We want those products which are of different categories have their deep vectors away from each other. Within a category, we want closer matching among similar dresses and yet be able to differentiate among different designs. Using joint supervision of softmax and center loss over triplet loss helps us achieve distinction between different products within the same category as we could treat each product as a class of its own. Intuitively, the softmax loss forces the deep features of the different products and categories apart, while the center loss pulls the same product images to a common center.

3 Experimental Analysis

For validating the performance of our proposed approach, we have used two datasets. LookBook dataset [14] is used to train the image retrieval module, and the matching network is validated using our in house collected dataset. For validating the matching network, we have computed the precision in retrieving top similar images.

3.1 Datasets Specification

Figure 4: Collected shopping dataset examples.

GAN Dataset:

For training the image retrieval system, we have utilized the LookBook dataset [14]. There are two categories of images in the dataset, one containing fashion models in different backgrounds and poses in a single dress, and the other is a corresponding product image with a clean background. The dataset consists of 84,748 images with 9,732 product images that are associated with 75,016 model images of the first category. Each model image on an average has eight pictures in different background and pose with the same product.

Shopping Dataset:

We make a shopping dataset that contains images of products from the Amazon website. For every product, we take a product image with a clean background that contains the front view of the dress. We use data augmentation to generate eight other pictures of the same product. The products are of varied color and types. There are 326 products in the database. It means there are a total of 2,608 images. Five categories are used to classify the products. The categories are Blue T-Shirts, Red Sweaters, Bridal Dress, Yellow T-Shirts and Others. Others category consists of apparels that do not fall into any of the first four categories. We have used data from all the categories for training the matching network and the rest for testing.Fig. 4 shows two examples from each of the categories in our dataset.

3.2 Performance metrics

We follow ranking based evaluation criteria [8]. For an input image , we are matching it to all the images in the shopping dataset. The matches are ranked based on the score resulted from the matching network. The product with the lowest score is ranked the highest. We define a binary value which is the ground truth category relevance between and the ranked image. Specifically, if the ground truth category of the input image and the matched image are of the same category, then the value is 1. If the categories differ, the value takes 0.

We can evaluate a ranking of top retrieved product images with respect to an input by precision


where is a normalization constant equal to . This ensures that the correct ranking results in an precision score of 1.

3.3 Results and analysis

         1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
         0.846 0.846 0.820 0.811 0.793 0.764 0.742 0.713 0.687 0.667 0.646 0.625 0.608 0.596 0.576
Table 4: Precision of the system with k varying from 1 to 15.

Performance is measured in terms of as described in Section 3.2. Table. 4 depicts the result of a precision match with top products for values ranging from 1 to 15. Our approach yields a high precision of when is 1 and decreases gradually to , , and for values of 5, 10, and 15 respectively.

Figure 5: Top 5 predictions of the framework from 5 sample query images.

Fig 5 shows the output produced by our proposed system. It is evident from the performance that the system works well in real-life scenarios as well, where there are significant challenges. Some of these beings pose variance, background clutter, and illumination variance. Moreover, the matching system can match the clothes on multiple attributes simultaneously. It can capture the type of garment as well as other attributes like color and sleeve length. Even the precision values indicate an excellent performance of the matching system, which is visible in Fig. 5.

Figure 6: Failure cases for the proposed system.

However, the system still suffers some failures. Fig. 6 shows two typical types of failures. The correct matching depends a lot on whether the required garment is in our database or not. If the garment is not in the database, then the system is not able to produce the correct results. The first failure in Fig. 6 shows one such example.

Moreover, since multiple attributes describe a garment, the network sometimes gives importance to some of the attributes than others. In the second failure case, the network can match the type of garment properly that is a half-sleeve t-shirt but is ignoring the color of the shirt. Hence, we need a system in which we could be able to control the priorities of different attributes during search time, also known as attribute matching.

4 Conclusion and future work

In this paper, we presented a new methodology to solve the street to shop problem of finding similar dresses to shop from different photo capturing scenarios. We also introduced a new dataset of clean images of dress shopping products on which we evaluated our proposed methodology. We proposed a methodology in two phases. First, using a GAN to generate clean dress images from daily query photos and then using the generated image as an input to a siamese network in the clothes domain for retrieving similar products. Future work involves expanding the collected dataset to more categories and do an attribute-based matching of products. The matching network should also be able to match generated images with clean product images that contain some parts of the human body part.

Acknowledgements. We wish to acknowledge and thank Pratyush Gaurav, Shashwat Garg and Sylvia Mittal, students of Indian Institute of Technology, Mandi for their work and contribution to the initial phases of idea and work.


  • [1] B. Gajic and R. Baldrich (2018) Cross-domain fashion image retrieval. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops, pp. 1869–1871. Cited by: Table 1.
  • [2] I. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville, and Y. Bengio (2014) Generative adversarial nets. In Advances in neural information processing systems, pp. 2672–2680. Cited by: Table 1, §2.1.
  • [3] M. Hadi Kiapour, X. Han, S. Lazebnik, A. C. Berg, and T. L. Berg (2015) Where to buy it: matching street clothing photos in online shops. In Proceedings of the IEEE international conference on computer vision, pp. 3343–3351. Cited by: Table 1.
  • [4] J. Huang, R. S. Feris, Q. Chen, and S. Yan (2015) Cross-domain image retrieval with a dual attribute-aware ranking network. In Proceedings of the IEEE international conference on computer vision, pp. 1062–1070. Cited by: Table 1.
  • [5] S. Jiang, Y. Wu, and Y. Fu (2016) Deep bi-directional cross-triplet embedding for cross-domain clothing retrieval. In Proceedings of the 24th ACM international conference on Multimedia, pp. 52–56. Cited by: Table 1.
  • [6] H. Lai, Y. Pan, Y. Liu, and S. Yan (2015) Simultaneous feature learning and hash coding with deep neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 3270–3278. Cited by: Table 1.
  • [7] X. Liang, L. Lin, W. Yang, P. Luo, J. Huang, and S. Yan (2016) Clothes co-parsing via joint image segmentation and labeling with application to clothing retrieval. IEEE Transactions on Multimedia 18 (6), pp. 1175–1186. Cited by: Table 1.
  • [8] S. Liu, Z. Song, G. Liu, C. Xu, H. Lu, and S. Yan (2012) Street-to-shop: cross-scenario clothing retrieval via parts alignment and auxiliary set. In 2012 IEEE Conference on Computer Vision and Pattern Recognition, pp. 3330–3337. Cited by: Table 1, §3.2.
  • [9] F. Schroff, D. Kalenichenko, and J. Philbin (2015) Facenet: a unified embedding for face recognition and clustering. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 815–823. Cited by: Table 1, §2.2.
  • [10] C. Szegedy, W. Liu, Y. Jia, P. Sermanet, S. Reed, D. Anguelov, D. Erhan, V. Vanhoucke, and A. Rabinovich (2015) Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1–9. Cited by: §2.2.
  • [11] J. Wan, D. Wang, S. C. H. Hoi, P. Wu, J. Zhu, Y. Zhang, and J. Li (2014) Deep learning for content-based image retrieval: a comprehensive study. In Proceedings of the 22nd ACM international conference on Multimedia, pp. 157–166. Cited by: Table 1.
  • [12] J. Wang, Y. Song, T. Leung, C. Rosenberg, J. Wang, J. Philbin, B. Chen, and Y. Wu (2014) Learning fine-grained image similarity with deep ranking. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 1386–1393. Cited by: Table 1.
  • [13] Y. Wen, K. Zhang, Z. Li, and Y. Qiao (2016) A discriminative feature learning approach for deep face recognition. In European conference on computer vision, pp. 499–515. Cited by: §2.2, §2.2.
  • [14] D. Yoo, N. Kim, S. Park, A. S. Paek, and I. S. Kweon (2016) Pixel-level domain transfer. In European Conference on Computer Vision, pp. 517–532. Cited by: PoshakNet: Framework for matching dresses from real-life photos using GAN and Siamese Network, Table 1, §2.1, §2.1, Table 2, Table 3, §3.1, §3.
  • [15] S. Zhang, S. Liu, X. Cao, Z. Song, and J. Zhou (2018) Watch fashion shows to tell clothing attributes. Neurocomputing 282, pp. 98–110. Cited by: Table 1, §1.
Comments 0
Request Comment
You are adding the first comment!
How to quickly get a good reply:
  • Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
  • Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
  • Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
The feedback must be of minimum 40 characters and the title a minimum of 5 characters
Add comment
Loading ...
This is a comment super asjknd jkasnjk adsnkj
The feedback must be of minumum 40 characters
The feedback must be of minumum 40 characters

You are asking your first question!
How to quickly get a good answer:
  • Keep your question short and to the point
  • Check for grammar or spelling errors.
  • Phrase it like a question
Test description