omoindrot / tensorflow-triplet-loss

Implementation of triplet loss in TensorFlow
https://omoindrot.github.io/triplet-loss
MIT License
1.12k stars 284 forks source link

build my model on my own data set #33

Open ProjectsRebository opened 5 years ago

ProjectsRebository commented 5 years ago

i read the post and understand that the network will be for feature extraction (is this right ?) i want to make model on my own data set

when i read the blog post i understand that the steps to generate my network is 1- prepare my data set using tensor flow for example i will use below code to prepare data set

import cv2

# Use a custom OpenCV function to read the image, instead of the standard
# TensorFlow `tf.read_file()` operation.
def _read_py_function(filename, label):
  image_decoded = cv2.imread(filename.decode(), cv2.IMREAD_GRAYSCALE)
  return image_decoded, label

# Use standard TensorFlow operations to resize the image to a fixed shape.
def _resize_function(image_decoded, label):
  image_decoded.set_shape([None, None, None])
  image_resized = tf.image.resize_images(image_decoded, [28, 28])
  return image_resized, label

filenames = ["/var/data/image1.jpg", "/var/data/image2.jpg", ...]
labels = [0, 37, 29, 1, ...]

dataset = tf.data.Dataset.from_tensor_slices((filenames, labels))
dataset = dataset.map(
    lambda filename, label: tuple(tf.py_func(
        _read_py_function, [filename, label], [tf.uint8, label.dtype])))
dataset = dataset.map(_resize_function) 

2- then i will pass this data set to train.py as arg but what i can't understand is params file (i don't know what is the values inside it ) and also will the code generate model for me ?and after that i can send image to that model and the model will recognize it

i am bit confused can you help me to understand and make model on my own data set thanks in advance i appreciate your help

omoindrot commented 5 years ago

The parameters file contains all the hyper parameters of the model (ex: learning rate, number of layers...).

Maybe you should learn more about the basics of machine learning first, by following classes like these:

Tushn commented 5 years ago

I'm newbie in Keras (I was using Caffe and DLIB), I'm searching a way for reuse your tripletloss with other network.

But, "estimator" resource of Keras is new for me, and I cant see or reuse your layers like "model" objects to allow. For example, I can't use "model.summary()" for to print layers.

May you help me, with any tip?

omoindrot commented 5 years ago

You can use your own model, but just the triplet loss I defined.

See #18 for a discussion on how to use the loss with Keras.