示例#1
0
    def render(self, is_running):
        bimpy.set_next_tree_node_open(True, bimpy.Condition.FirstUseEver)

        if not bimpy.tree_node('progress##train_phase_component'):
            return

        self._is_trainning_start = False
        self._is_trainning_stop = False
        if self._is_trainning:
            if bimpy.button('stop##train_phase_component'):
                # print('stop')
                self._is_trainning = False
                self._is_trainning_stop = True
            if not is_running:
                # print('run over stop')
                self._is_trainning = False
                self._is_trainning_stop = True
        else:
            if bimpy.button('start##train_phase_component'):
                # print('start {}'.format(is_running))
                if not is_running:
                    self._is_trainning = True
                    self._is_trainning_start = True

        if self._trainning_progress is not None:
            bimpy.text('epoch: {} / {}'.format(
                self._trainning_progress['epoch_now'],
                self._trainning_progress['epoch_all'],
            ))

        bimpy.tree_pop()
示例#2
0
    def render(self, is_lock):
        bimpy.set_next_tree_node_open(True, bimpy.Condition.FirstUseEver)
        
        if not bimpy.tree_node('convex points##convex_component'):
            return
        
        bimpy.same_line()
        bimpy_tools.help_marker('Convex points should be presented in counter-clockwise order')

        flags = bimpy.InputTextFlags.EnterReturnsTrue
        if is_lock:
            flags |= bimpy.InputTextFlags.ReadOnly
        
        last_convex_number_value = self._convex_number.value

        if bimpy.input_int('number##convex_component', self._convex_number, 1, 1, flags):
            self._convex_number.value = max(3, self._convex_number.value)
            if last_convex_number_value > self._convex_number.value:
                self._convex_data = self._convex_data[:self._convex_number.value]  # cut back points
            else:
                self._convex_data.extend([
                    [bimpy.Float(0), bimpy.Float(0)] 
                    for _ in range(last_convex_number_value, self._convex_number.value)
                ])
        
        # show convex value setting
        bimpy.set_next_tree_node_open(self._convex_number.value < 10, bimpy.Condition.FirstUseEver)

        if bimpy.tree_node('convex value ({})##convex_component'.format(self._convex_number.value)):
            for index in range(self._convex_number.value):
                bimpy.push_item_width(210)
                bimpy.input_float2(
                    '{:<3d}'.format(index),
                    self._convex_data[index][0],
                    self._convex_data[index][1],
                    flags=flags
                )
                bimpy.pop_item_width()
            bimpy.tree_pop()
        
        # draw part
        bimpy.new_line()
        if bimpy.button('draw convex##convex_component') and not is_lock:
            self._convex_data_backup = [[item[0].value, item[1].value]
                                        for item in self._convex_data]
            self._convex_draw_flag = True
            self._convex_data = []
            self._convex_number.value = 0

        bimpy.tree_pop()
    def render(self):
        bimpy.set_next_tree_node_open(True, bimpy.Condition.FirstUseEver)

        if not bimpy.tree_node('result##train_result_component'):
            return
        
        for item in ['loss', 'acc']:
            for name in self._measure_value:
                bimpy.text('{:<6} {:<6}: {:.8f}'.format(
                    name, item, 
                    self._measure_value[name][item],
                ))
            bimpy.new_line()

        bimpy.tree_pop()
