Python Pix2pix: Image-to-image translation with a conditional GAN

Click For Summary
SUMMARY

The forum discussion focuses on implementing an input pipeline for image processing using TensorFlow's tf.data API in the context of the Pix2pix model. The user seeks clarification on the function load_image_train, which processes a single image file and returns two images: input_image and real_image. The discussion highlights issues with the mapping of the dataset and the handling of tuples within the TensorFlow pipeline, specifically when combining reference images and drawings.

PREREQUISITES
  • Familiarity with TensorFlow 2.x and its tf.data API
  • Understanding of image preprocessing techniques such as normalization and random jittering
  • Knowledge of Python programming, particularly with functions and data structures
  • Basic concepts of Generative Adversarial Networks (GANs), specifically Pix2pix architecture
NEXT STEPS
  • Explore TensorFlow's tf.data.Dataset documentation for advanced input pipeline techniques
  • Learn about image augmentation methods in TensorFlow to enhance dataset diversity
  • Investigate debugging techniques for TensorFlow functions, especially with tf.function()
  • Study the Pix2pix model architecture and its implementation details in TensorFlow
USEFUL FOR

Machine learning practitioners, data scientists, and developers working on image-to-image translation tasks using TensorFlow, particularly those implementing the Pix2pix model.

btb4198
Messages
570
Reaction score
10
So I am trying to do this tutorials but I want to use my own dataset. I am having problems "Build an input pipeline with tf.data."
My question is about their code:
[CODE title="load_image_train"]def load_image_train(image_file):
input_image, real_image = load(image_file)
input_image, real_image = random_jitter(input_image, real_image)
input_image, real_image = normalize(input_image, real_image)

return input_image, real_image[/CODE][CODE title="Build an input pipeline with tf.data"]train_dataset = tf.data.Dataset.list_files(str(PATH / 'train/*.jpg'))
train_dataset = train_dataset.map(load_image_train,
num_parallel_calls=tf.data.AUTOTUNE)
train_dataset = train_dataset.shuffle(BUFFER_SIZE)
train_dataset = train_dataset.batch(BATCH_SIZE)[/CODE]

when they call load_image_train, are they sending a list of images or just one image?
I am really not liking this Not displaying type stuff
 
Technology news on Phys.org
btb4198 said:
So I am trying to do this tutorials but I want to use my own dataset. I am having problems "Build an input pipeline with tf.data."
My question is about their code:
[CODE title="load_image_train"]def load_image_train(image_file):
input_image, real_image = load(image_file)
input_image, real_image = random_jitter(input_image, real_image)
input_image, real_image = normalize(input_image, real_image)

return input_image, real_image[/CODE][CODE title="Build an input pipeline with tf.data"]train_dataset = tf.data.Dataset.list_files(str(PATH / 'train/*.jpg'))
train_dataset = train_dataset.map(load_image_train,
num_parallel_calls=tf.data.AUTOTUNE)
train_dataset = train_dataset.shuffle(BUFFER_SIZE)
train_dataset = train_dataset.batch(BATCH_SIZE)[/CODE]

when they call load_image_train, are they sending a list of images or just one image?
I am really not liking this Not displaying type stuff
What looks to me like what's happening is that load_image_train has a single image file as its input, but returns two image files: input_image and real_image.
 
btb4198 said:
when they call load_image_train, are they sending a list of images or just one image?
The load_image_train function takes a single image filename as its argument.

The effect of the map method call is to call load_image_train once for each filename in a list of filenames returned by the list_files method call.
 
I am getting a very weird error when I am trying to Build an input pipeline with tf.data. I am combining my reference image and my drawing into a tuple. Then I added to that to list. This should work,
but now I am getting this weird error at this line:
train_dataset = train_dataset.map(load_image_train, num_parallel_calls=tf.data.AUTOTUNE)

Here is my code:
Code:
@tf.function()
def load_image_train(a_training_datapoint):
 print(type(a_training_datapoint))
 print("here 1")
 real_image_path, drawing_path = zip(*a_training_datapoint)
 print("here 2")
 real_image = convert_images_to_tensor(real_image_path)
 print("here 3")
 drawing_image = convert_images_to_tensor(drawing_path)
 real_image, drawing_image = random_jitter(real_image, drawing_image)
 real_image, drawing_image = normalize(real_image, drawing_image)
return real_image, drawing_image

and then I have this:

Code:
test_dataset_list = []
for data in test_set:
 test_dataset_list.append(zip(data.reference_image, data.drawing))
print(test_dataset_list)
Here 1 is the only one that prints out.

so it seem to not like how I am unzipping my tuple, but I am sure I am doing it right.

Also it say this : <class 'tensorflow.python.framework.ops.Tensor'>

when I am printing out the type for the a_test_datapoint
 
We have many threads on AI, which are mostly AI/LLM, e.g,. ChatGPT, Claude, etc. It is important to draw a distinction between AI/LLM and AI/ML/DL, where ML - Machine Learning and DL = Deep Learning. AI is a broad technology; the AI/ML/DL is being developed to handle large data sets, and even seemingly disparate datasets to rapidly evaluated the data and determine the quantitative relationships in order to understand what those relationships (about the variaboles) mean. At the Harvard &...

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K