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

AI Thread Summary
The discussion focuses on issues related to using a custom dataset with the Pix2pix image-to-image translation tutorial. The user is trying to understand the input to the `load_image_train` function, which accepts a single image filename and returns two processed images. They are encountering errors when mapping their own dataset, particularly when unzipping tuples of image paths. The user is also confused about the TensorFlow data types being printed during execution. Overall, the conversation highlights challenges in building an input pipeline with TensorFlow's `tf.data` API for custom datasets.
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
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
2
Views
1K
Back
Top