Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_make_data_gen() and start_enqueueing_threads() #98

Closed
villanuevab opened this issue Jul 27, 2017 · 6 comments
Closed

_make_data_gen() and start_enqueueing_threads() #98

villanuevab opened this issue Jul 27, 2017 · 6 comments

Comments

@villanuevab
Copy link
Contributor

I'm not sure I understand what is happening in inputs/kitti_seg_input.py here: https://github.com/MarvinTeichmann/KittiSeg/blob/master/inputs/kitti_seg_input.py#L169-L173.

elif phase == 'train':
    yield jitter_input(hypes, image, gt_image)
    yield jitter_input(hypes, np.fliplr(image), np.fliplr(gt_image))

So, we are yielding 2 generators to the variable, gen, in L359:

gen = _make_data_gen(hypes, phase, data_dir)
gen.next() # but then why do we just iterate over it? 

But then why do we do the gen.next() in the following line, without making use of the returned value? What is the purpose of this portion of the code, in start_enqueueing_threads()?

@MarvinTeichmann
Copy link
Owner

Your assumption, that the second statement @L173 will never be reached is wrong.

The generator created by yield will jump back to the last yield keyword and execute the remainder of the function from there, pausing at the next yield command. You can test this behaviour using the minimal example below.

In [3]: def mygen():
   ...:     while True:
   ...:         yield 0
   ...:         yield 1
   ...:         
In [4]: gen = mygen()
In [5]: gen.next()
Out[5]: 0
In [6]: gen.next()
Out[6]: 1
In [7]: gen.next()
Out[7]: 0
In [8]: gen.next()
Out[8]: 1

@villanuevab
Copy link
Contributor Author

villanuevab commented Jul 28, 2017

Ah, yes. A quick review of yield statements and your response showed me that my starting assumption was wrong. Thank you!

@villanuevab
Copy link
Contributor Author

Does this mean that the dataset is effectively doubled during training? In particular, that there are two versions of the input image in the training data:

  1. the input image itself, and,
  2. a horizontally flipped copy of the input image

@MarvinTeichmann
Copy link
Owner

Yes, data augmentation like random flipping is used to increasing the amount of effectively available training data.

Other forms of data augmentation applied is random aspect ratio augmentation (random resize, random crop) and color augmentation (random brightness, random contrast, random saturation and random hue).

@wenouyang
Copy link

Hi Marvin, related to random resize or random crop, does that mean you the training set will have different image size when feeding to the network input?

@MarvinTeichmann
Copy link
Owner

If you use batch_size = 1 (default) you can train the network with variable image sizes (default and recommended).

For batch_sizes > 1 all inputs need the same size. That can be achieved by setting reseize_image or crop_patch to true. Resize_image will perform bilinear resize after the augmentation (if you use both random resize and random crop this means that still meaningful augmentation is done) . crop_patch will crop a random patch of fixed size on the image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants