Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PySegCNN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
earth_observation_public
PySegCNN
Commits
2ac1b506
Commit
2ac1b506
authored
4 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Removed cval kwarg: is now set automatically
parent
391743ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pysegcnn/core/dataset.py
+13
-25
13 additions, 25 deletions
pysegcnn/core/dataset.py
with
13 additions
and
25 deletions
pysegcnn/core/dataset.py
+
13
−
25
View file @
2ac1b506
...
@@ -18,6 +18,7 @@ import csv
...
@@ -18,6 +18,7 @@ import csv
import
glob
import
glob
import
enum
import
enum
import
itertools
import
itertools
import
logging
# externals
# externals
import
numpy
as
np
import
numpy
as
np
...
@@ -30,6 +31,9 @@ from pysegcnn.core.constants import (Landsat8, Sentinel2, Label, SparcsLabels,
...
@@ -30,6 +31,9 @@ from pysegcnn.core.constants import (Landsat8, Sentinel2, Label, SparcsLabels,
from
pysegcnn.core.utils
import
(
img2np
,
is_divisible
,
tile_topleft_corner
,
from
pysegcnn.core.utils
import
(
img2np
,
is_divisible
,
tile_topleft_corner
,
parse_landsat_scene
,
parse_sentinel2_scene
)
parse_landsat_scene
,
parse_sentinel2_scene
)
# module level logger
LOGGER
=
logging
.
getLogger
(
__name__
)
# generic image dataset class
# generic image dataset class
class
ImageDataset
(
Dataset
):
class
ImageDataset
(
Dataset
):
...
@@ -60,10 +64,7 @@ class ImageDataset(Dataset):
...
@@ -60,10 +64,7 @@ class ImageDataset(Dataset):
# whether to pad the image to be evenly divisible in square tiles
# whether to pad the image to be evenly divisible in square tiles
# of size (tile_size x tile_size)
# of size (tile_size x tile_size)
'
pad
'
:
False
,
'
pad
'
:
False
# the value to pad the samples
'
cval
'
:
0
,
}
}
...
@@ -130,25 +131,12 @@ class ImageDataset(Dataset):
...
@@ -130,25 +131,12 @@ class ImageDataset(Dataset):
# always use the original dataset together with the augmentations
# always use the original dataset together with the augmentations
self
.
transforms
=
[
None
]
+
self
.
transforms
self
.
transforms
=
[
None
]
+
self
.
transforms
# check if the padding value is equal to any of the class
# when padding, add a new "no data" label to the ground truth
# identifiers in the ground truth mask
if
self
.
pad
and
sum
(
self
.
padding
)
>
0
:
if
self
.
pad
and
sum
(
self
.
padding
)
>
0
:
if
self
.
cval
in
self
.
labels
.
keys
():
self
.
cval
=
max
(
self
.
labels
)
+
1
raise
ValueError
(
'
Constant padding value cval={} is not
'
self
.
labels
[
self
.
cval
]
=
{
'
label
'
:
'
No data
'
,
'
color
'
:
'
black
'
}
'
allowed: class
"
{}
"
is represented as {} in
'
LOGGER
.
info
(
'
Adding label
"
No data
"
with value={} to ground truth.
'
'
the ground truth.
'
.
format
(
self
.
cval
))
.
format
(
self
.
cval
,
self
.
labels
[
self
.
cval
][
'
label
'
],
self
.
cval
)
)
# add the "no data" label to the class labels of the ground truth
else
:
if
not
0
<=
self
.
cval
<=
255
:
raise
ValueError
(
'
Expecting 0 <= cval <= 255, got cval={}.
'
.
format
(
self
.
cval
))
print
(
'
Adding label
"
No data
"
with value={} to ground truth.
'
.
format
(
self
.
cval
))
self
.
labels
[
self
.
cval
]
=
{
'
label
'
:
'
No data
'
,
'
color
'
:
'
black
'
}
def
_build_labels
(
self
):
def
_build_labels
(
self
):
return
{
band
.
id
:
{
'
label
'
:
band
.
name
.
replace
(
'
_
'
,
'
'
),
return
{
band
.
id
:
{
'
label
'
:
band
.
name
.
replace
(
'
_
'
,
'
'
),
...
@@ -446,9 +434,9 @@ class StandardEoDataset(ImageDataset):
...
@@ -446,9 +434,9 @@ class StandardEoDataset(ImageDataset):
gt
=
gt
.
pop
()
gt
=
gt
.
pop
()
except
IndexError
:
except
IndexError
:
print
(
'
Skipping scene {}: ground truth not available
'
LOGGER
.
info
(
'
Skipping scene {}: ground truth not available
'
'
(pattern = {}).
'
'
(pattern = {}).
'
.
format
(
scene
[
'
id
'
],
.
format
(
scene
[
'
id
'
],
self
.
gt_pattern
))
self
.
gt_pattern
))
continue
continue
# iterate over the tiles
# iterate over the tiles
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment