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
9f205b4b
Commit
9f205b4b
authored
4 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Added a generic class to define label mappings.
parent
1be8822b
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/constants.py
+28
-20
28 additions, 20 deletions
pysegcnn/core/constants.py
with
28 additions
and
20 deletions
pysegcnn/core/constants.py
+
28
−
20
View file @
9f205b4b
...
@@ -77,24 +77,6 @@ class Sentinel2(MultiSpectralSensor):
...
@@ -77,24 +77,6 @@ class Sentinel2(MultiSpectralSensor):
swir2
=
12
swir2
=
12
class
Gdal2Numpy
(
enum
.
Enum
):
"""
Data type mapping from gdal to numpy.
"""
Byte
=
np
.
uint8
UInt8
=
np
.
uint8
Int8
=
np
.
int8
UInt16
=
np
.
uint16
Int16
=
np
.
int16
UInt32
=
np
.
uint32
Int32
=
np
.
int32
Float32
=
np
.
float32
Float64
=
np
.
float64
CInt16
=
np
.
complex64
CInt32
=
np
.
complex64
CFloat32
=
np
.
complex64
CFloat64
=
np
.
complex64
class
Label
(
enum
.
Enum
):
class
Label
(
enum
.
Enum
):
"""
Generic enumeration for class labels.
"""
"""
Generic enumeration for class labels.
"""
...
@@ -112,8 +94,34 @@ class Label(enum.Enum):
...
@@ -112,8 +94,34 @@ class Label(enum.Enum):
def
label_dict
(
cls
):
def
label_dict
(
cls
):
"""
Return the enumeration as a nested dictionary.
"""
"""
Return the enumeration as a nested dictionary.
"""
return
{
label
.
id
:
{
'
label
'
:
label
.
name
.
replace
(
'
_
'
,
'
'
),
return
{
label
.
id
:
{
'
label
'
:
label
.
name
.
replace
(
'
_
'
,
'
'
),
'
color
'
:
label
.
color
}
'
color
'
:
label
.
color
}
for
label
in
cls
}
for
_
,
label
in
cls
.
__members__
.
items
()}
class
LabelMapping
(
enum
.
Enum
):
"""
Generic enumeration for mapping label classes.
"""
@classmethod
def
label_map
(
cls
):
"""
Return the label mapping dictionary.
"""
return
{
label
.
name
:
label
.
value
for
label
in
cls
}
class
Gdal2Numpy
(
LabelMapping
):
"""
Data type mapping from gdal to numpy.
"""
Byte
=
np
.
uint8
UInt8
=
np
.
uint8
Int8
=
np
.
int8
UInt16
=
np
.
uint16
Int16
=
np
.
int16
UInt32
=
np
.
uint32
Int32
=
np
.
int32
Float32
=
np
.
float32
Float64
=
np
.
float64
CInt16
=
np
.
complex64
CInt32
=
np
.
complex64
CFloat32
=
np
.
complex64
CFloat64
=
np
.
complex64
class
SparcsLabels
(
Label
):
class
SparcsLabels
(
Label
):
...
...
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