cansado2930
cansado2930

Reputation: 339

how to add more classes of images to train of tensorflow

The first sorry if the question is very noob. I ‘m train a tensorflow with different images, for example, the six flowers of sample. When the tensor flow receives an image for example of a living room that there aren’t flowers, it shows 22% of it is sunflowers…. I need to recognize the flowers… but if the user show other thing that it isn’t of objective… the tensor flow doesn’t say that it is one type of flower with a lot of percentage…

I can’t to put the accuracy with a high value, because when it receives for example a sunflower, it says that it is a sunflower with 3%.

If I have to train from scratch of all photos… the main problem is where can I find a bank of images as mobileNetV2 and they are ready to train? It is impossible if I have searched well. So, my question is the following. Is possible to add the train flowers to mobileNetV2 that is available on the sample? If the answer is yes, could you share me some sample of script? Thank you

Upvotes: 0

Views: 172

Answers (1)

user11530462
user11530462

Reputation:

To train mobilenet_v2 on your own dataset, you have to get the feature vectors of modilenet_v2 from the tensorflow hub.

image_module = hub.KerasLayer('https://tfhub.dev/google/tf2-preview/mobilenet_v2/feature_vector/4',input_shape=(224,224,3),trainable=False)

Then you have to add the dense layer to the model based on your classes.

For example if i am training mobilenet_v2 on a dataset that has 5 classes, I will add a dense layer of 5 units.

model=tf.keras.Sequential([image_module,
                           tf.keras.layers.Dense(5,activation='softmax')]) 

Then you can train the model on your own dataset.

You can refer to this gist for the implementation.

Upvotes: 1

Related Questions