GeorgeSeif / Semantic-Segmentation-Suite

Semantic Segmentation Suite in TensorFlow. Implement, train, and test new Semantic Segmentation models easily!
2.51k stars 880 forks source link

Could you add some information about data augmentation in the readme? #77

Closed andreruas closed 6 years ago

andreruas commented 6 years ago

What are your command line arguments?: python3 main.py --num_epochs 200 --batch_size 1 --h_flip true --brightness 10 --rotation 30 --model DeepLabV3-Res152 Have you written any custom code?: No TensorFlow version?: 1.8

Describe the problem

Hello, I've been using your library for a week or so now and it has been excellent overall. Thanks for putting together such a comprehensive and accessible package for deep learning.

I had a question about data augmentation though, and wasn't able to find an answer when looking through the readme or the code. I'm not completely sure what the units/limits are for the brightness augmentation (is it a percentage from 0 to 100, or 0 to 255)? Also, I have the same question with the rotation flag. Is it in degrees?

What have you done to try and solve this issue?: I'm asking this question because I've trained DeepLabv3-Res152 on the CamVid dataset a few times using your library with various settings (successfully), but last night I set the --brightness 10 and --rotation 30 flags for the first time. Unfortunately, the loss grew extremely high after a few epochs, and the model never converged. I figured the brightness would change by 10% and the rotation by 30 degrees: am I wrong about that?

Could you add a sentence or two explaining this in the readme? Again, thanks so much for putting together such an excellent package.

Source code / logs

[2018-06-26 08:44:25] Epoch = 499 Count = 400 Current_Loss = 10795887616.0000 Time = 2.12 [2018-06-26 08:44:27] Epoch = 499 Count = 420 Current_Loss = 22598909952.0000 Time = 2.13

GeorgeSeif commented 6 years ago

Hi there @andreruas, thanks for the feedback and thorough description of the issue!

Ah I see that it can be a bit confusing. So for the brightness, it's simply an exponential factor. You can see in this line:

table = np.array([((i / 255.0) ** factor) * 255 for i in np.arange(0, 256)]).astype(np.uint8)

that "factor" is applied as an exponent. I admit it is a bit confusing and it's fairly old code. I can probably change it to something a bit clearer and easier to use! I would honestly avoid using it for now as it should really be changed. I do like your idea/thought of having be a percentage though.

The rotation is simply in degrees :).

I'll finally be getting a new computer soon and be able to make more updates to the repo!

Let me know if you have any more questions

GeorgeSeif commented 6 years ago

Ah I actually decided to do a quick update. So I changed the brightness to be like you said as a percentage, but it's between 0 and 1 (so 10% max change is 0.1). I documented it in the command line args

andreruas commented 6 years ago

Thanks for the quick update, I appreciate it. After updating my code, however, I think you may have made a small mistake: using self.brightness instead of args.brightness. This is the error I got after running the main.py (the same command as above).

Traceback (most recent call last): File "main.py", line 288, in input_image, output_image = data_augmentation(input_image, output_image) File "main.py", line 109, in data_augmentation factor = 1.0 + random.uniform(-1.0*self.brightness, self.brightness) NameError: name 'self' is not defined

GeorgeSeif commented 6 years ago

Are you're right! Sorry, I don't have a GPU right now so I haven't been able to test anything. I'll be getting one soon though!. I'll change that one