示例#4
0
    def render(self, is_lock):
        bimpy.set_next_tree_node_open(True, bimpy.Condition.FirstUseEver)

        if not bimpy.tree_node('trainning##train_component'):
            return

        flags = bimpy.InputTextFlags.EnterReturnsTrue
        if is_lock:
            flags |= bimpy.InputTextFlags.ReadOnly

        bimpy.push_item_width(120)

        if bimpy.input_int('epoch##train_component',
                           self._epoch,
                           0,
                           0,
                           flags=flags):
            self._epoch.value = max(1, self._epoch.value)

        if bimpy.input_int('batch_size##train_component',
                           self._batch_size,
                           0,
                           0,
                           flags=flags):
            self._batch_size.value = max(1, self._batch_size.value)

        if bimpy.input_int('batch_per_epoch##train_component',
                           self._batch_per_epoch,
                           0,
                           0,
                           flags=flags):
            self._batch_per_epoch.value = max(1, self._batch_per_epoch.value)

        if bimpy.input_int('valid_size##train_component',
                           self._valid_size,
                           0,
                           0,
                           flags=flags):
            self._valid_size.value = max(0, self._valid_size.value)

        bimpy.pop_item_width()

        bimpy.tree_pop()
    def render(self, is_lock):
        bimpy.set_next_tree_node_open(True, bimpy.Condition.FirstUseEver)

        if not bimpy.tree_node('optimizer##optimizer_component'):
            return

        if bimpy.begin_combo('select##optimizer_component',
                             self._select_optimizer):
            for item in self._optimizer_list:
                is_selected = bimpy.Bool(self._select_optimizer == item)

                if bimpy.selectable(item, is_selected) and not is_lock:
                    self._select_optimizer = item

                if is_selected.value:
                    bimpy.set_item_default_focus()
            bimpy.end_combo()

        self._optimizer_map[self._select_optimizer].render(is_lock)

        bimpy.tree_pop()
示例#6
0
    def render(self, is_lock):
        bimpy.set_next_tree_node_open(True, bimpy.Condition.FirstUseEver)
        
        if not bimpy.tree_node('lines##lines_component'):
            return

        # number setting
        flags = bimpy.InputTextFlags.EnterReturnsTrue
        if is_lock:
            flags |= bimpy.InputTextFlags.ReadOnly
        
        if bimpy.input_int('number##lines_component', self._line_number, 1, 1, flags):
            self._line_number.value = max(3, self._line_number.value)
            if self._last_line_number_value > self._line_number.value:
                self._line_data = self._line_data[:self._line_number.value]  # cut back points
            else:
                self._line_data.extend([
                    [bimpy.Float(0), bimpy.Float(0), bimpy.Float(0)] 
                    for _ in range(self._last_line_number_value, self._line_number.value)
                ])
            self._last_line_number_value = self._line_number.value
            # print('line number change to {}'.format(self._line_number.value))

        # show line value setting
        bimpy.set_next_tree_node_open(self._line_number.value < 10, bimpy.Condition.FirstUseEver)

        self._highlight_line_index = None

        if bimpy.tree_node('line value ({})'.format(self._line_number.value)):
            for index in range(self._line_number.value):
                bimpy.push_item_width(210)
                bimpy.input_float3(
                    '{:<3d}'.format(index),
                    self._line_data[index][0],
                    self._line_data[index][1],
                    self._line_data[index][2],
                    flags=flags
                )
                bimpy.pop_item_width()

                if bimpy.is_item_hovered():
                    self._highlight_line_index = index

                bimpy.same_line()
                if bimpy.button('rev##lines_component{}'.format(index)) and not is_lock:
                    for j in range(3):
                        self._line_data[index][j].value = -self._line_data[index][j].value
                
                if bimpy.is_item_hovered():
                    self._highlight_line_index = index

                bimpy.same_line()
                if bimpy.button('draw##lines_component{}'.format(index)) and not is_lock:
                    self._waitting_draw_line_index = index
                    bimpy.set_window_focus('canvas window##canvas')
                
                if bimpy.is_item_hovered():
                    self._highlight_line_index = index

            bimpy.tree_pop()

        # random setting
        bimpy.new_line()
        if bimpy.button('random##lines_component') and not is_lock:
            initializer = self.initializer_component.build_initializer()
            random_lines = initializer.random(self._line_number.value)
            for index in range(self._line_number.value):
                self._line_data[index][0].value = random_lines[index].a
                self._line_data[index][1].value = random_lines[index].b
                self._line_data[index][2].value = random_lines[index].c
        
        self.initializer_component.render(is_lock)

        bimpy.tree_pop()