Giter VIP home page Giter VIP logo

tripletnet's Introduction

Cross-domain image retrieval on fashion with designed triplet loss

Current Structure of Network

tripletNet

Partial Network 'embNet'

embNet

Implementation

These notebooks are implemented by python = 3.5 or 3.6 with keras = 2.1.1 .

Usage

Before execute jupyter notebook, we need some work.

$ mkdir model
$ brew install graphviz
# or apt-get install graphviz
$ pip install pydot

Experiment

Nogizaka46

Query

query

Nearest

nearest

Distance

distance

mnist

mnistemb pcaplot

Dataset

By using the Dataset of DeepFashion, I address one of the three tasks. (http://mmlab.ie.cuhk.edu.hk/projects/DeepFashion.html) Calculate accuracy by top-K score of retrievals.

First, I'll try to use the FashionNet which is suggested by the provider of the Dataset. (https://ieeexplore.ieee.org/document/7780493/)

2.3. Benchmarks
We build the following benchmarks out of DeepFashion for evaluating different methods. Category and Attribute Prediction
This task is to classify 50 fine-grained categories and 1, 000 attributes. There are 63, 720 diverse images in this benchmark. For category classification, we employ the standard top-k classification accuracy as evaluation metric. For attribute prediction, our measuring criteria is the top-k recall rate following [9], which is obtained by ranking the 1, 000 classification scores and determine how many attributes have been matched in the top-k list. In-Shop Clothes Retrieval
This task is to determine if two images taken in shop belong to the same clothing item 5. It is important when customers encounter shop image on photo sharing sites and would like to know more about its item information on online retailer stores. This benchmark contains 54,642 images of 11,735 clothing items from Forever21. Top-k retrieval accuracy is adopted to measure the performance of fashion retrieval, such that a successful retrieval is counted if the exact fashion item has been found in the top-k retrieved results. Consumer-to-Shop Clothes Retrieval
This scenario has been considered by several previous works [10], [12], aiming at matching consumer-taken photos with their shop counterparts. We select 251,361 consumer-to-shop image pairs from Mogujie for this benchmark. Again, top-k retrieval accuracy is employed to evaluate performance.

tripletnet's People

Contributors

zukakosan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

tripletnet's Issues

somthing wrong with "plt.imshow(img)"

img = np.array(Image.open('path').resize((w,h)))
img = (img/255.).astype(np.float32)
plt.imshow(img)

if I exec this code, normal image comes up...Why?

Something wrong with triplet-loss

why loss: 0.0000e+00 ?

Epoch 1/10
400/400 [==============================] - 6s 15ms/step - loss: 3278.5809
Epoch 2/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 3/10
400/400 [==============================] - 4s 9ms/step - loss: 778.3205
Epoch 4/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 5/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 6/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 7/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 8/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 9/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 10/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00

train tripletNet with images of Nogizaka and confirm the behavior

import numpy as np
import os.path

class IdentityMetadata():
    def __init__(self, base, name, file):
        # dataset base directory
        self.base = base
        # identity name
        self.name = name
        # image file name
        self.file = file

    def __repr__(self):
        return self.image_path()

    def image_path(self):
        return os.path.join(self.base, self.name, self.file) 
    
def load_metadata(path):
    metadata = []
    for i in os.listdir(path):
        for f in os.listdir(os.path.join(path, i)):
            metadata.append(IdentityMetadata(path, i, f))
    return np.array(metadata)

metadata = load_metadata('images')

クラスを作成してfilename,とデータを紐付ける。

論文まとめ

せっかく読んでも後で見直すのが面倒なので、新しくipadにノート作ってまとめる。

How can I get the embedded vectors?

embedded = np.zeros((metadata.shape[0], 128))

for i, m in enumerate(metadata):
    img = load_image(m.image_path())
    img = align_image(img)
    # scale RGB values to interval [0,1]
    img = (img / 255.).astype(np.float32)
    # obtain embedding vector for image
    embedded[i] = nn4_small2_pretrained.predict(np.expand_dims(img, axis=0))[0]

predict( )[0]なのでpredictしたうちのanchorに相当する値を取り出しemb_vecとしている?
expand_dims : [a,b,c] -> [[a,b,c]]

what is L2-norm Layer's role?

import numpy as np
epsilon = 1e-12
x =np.array([0.0000002,0.0000002,0.00000033])
print(sum(x**2))
print(x/np.sqrt(epsilon))
print(x/np.sqrt(sum(x**2)))
x/np.sqrt(max(sum(x**2), epsilon))

output

1.889e-13
[ 0.2   0.2   0.33]
[ 0.46016546  0.46016546  0.75927301]
array([ 0.2 ,  0.2 ,  0.33])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.