Skip to content

Commit

Permalink
fix num and percentage splits
Browse files Browse the repository at this point in the history
  • Loading branch information
vorozhkog committed Sep 13, 2024
1 parent 558c8cf commit 854b976
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/compute/layers/processing/SplitDataLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ def process(self, data_el: Tuple[ImageDescriptor, Annotation]):
def _split_by_percent() -> List[Tuple[ImageDescriptor, Annotation]]:
new_item_desc = deepcopy(item_desc)
split_ratio = self.settings.get("split_ratio", 0.8)
split_index = int(item_idx / (total_items_cnt * split_ratio))
split_num = total_items_cnt * split_ratio
split_index = int(item_idx / split_num) + (item_idx % split_num > 0)
dataset = f"split_{split_index}"
new_item_desc.res_ds_name = dataset
return [(new_item_desc, ann)]

def _split_by_num() -> List[Tuple[ImageDescriptor, Annotation]]:
new_item_desc = deepcopy(item_desc)
split_num = self.settings.get("split_num", total_items_cnt // 2)
split_index = int(item_idx / split_num)
split_index = int(item_idx / split_num) + (item_idx % split_num > 0)
print(f"ITEM INDEX: {item_idx}, SPLIT INDEX: {split_index}")
dataset = f"split_{split_index}"
new_item_desc.res_ds_name = dataset
return [(new_item_desc, ann)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
def create_sidebar_widgets():
# Sidebar Initialization widgets

sidebar_percent_slider = Slider(show_input=True, show_input_controls=True, min=1)
sidebar_percent_slider = Slider(
show_input=True, show_input_controls=True, min=0.01, max=1, step=0.01
)
sidebar_percent_field = Field(
sidebar_percent_slider,
"Select percentage",
Expand Down

0 comments on commit 854b976

Please sign in to comment.