Skip to content

Commit

Permalink
Added ui fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
QazyBi committed Jan 11, 2024
1 parent f47a729 commit a9429ee
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __pycache__/
*.py[cod]
*$py.class


# C extensions
*.so

Expand Down Expand Up @@ -115,6 +116,8 @@ logs
!/.pytest_cache/
#data
*.cache
**cache*
.DS_Store

data/
!tests/data/
Expand Down
Binary file removed config/.DS_Store
Binary file not shown.
30 changes: 30 additions & 0 deletions config/experiments/semantic-segmentation/AS_151123_oks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# @package _global_
defaults:
- override /models: semantic-segmentation/deeplabv3plus
- override /datasets: semantic-segmentation/oks_151123
- override /loggers: wandb
- override /losses: semantic-segmentation/dice
- override /optimizers: adam
- override /augmentations_train: linear-roads-bin-seg

datasets:
batch_size: 20
num_workers: 42


models:
in_channels: 3
classes: 1
encoder_name: resnet101
encoder_depth: 5
decoder_channels: 256
encoder_weights:

project: oks
task: image-segmentation
random_seed: 42
accelerator: gpu
devices: 1
batch_size: 20
num_workers: 42
epochs: 40
17 changes: 12 additions & 5 deletions dui/assets/dui.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,14 @@ function parseHtmlToDict(html_array){
}

if (parent != null){
let new_dict = {};
new_dict[k] = v;
dict[parent].push(new_dict);
if (isNaN(Number(k))) {
let new_dict = {};
new_dict[k] = v;
dict[parent].push(new_dict);
}
else{
dict[parent].push(v);
}
}
else{
dict[k] = v;
Expand Down Expand Up @@ -508,7 +513,7 @@ function openModalWindowOnEditButtonClick(button){

let nameOfConfig = document.createElement("h3");
nameOfConfig.className = "modal_config_name";
const text = document.createTextNode(fileName+".yaml");
const text = document.createTextNode(fileName);
nameOfConfig.appendChild(text);
modal_content.insertBefore(nameOfConfig, modal_content.children[0])

Expand Down Expand Up @@ -536,7 +541,9 @@ function modals(){

function change_config_name_and_url(){
let config_name = document.getElementById("config_name");
config_name.value = "duplicate " + config_name.value;
const parts = config_name.value.split('.');

config_name.value = parts[0] + "_duplicate.yaml";
history.pushState(null, 'FeaturePoints Login', location.protocol+"//"+location.host+"/config/"+config_name.value);
}

Expand Down
19 changes: 14 additions & 5 deletions dui/pages/config_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,23 @@ def decompose(configurations, recurse=False, level=0):
print(e, k, v)


def simplify_dict(dict):
def simplify_dict(in_dict):
new_dict = {}

for k, v in dict.items():
for k, v in in_dict.items():
if type(v) is list:
intermediate_dict = {key: value for element in v for key, value in element.items()}
intermediate_dict = simplify_dict(intermediate_dict)
new_dict[k] = intermediate_dict
intermediate_dict = {}
for element in v:
if type(element) is dict:
for key, value in element.items():
intermediate_dict[key] = value
intermediate_dict = simplify_dict(intermediate_dict)
new_dict[k] = intermediate_dict
else:
if k not in new_dict.keys():
new_dict[k] = [element]
else:
new_dict[k].append(element)
else:
new_dict[k] = v
return new_dict
Expand Down
19 changes: 14 additions & 5 deletions dui/pages/config_getting.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,23 @@ def decompose(configurations, recurse=False, level=0):
except Exception as e:
print(e, k, v)

def simplify_dict(dict):
def simplify_dict(in_dict):
new_dict = {}

for k, v in dict.items():
for k, v in in_dict.items():
if type(v) is list:
intermediate_dict = {key: value for element in v for key, value in element.items()}
intermediate_dict = simplify_dict(intermediate_dict)
new_dict[k] = intermediate_dict
intermediate_dict = {}
for element in v:
if type(element) is dict:
for key, value in element.items():
intermediate_dict[key] = value
intermediate_dict = simplify_dict(intermediate_dict)
new_dict[k] = intermediate_dict
else:
if k not in new_dict.keys():
new_dict[k] = [element]
else:
new_dict[k].append(element)
else:
new_dict[k] = v
return new_dict
Expand Down
6 changes: 5 additions & 1 deletion dui/pages/config_saving.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ def layout():
request_body = request.json
with open(configs_path / request_body["config_name"], "w+") as stream:
try:
s = "# @package _global_\n" + yaml.dump(request_body["html"], allow_unicode=True, default_flow_style=False)
if "experiments/" in configs_path:
s = "# @package _global_\n" + yaml.dump(request_body["html"], allow_unicode=True,
default_flow_style=False)
else:
s = yaml.dump(request_body["html"], allow_unicode=True, default_flow_style=False)
stream.write(s)
except yaml.YAMLError as exc:
print("ERROR:", exc)
Expand Down
Binary file removed innofw/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_samples(path) -> List[Path]: # todo: move out


class SegmentationDM(BaseLightningDataModule):
task = ["image-segmentation"]
task = ["image-segmentation", "multiclass-image-segmentation"]
framework = [Frameworks.torch]

@validate_arguments
Expand Down
3 changes: 2 additions & 1 deletion innofw/core/datasets/semantic_segmentation/tiff_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from innofw.constants import SegDataKeys
from innofw.core.augmentations import Augmentation

from rasterio.plot import reshape_as_raster
#
#

Expand Down Expand Up @@ -98,6 +98,7 @@ def __getitem__(self, index) -> dict:
mask = read_tif(self.masks[index])

mask = mask.astype(np.int) # todo: refactor
mask = reshape_as_raster(mask)[0]
if mask.shape[-1] == 1: # todo: refactor
mask = np.squeeze(mask, -1)

Expand Down
Binary file removed tests/.DS_Store
Binary file not shown.
Binary file removed ui/.DS_Store
Binary file not shown.

0 comments on commit a9429ee

Please sign in to comment.