-
Notifications
You must be signed in to change notification settings - Fork 387
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
MultiBands, and tools improvements (mostly) #138
base: master
Are you sure you want to change the base?
Changes from all commits
213540e
6991719
bbd86a3
9c9b307
d51393d
d8f1686
43a6050
b20e5a4
73933fd
fd4ca3b
29935f6
2e97d16
dd15457
822bae7
0b86808
1e43632
48115d2
82c2bcd
f2e6405
b0c554c
fab73f9
e68d8f5
236f471
69ef557
249107b
1407730
2fe3864
3f27682
8da0e8b
b2a76dd
4946f6f
de654a4
bf30a22
173a60d
98efc71
350d46f
7a5eae4
275f017
47364ea
9b0588c
9457880
f9e788b
c874a04
2270d49
6a55b2b
b75c3b1
13d4f7c
d260eef
7c88599
7083cb9
aad94fc
8f1faca
5ade9f2
e6a5f87
1bf590a
4e795e0
23b9b96
ce12ab5
9ce1782
3218253
f79fa97
b20561d
ccc7e8d
16a985d
bc82113
008398e
583f1ce
47d91a4
293673e
e3cfd3a
cce48b6
30a68ad
42c110b
6ead578
6aba3a7
a0fd555
d3dbd89
57f3bc4
01ea0b2
b4391d3
3612d70
0433e26
ed16e8f
53b0b4e
e02dffd
1a451d3
0fa123e
0c6fff7
24716db
bcf13ce
552ffb5
0504df5
9f3eb8f
0aa7f46
d7e8559
c628975
a59d971
9b8f94e
bb2dcf8
b28b2c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Daniel J. Hofmann <[email protected]> https://github.com/daniel-j-h | ||
|
||
Bhargav Kowshik <[email protected]> https://github.com/bkowshik | ||
|
||
Olivier Courtin <[email protected]> https://github.com/ocourtin | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# RoboSat Configuration | ||
# For syntax see: https://github.com/toml-lang/toml#table-of-contents | ||
|
||
[dataset] | ||
# The slippy map dataset's base directory. | ||
path = '/tmp/slippy-map-dir/' | ||
|
||
# Dataset specific class weights computes on the training data. | ||
# Needed by 'mIoU' and 'CrossEntropy' losses to deal with unbalanced classes. | ||
# Note: use `./rs weights -h` to compute these for new datasets. | ||
weights = [1.6248, 5.762827] | ||
|
||
|
||
[classes] | ||
# Human representation for classes. | ||
titles = ['background', 'parking'] | ||
|
||
# Color map for visualization and representing classes in masks. | ||
# Note: available colors are either CSS3 colors names or #RRGGBB hexadecimal representation. | ||
colors = ['denim', 'orange'] | ||
|
||
|
||
# Channels configuration let your indicate wich dataset sub-directory and bands to take as input | ||
# You could so, add several channels blocks to compose your input Tensor. Orders are meaningful. | ||
[[channels]] | ||
sub = "images" | ||
bands = [1,2,3] | ||
|
||
|
||
# Model specific attributes. | ||
[model] | ||
|
||
# Batch size for training. | ||
batch_size = 2 | ||
|
||
# Image side size in pixels. | ||
image_size = 512 | ||
|
||
# Total number of epochs to train for. | ||
epochs = 10 | ||
|
||
# Learning rate for the optimizer. | ||
lr = 0.0001 | ||
|
||
# Weight decay l2 penalty for the optimizer | ||
decay = 0.0001 | ||
|
||
# Loss function name (e.g 'Lovasz', 'mIoU' or 'CrossEntropy') | ||
loss = 'Lovasz' | ||
|
||
# Data augmentation, Flip or Rotate probability | ||
data_augmentation = 0.75 | ||
|
||
# Use ImageNet weights pretraining | ||
pretrained = true |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ FROM ubuntu:16.04 | |
# See: https://github.com/skvark/opencv-python/issues/90 | ||
RUN apt-get update -qq && \ | ||
apt-get install -qq -y -o quiet=1 \ | ||
python3 python3-dev python3-tk python3-pip build-essential libboost-python-dev libexpat1-dev zlib1g-dev libbz2-dev libspatialindex-dev libsm6 | ||
python3 python3-dev python3-tk python3-pip build-essential libboost-python-dev libexpat1-dev zlib1g-dev libbz2-dev libspatialindex-dev libsm6 libwebp-dev libjpeg-turbo8-dev | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to add these new system-wide native deps to the readme installation instructions, too. For users not running the dockerized image. |
||
|
||
WORKDIR /app | ||
ADD . /app | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,76 +2,30 @@ | |
""" | ||
|
||
import colorsys | ||
|
||
from enum import Enum, unique | ||
|
||
|
||
# Todo: user should be able to bring her own color palette. | ||
# Functions need to account for that and not use one palette. | ||
|
||
|
||
def _rgb(v): | ||
r, g, b = v[1:3], v[3:5], v[5:7] | ||
return int(r, 16), int(g, 16), int(b, 16) | ||
|
||
|
||
@unique | ||
class Mapbox(Enum): | ||
"""Mapbox-themed colors. | ||
|
||
See: https://www.mapbox.com/base/styling/color/ | ||
""" | ||
|
||
dark = _rgb("#404040") | ||
gray = _rgb("#eeeeee") | ||
light = _rgb("#f8f8f8") | ||
white = _rgb("#ffffff") | ||
cyan = _rgb("#3bb2d0") | ||
blue = _rgb("#3887be") | ||
bluedark = _rgb("#223b53") | ||
denim = _rgb("#50667f") | ||
navy = _rgb("#28353d") | ||
navydark = _rgb("#222b30") | ||
purple = _rgb("#8a8acb") | ||
teal = _rgb("#41afa5") | ||
green = _rgb("#56b881") | ||
yellow = _rgb("#f1f075") | ||
mustard = _rgb("#fbb03b") | ||
orange = _rgb("#f9886c") | ||
red = _rgb("#e55e5e") | ||
pink = _rgb("#ed6498") | ||
import webcolors | ||
import numpy as np | ||
|
||
|
||
def make_palette(*colors): | ||
"""Builds a PIL-compatible color palette from color names. | ||
"""Builds a PIL-compatible color palette from CSS3 color names, or hex values patterns as #RRGGBB | ||
|
||
Args: | ||
colors: variable number of color names. | ||
""" | ||
|
||
rgbs = [Mapbox[color].value for color in colors] | ||
flattened = sum(rgbs, ()) | ||
return list(flattened) | ||
|
||
|
||
def color_string_to_rgb(color): | ||
"""Convert color string to a list of RBG integers. | ||
assert 0 < len(colors) <= 256 | ||
|
||
Args: | ||
color: the string color value for example "250,0,0" | ||
|
||
Returns: | ||
color: as a list of RGB integers for example [250,0,0] | ||
""" | ||
hexs = [webcolors.CSS3_NAMES_TO_HEX[color] if color[0] != "#" else color for color in colors] | ||
rgbs = [(int(h[1:3], 16), int(h[3:5], 16), int(h[5:7], 16)) for h in hexs] | ||
|
||
return [*map(int, color.split(","))] | ||
return list(sum(rgbs, ())) | ||
|
||
|
||
def continuous_palette_for_color(color, bins=256): | ||
"""Creates a continuous color palette based on a single color. | ||
|
||
Args: | ||
color: the rgb color tuple to create a continuous palette for. | ||
color: the CSS3 color name or it's hex values as #RRGGBB, to create a continuous palette for. | ||
bins: the number of colors to create in the continuous palette. | ||
|
||
Returns: | ||
|
@@ -81,15 +35,29 @@ def continuous_palette_for_color(color, bins=256): | |
# A quick and dirty way to create a continuous color palette is to convert from the RGB color | ||
# space into the HSV color space and then only adapt the color's saturation (S component). | ||
|
||
r, g, b = [v / 255 for v in Mapbox[color].value] | ||
hexs = webcolors.CSS3_NAMES_TO_HEX[color] if color[0] != "#" else color | ||
r, g, b = [(int(h[1:3], 16), int(h[3:5], 16), int(h[5:7], 16)) for h in hexs] | ||
h, s, v = colorsys.rgb_to_hsv(r, g, b) | ||
|
||
palette = [] | ||
assert 0 < bins <= 256 | ||
|
||
palette = [] | ||
for i in range(bins): | ||
ns = (1 / bins) * (i + 1) | ||
palette.extend([int(v * 255) for v in colorsys.hsv_to_rgb(h, ns, v)]) | ||
|
||
assert len(palette) // 3 == bins | ||
r, g, b = [int(v * 255) for v in colorsys.hsv_to_rgb(h, (1 / bins) * (i + 1), v)] | ||
palette.extend(r, g, b) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Nice refactor |
||
|
||
return palette | ||
|
||
|
||
def complementary_palette(palette): | ||
"""Creates a PIL complementary colors palette based on an initial PIL palette""" | ||
|
||
comp_palette = [] | ||
colors = [palette[i : i + 3] for i in range(0, len(palette), 3)] | ||
|
||
for color in colors: | ||
r, g, b = [v for v in color] | ||
h, s, v = colorsys.rgb_to_hsv(r, g, b) | ||
comp_palette.extend(map(int, colorsys.hsv_to_rgb((h + 0.5) % 1, s, v))) | ||
|
||
return comp_palette | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neat! |
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 all your work so far!