I have the following preprocessing pipeline in Tensorflow:
data_transformation = tf.keras.Sequential([layers.experimental.preprocessing.RandomContrast(factor=(0.7,0.9)),layers.GaussianNoise(stddev=tf.random.uniform(shape=(),minval=0, maxval=1)), layers.experimental.preprocessing.RandomRotation(factor=0.1, fill_mode='reflect', interpolation='bilinear', seed=None, name=None, fill_value=0.0), layers.experimental.preprocessing.RandomZoom(height_factor=(0.1,0.2), width_factor=(0.1,0.2), fill_mode='reflect', interpolation='bilinear', seed=None, name=None, fill_value=0.0),])
I would like to change the layers.experimental.preprocessing.RandomContrast.py file to change how it works. However, I don't find such a file in my system. Whenever I found a file, it is an init.py file linking to a different directory. I know that, if I declare the following in the python terminal, It returns fine:
import tensorflow as tf
tf.image.random_contrast
But if I look for image in my tensorflow directory, the following returns to me
/usr/local/lib/python3.8/dist-packages/tensorflow/_api/v2/image
/usr/local/lib/python3.8/dist-packages/tensorflow/_api/v2/compat/v1/image
/usr/local/lib/python3.8/dist-packages/tensorflow/_api/v2/compat/v2/image
/usr/local/lib/python3.8/dist-packages/tensorflow/include/tensorflow/core/kernels/image
/usr/local/lib/python3.8/dist-packages/tensorflow/keras/preprocessing/image
/usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/api/_v1/keras/preprocessing/image
/usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/api/keras/preprocessing/image
/usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/api/_v2/keras/preprocessing/image
All of these directories point to init.py files again. And it seems in an infinite loop looking for directories that are redirected by init.py files. How am I supposed to find the specific .py file of a specific import in python?
CodePudding user response:
You can search on the web for :
tf layers.experimental.preprocessing.RandomContrast
Then follow the first link : RandomContrast and finally click on view source on github which will go here: image_preprocessing.py