-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Train WildFire #64
Train WildFire #64
Conversation
Codecov Report
@@ Coverage Diff @@
## master #64 +/- ##
=======================================
Coverage 83.85% 83.85%
=======================================
Files 19 19
Lines 706 706
=======================================
Hits 592 592
Misses 114 114 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
There seems to be an issues with overlapping modifications with #63. Could you take a look please?
if ratios['test'] > 0: | ||
fire_ids = {'train': self._get_fire_ids_for_one_split(n_samples_train), | ||
'val': self._get_fire_ids_for_one_split(n_samples_val)} | ||
fire_ids['test'] = [id_ for id_ in self._fire_id_to_size | ||
if id_ not in (fire_ids['train'] + fire_ids['val'])] | ||
# Finish exhaustion | ||
for fire_id_test in fire_ids['test']: | ||
del self._fire_id_to_size_to_exhaust[fire_id_test] | ||
|
||
else: | ||
fire_ids = {'train': self._get_fire_ids_for_one_split(n_samples_train)} | ||
fire_ids['val'] = [id_ for id_ in self._fire_id_to_size if id_ not in fire_ids['train']] | ||
# Finish exhaustion | ||
for fire_id_test in fire_ids['val']: | ||
del self._fire_id_to_size_to_exhaust[fire_id_test] | ||
fire_ids['test'] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this supposed to be in #63 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you cancel out this modif please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done !
# if wildfire.metadata['fire_id'].nunique() != wildfire.metadata['fire_id'].max() + 1: | ||
# warnings.warn(f"Inconsistent Fire Labeling. Maybe try to label the fire again\n" | ||
# f"Distinct values of ids({wildfire.metadata['fire_id'].nunique()}" | ||
# f" ≠ {wildfire.metadata['fire_id'].max() + 1})", Warning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
test/test_datasets_wildfire_split.py
Outdated
def test_splitting_with_test_to_zero(self): | ||
ratios = {'train': 0.81, 'val': 0.19, 'test': 0} | ||
|
||
splitter = WildFireSplitter(ratios, seed=42) | ||
splitter.fit(self.wildfire) | ||
|
||
for (set_, ratio_) in splitter.ratios_.items(): | ||
self.assertAlmostEqual(ratio_, ratios[set_], places=2) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! A few changes and some transformation choices that I'm having doubts about, let me know your thoughts about the comments!
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) | ||
|
||
train_transforms = transforms.Compose([ | ||
transforms.RandomResizedCrop(size=args.resize // 7, scale=(0.8, 1.0)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a pretty big loss of information with a relative output size of 1/7
. Perhaps we should directly resize to target size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a mistake, I didn't want to lose so much information. Thank you, that's corrected. I also deleted one of the two crops.
transforms.RandomRotation(degrees=15), | ||
transforms.ColorJitter(), | ||
transforms.RandomHorizontalFlip(), | ||
transforms.CenterCrop(size=args.resize), # Image net standards |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally CenterCrop is used for eval but not train set. Having two crop transformations seems unnecessary. It might be better to stick with RandomResizedCrop but discard CenterCrop
]) | ||
|
||
val_transforms = transforms.Compose([ | ||
transforms.Resize(size=args.resize // 7), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here for the small resize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small change to make for eval transformations but the rest looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only some side modifications to cancel out, the rest looks good!
if ratios['test'] > 0: | ||
fire_ids = {'train': self._get_fire_ids_for_one_split(n_samples_train), | ||
'val': self._get_fire_ids_for_one_split(n_samples_val)} | ||
fire_ids['test'] = [id_ for id_ in self._fire_id_to_size | ||
if id_ not in (fire_ids['train'] + fire_ids['val'])] | ||
# Finish exhaustion | ||
for fire_id_test in fire_ids['test']: | ||
del self._fire_id_to_size_to_exhaust[fire_id_test] | ||
|
||
else: | ||
fire_ids = {'train': self._get_fire_ids_for_one_split(n_samples_train)} | ||
fire_ids['val'] = [id_ for id_ in self._fire_id_to_size if id_ not in fire_ids['train']] | ||
# Finish exhaustion | ||
for fire_id_test in fire_ids['val']: | ||
del self._fire_id_to_size_to_exhaust[fire_id_test] | ||
fire_ids['test'] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you cancel out this modif please?
test/test_datasets_wildfire_split.py
Outdated
def test_splitting_with_test_to_zero(self): | ||
ratios = {'train': 0.81, 'val': 0.19, 'test': 0} | ||
|
||
splitter = WildFireSplitter(ratios, seed=42) | ||
splitter.fit(self.wildfire) | ||
|
||
for (set_, ratio_) in splitter.ratios_.items(): | ||
self.assertAlmostEqual(ratio_, ratios[set_], places=2) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you cancel out this modification? The rest of the PR looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Added some comments to let the ability of optimizer change and tensor shape for targets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the changes!
* Allow test ratio to zero in WildFireSplitter * fix flake8 * add training script for Wildfire * add a test to improve code coverage * put back the warning on FireIds * Fix size in RandomCrop and delete CenterCrop * add centercrop to get square images * remove change already made in PR pyronear#63
The purpose of this PR is to add a basic training loop for the wildfire dataset. This is far from being optimal in terms of performance but it can be considered as a first baseline.