tensorflow2.0

Tensorflow Object Detection and Image Cropping for Data Extraction

Tensorflow Object Detection and Image Cropping for Data Extraction Question: Below is my code that detect the regions (tables, paragraphs) from invoice and and crop the detected region from the invoice. I am facing issues while performing data extraction on cropped images as images are very small. I am passing cropped image to tesseract for …

Total answers: 1

Add a gaussian noise to a Tensorflow Dataset

Add a gaussian noise to a Tensorflow Dataset Question: I have a CSVDataset which has around 6 million rows. For the purposes of this question I am making a TensorSliceDataset as following:- import tensorflow as tf import numpy as np datasetz = tf.data.Dataset.from_tensor_slices((np.random.randn(10, 5), np.random.randn(10,1))) datasetz = datasetz.map(lambda x, y: (x, x)) datasetz # <MapDataset …

Total answers: 1

Apply preprocessing only to images , not to masks

Apply preprocessing only to images , not to masks Question: I have a dataset which has images and masks. images_p = tf.keras.utils.image_dataset_from_directory( path_imgs, batch_size=None, shuffle=False, label_mode=None) masks_p = tf.keras.utils.image_dataset_from_directory( path_masks, batch_size=None, shuffle=False, label_mode=None, color_mode=’grayscale’) dataset = tf.data.Dataset.zip((images_p, masks_p)) Now, I want to apply some preprocessing. But, it will be different for images and masks. For …

Total answers: 1

How to Save a Tensorflow Dataset

How to Save a Tensorflow Dataset Question: As the title says I’m trying to save a TensorSliceDataset object to file. Viewing tensorflow’s website it seems that the tf.data.Dataset class has a save function but it is not implemented for TensorSliceDataset objects. Pickling also did not work for me. Example code import tensorflow as tf t …

Total answers: 3

create tensorflow dataset from list_files

create tensorflow dataset from list_files Question: I am trying to create tensroflow dataset : path_imgs = (‘./images/train/*.jpg’) path_masks =(‘./masks/train/*.jpg’ images = tf.data.Dataset.list_files(path_imgs, shuffle=False) masks = tf.data.Dataset.list_files(path_masks, shuffle=False) dataset = tf.data.Dataset.from_tensor_slices((tf.constant(path_imgs), tf.constant(path_masks))) and I am receiving: Unbatching a tensor is only supported for rank >= 1 Asked By: George || Source Answers: Try something like this: …

Total answers: 1

Tensorflow finds GPU but doesn't use GPU

Tensorflow finds GPU but doesn't use GPU Question: Recently bought a 3060 and trying to make it work with tensorflow but it doesn’t seem to work. Although the GPU can be detected, whenever I train mask_rcnn_coco.h5 it takes so much time that I left it for like 30 minutes and not even 1 epoch was …

Total answers: 1

Vectorized calculation of grouped metrics in tensorflow

Vectorized calculation of grouped metrics in tensorflow Question: Using Tensorflow, I need to calculate multiple grouped metrics (e.g. mean) from a tensor, based on groups that are given by a second tensor. A a toy example, let’s say I got: values = tf.constant([[1], [1.5], [2], [2.5], [3], [3.5]]) groupings = tf.constant([1,3,2,1,2,3]) And want to calculate: …

Total answers: 1

subclassing API: expected 'trainable' argument to be a boolean TF2

subclassing API: expected 'trainable' argument to be a boolean TF2 Question: I am following a tutorial for TensorFlow subclassing API: https://www.youtube.com/watch?v=WcZ_1IAH_nM&ab_channel=AladdinPersson When executing the code, I receive the following error: TypeError: Expected `trainable` argument to be a boolean, but got: [32, 32, 64] Which from what I gather comes from the ResBlock (as if trying …

Total answers: 1

Reduce max in tensorflow for grouping rows?

Reduce max in tensorflow for grouping rows? Question: I have a tensor I want to calculate max in every column grouped by certain rows. Eg: tensor_eg = [[0.1 0.2 0.4 0.5], [0.1 0.8 0.2 0.5], [0.1 0.2 0.4 0.5], [0.1 0.1 0.6 0.5]] tf.reduce_max(tensor_eg, axis = 0) would give me the max value for each …

Total answers: 1