Comments (7)
Hello @jaimerodric ,
Sorry for the late response. As the output is a normal tf.data.Dataset
you can use the apply function normally after creating the dataset from the generator.
from kerasgen.
@ma7555
Thanks for your response! That's a smart solution. If I am not wrong, the images are loaded as RGB, right? I want to confirm this because when testing, if I load images with opencv, they are in BGR form and should I convert it ro RGB?
I am trying to train a network from scratch and I am struggling, I do not know if it is because working with only 200k images, the generator, the network...
from kerasgen.
The images are loaded in RGB as tf.Tensor, to use a preprocessing function you need to use the apply method I mentioned but make sure all the transformations are done using tf ops and not numpy.
If you need to use numpy or other pythonic functions please refer to tf.numpy_function
and tf.function
from kerasgen.
@ma7555
Thanks again for the response. What margin have you tested that is the better for training? Because the TripletSemiHardLoss, it is by default established on 1, but from my point of view it does not make sense when there is a normalization L2 at the end of the network (normalized output of 1)
from kerasgen.
I have not experimented with changing the margin. But keeping it default worked well for me.
from kerasgen.
Hi again @ma7555 !
I am struggling applying the preprocessing function. I have implemented one that is like this:
def pre_process_facenet(dataset):
x_images = []
for ret in dataset:
# standardize pixel values across channels (global)
mean, std = ret.mean(), ret.std()
ret = (ret - mean) / std
x_images.append(ret)
return np.array(x_images)
train_ds = balanced_image_dataset_from_directory(
directory, num_classes_per_batch=5,
num_images_per_class=5, image_size=(160, 160),
seed=6, validation_split=0.2, subset='training',
safe_triplet=True)
But when using apply on the dataset generated with kerasgen I got some errors
train_ds = train_ds.apply(tf.numpy_function(pre_process_facenet, train_ds, tf.float32))
ValueError: could not broadcast input array from shape (25,160,160,3) into shape (25,)
What I am doing wrong? I want to apply pre_process_facenet in train_ds and then into the fit method of TF
from kerasgen.
mimo-Keras package (https://pypi.org/project/mimo-keras/) can help you to create your pipeline without additional coding
from kerasgen.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kerasgen.