sanku-lib / image_triplet_loss Goto Github PK
View Code? Open in Web Editor NEWImage similarity using Triplet Loss
Home Page: https://medium.com/@shibsankardas.cse/image-similarity-using-triplet-loss-3744c0f67973
Image similarity using Triplet Loss
Home Page: https://medium.com/@shibsankardas.cse/image-similarity-using-triplet-loss-3744c0f67973
Hi ,
Can You please help me, how can I pick only one image while testing? Right now it picks random images (random images through index value). I want to give one image and get output through that.
Hi,
Thanks for the wonderful algorithm. Helped me a lot.
I am trying to implement a different flavor of networks for my algortihm:
def conv_net(self, inp, reuse=False):
vgg_model = VGG16(weights=None, include_top=False,input_shape=(32,32,3),input_tensor=inp)
#print(" vgg_model_input {}".format(vgg_model.input))
x = vgg_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(4096, activation='relu')(x)
x = Dropout(0.6)(x)
x = Dense(4096, activation='relu')(x)
x = Dropout(0.6)(x)
x = Lambda(lambda x_: K.l2_normalize(x,axis=1))(x)
convnet_model = Model(inputs=vgg_model.input,outputs=x)
first_conv = Conv2D(96, kernel_size=(8, 8),strides=(16,16), padding='same',name="conv_layer_1")(inp)
first_max = MaxPool2D(pool_size=(3,3),strides = (4,4),padding='same')(first_conv)
first_max = Flatten()(first_max)
first_max = Lambda(lambda x: K.l2_normalize(x,axis=1))(first_max)
second_conv = Conv2D(96, kernel_size=(8, 8),strides=(32,32), padding='same',name="conv_layer_2")(inp)
second_max = MaxPool2D(pool_size=(7,7),strides = (2,2),padding='same')(second_conv)
second_max = Flatten()(second_max)
second_max = Lambda(lambda x: K.l2_normalize(x,axis=1))(second_max)
merge_one = concatenate([first_max, second_max])
merge_two = concatenate([merge_one, convnet_model.output])
emb = Dense(512)(merge_two)
l2_norm_final = Lambda(lambda x: K.l2_normalize(x,axis=1))(emb)
#emb = Flatten()(emb)
print("Embedding {}".format(emb))
return l2_norm_final
However when I train using these layers, my model only produces nonzero loss for first iteration, all further losses are 0.0.
Could you think of a reason why that might be happening ?
I am new to tensorflow to the struggles.
Thanks
Hello,
thank you for your great project!
I'm currently trying to execute your code. However, when I try to execute the jupyter notebook, cell 6 throws the following error:
model = TripletLoss()
"NameError: name 'TripletLoss' is not defined".
Is there anything which needs to be additionally installed for this?
Best wishes
Edit: Is it possible, that "from model import TripletLossetLoss" is meant to be "from model import TripletLoss"?
Hello!
Thanks for sharing your project.
I tried to run training with my own dataset but the following error was occured:
Dataset loaded successfully.
Preprocessing Done. Summary:
Images train : (837,)
Labels train : (837,)
Images test : (91,)
Labels test : (91,)
Unique label : [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
24 25 26 27 28 29]
placeholder_shape [None]
WARNING:tensorflow:From train_triplets.py:25: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.
WARNING:tensorflow:From /home/user/similarity/sanku/model.py:8: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.
WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
* https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
* https://github.com/tensorflow/addons
* https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.
Traceback (most recent call last):
File "train_triplets.py", line 30, in <module>
anchor_output = model.conv_net(anchor_input, reuse=False)
File "/home/user/similarity/sanku/model.py", line 11, in conv_net
scope=scope, reuse=reuse)
File "/home/user/.local/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args
return func(*args, **current_args)
File "/home/user/.local/lib/python3.6/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1159, in convolution2d
conv_dims=2)
File "/home/user/.local/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args
return func(*args, **current_args)
File "/home/user/.local/lib/python3.6/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1025, in convolution
(conv_dims + 2, input_rank))
ValueError: Convolution expects input with rank 4, got 1
Please help. What should I improve for a launch?
My packages versions are all from requirements.txt. Besides, I tried to run the program without any env (tensorflow 1.14, numpy 1.18) but got the same error.
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.