I new in TF, I tried the classic flowers recognition sample:
I replicate this in PyCharm and it works but I dont’ understand how to test this script passing some real flowers picture to test this in real world.
Thank in advance
I new in TF, I tried the classic flowers recognition sample:
I replicate this in PyCharm and it works but I dont’ understand how to test this script passing some real flowers picture to test this in real world.
Thank in advance
You can follow this tutorial to get an idea. Go through the particular section I linked and if there’s any doubt, let me know.
If you want to play with this on your Android device camera you could try to follow this tutorial:
Many thanks for info.
I’m trying to create a custom classification using my set of images but I’m getting lost in hundreds of examples all different each other.
Regards
Hi @Paolo_Pini You can try tf.keras.Model.predict
as in name_of_your_model.predict(...)
(be mindful of tensor shapes).
Examples:
Predict on new data
Finally, let’s use our model to classify an image that wasn’t included in the training or validation sets.
…
sunflower_url = "https://storage.googleapis.com/download.tensorflow.org/example_images/592px-Red_sunflower.jpg" sunflower_path = tf.keras.utils.get_file('Red_sunflower', origin=sunflower_url) img = keras.preprocessing.image.load_img( sunflower_path, target_size=(img_height, img_width) ) img_array = keras.preprocessing.image.img_to_array(img) img_array = tf.expand_dims(img_array, 0) # Create a batch predictions = model.predict(img_array) ...
Now, define a simple custom callback that logs:
- When
fit
/evaluate
/predict
starts & ends- When each epoch starts & ends
- When each training batch starts & ends
- When each evaluation (test) batch starts & ends
- When each inference (prediction) batch starts & ends
…class CustomCallback(keras.callbacks.Callback): ... ... res = model.predict(x_test, batch_size=128, callbacks=[CustomCallback()])