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

In summary: I get this:here 1In summary, the load_image_train function takes a single image filename as its input and returns two image files: input_image and real_image.
  • #1
btb4198
572
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:
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
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)

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
  • #2
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:
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
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)

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.
 
  • #3
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.
 
  • #4
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
 

1. What is Pix2pix?

Pix2pix is a deep learning model that uses a conditional generative adversarial network (GAN) to perform image-to-image translation. This means it takes in an input image and outputs a corresponding image in a different style or with different attributes.

2. How does Pix2pix work?

Pix2pix works by training a generator and a discriminator network simultaneously. The generator takes in an input image and produces a new image, while the discriminator tries to determine if the new image is real or fake. This creates a feedback loop that allows the generator to improve its output over time.

3. What is a conditional GAN?

A conditional GAN is a type of GAN that incorporates additional information, such as class labels or input images, to guide the generation process. In Pix2pix, the conditional GAN takes in the input image and uses it to produce a realistic output image.

4. What are some applications of Pix2pix?

Pix2pix has been used for a variety of applications, including image colorization, style transfer, and image editing. It has also been used in the fields of computer vision and robotics for tasks such as object detection and image segmentation.

5. What are some limitations of Pix2pix?

Some limitations of Pix2pix include its reliance on training data, which can be time-consuming and expensive to collect, and its tendency to produce blurry or distorted images in some cases. It also struggles with translating complex or abstract concepts, such as human faces, accurately.

Similar threads

  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
Back
Top