zukakosan / tripletnet Goto Github PK
View Code? Open in Web Editor NEWImage retrieval with triplet loss
Image retrieval with triplet loss
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))
1.889e-13
[ 0.2 0.2 0.33]
[ 0.46016546 0.46016546 0.75927301]
array([ 0.2 , 0.2 , 0.33])
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,とデータを紐付ける。
for mnist dataset, alpha = 0.05 is currently best.
To reduce dimensions to 2, use PCA and plot mnist_emb
To compress the value between 0 and 1
せっかく読んでも後で見直すのが面倒なので、新しくipadにノート作ってまとめる。
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
implement FashionNet according to its thesis
https://ieeexplore.ieee.org/document/7780493/
triplet lossについての理解を深める
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?
If use different one, Network for negative may be completely different.
Where to buy it
http://tamaraberg.com/street2shop/
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]]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.