예제 #1
0
파일: model.py 프로젝트: gfannes/subsoil
    def _show(self, ctx):
        # Show/adjust the weights
        if (not self.mlp.layers):
            bimpy.text("Warning: you need at least one layer")
            return

        # Select layer
        names = ["{ix} {str}".format(ix=ix, str=str(layer)) for ix,layer in enumerate(self.mlp.layers)]
        if (bimpy.combo("Layer", self.ui.layer_ix, names)):
            self.ui.neuron_ix.value = 0
        layer_ix = self.ui.layer_ix.value
        if (layer_ix < len(self.mlp.layers)):
            layer = self.mlp.layers[layer_ix]
            # Select neuron
            names = ["{ix}".format(ix=ix) for ix,neuron in enumerate(layer.neurons)]
            bimpy.combo("Neuron", self.ui.neuron_ix, names)
            neuron_ix = self.ui.neuron_ix.value
            if (neuron_ix < len(layer.neurons)):
                neuron = layer.neurons[neuron_ix]
                weights = [bimpy.Float(self.weights[neuron.weight_offset+ix]) for ix,_ in enumerate(neuron.input_ixs)]
                for ix,weight in enumerate(weights):
                    bimpy.slider_float("Weight {ix}".format(ix=ix), weight, *util.mm)
                    self.weights[neuron.weight_offset+ix] = weight.value

        if (self.mlp.layers[-1].nr_neurons != 1):
            bimpy.text("Warning: last layer should have only one output")
            return

        if (not self.setup()):
            return
예제 #2
0
    def render(self, is_lock):
        bimpy.indent(10)

        bimpy.text('- Plane')
        bimpy.same_line()
        bimpy_tools.help_marker(
            'generate with random points\n' \
            '* plane random: random on whole plane\n' \
            '* balanced random: balanced positive and negative samples'
        )

        bimpy.push_item_width(140)

        if bimpy.begin_combo('strategy##plane_random_generator',
                             self._select_strategy):
            for item in self._strategy_list:
                is_selected = bimpy.Bool(self._select_strategy == item)

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

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

        bimpy.pop_item_width()
        bimpy.unindent(10)
예제 #3
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()
예제 #4
0
    def retrival(self):

        ###########UI###########
        size = bimpy.Vec2(500, 750)
        bimpy.set_next_window_size(size, bimpy.Condition.Once)

        if bimpy.begin_popup_modal('{}: {}'.format(LANG.retrieve, self.select_label)) \
                and self.select_label != '' and self.first_init:

            for idx, file in enumerate(
                    self.r.label2pic[self.select_label.lower()]):
                if idx != 0:
                    bimpy.separator()

                img = self.r.get_thumbnail(file)
                bimpy.text(file)
                bimpy.image(img)

            bimpy.separator()

            if bimpy.button(LANG.retrieve_close):
                bimpy.clode_current_popup()
            bimpy.end_popup()
        ########################

        t = {
            'x': bimpy.get_window_pos().x,
            'y': bimpy.get_window_pos().y,
            'w': bimpy.get_window_size().x,
            'h': bimpy.get_window_size().y,
            'self': self,
        }

        return t
예제 #5
0
def main():
	global CTX

	ctx = bimpy.Context()
	ctx.init(1200, 1200, "Image")
	with ctx:
		bimpy.themes.set_light_theme()


	socket_thread = threading.Thread(target = thread_socket_func, args = (8883, ))
	socket_thread.start()

	message_thread = threading.Thread(target = message_thread_func)
	message_thread.start()

	previous_n_points = 0
	clear_flag = False
	while not ctx.should_close():
		with ctx:
			bimpy.set_next_window_pos(bimpy.Vec2(120, 120), bimpy.Condition.Once)
			bimpy.set_next_window_size(bimpy.Vec2(400, 400), bimpy.Condition.Once)
			bimpy.begin("Window #1")
			
			bimpy.text("This is text!")
			
			if bimpy.button("Send A Lot Of Messages"):
				temp_messages = [make_message_text("log", "Message #" + str(i)) for i in range(560)]
				send_messages(CTX.message_pipeline, temp_messages)
			
			if bimpy.button("Send A Lot Of Random Points"):
				temp_messages = [make_message_point("point", (random.randrange(400 + i), random.randrange(400 + i))) for i in range(20)]
				send_messages(CTX.message_pipeline, temp_messages)				
			
			if bimpy.button("Clear Flag"):
				clear_flag = not clear_flag
			
			bimpy.text("Text from events:\n%s" % (CTX.data.text))

			bimpy.end()

			draw_window_drawing(ctx, 400, 400, "Sample Drawing", CTX.data.points)

	log("Exited rendering thread")

	log("Sending exit to message_thread")
	send_message_text(CTX.message_pipeline, "exit", "")

	log("Waiting for message_thread")
	message_thread.join()
	CTX.server_socket_running = False
	if CTX.server_socket:
		for c, info in CTX.server_socket.connections:
			c.send(b'exit')

	log("Waiting for socket_thread")
	socket_thread.join()

	log("Bye")
예제 #6
0
파일: basic_app.py 프로젝트: torss/bimpy
    def on_update(self):
        bp.text("Hello, world!")

        if bp.button("OK"):
            print(self.string.value)

        bp.input_text('string', self.string, 256)

        bp.slider_float("float", self.f, 0, 1)
예제 #7
0
def view_batch(bp):
    bimpy.begin("Batch")
    bimpy.button("Open files...")
    bimpy.button("Open configurations...")
    bimpy.separator()
    bimpy.text("Regions:")
    bimpy.separator()
    bimpy.button("Render Files")
    bimpy.end()
예제 #8
0
파일: app.py 프로젝트: gfannes/subsoil
 def show(self, ctx):
     if (bimpy.collapsing_header("Subapp selection ({str})".format(str=str(self)))):
         if bimpy.combo("Selected app", self.ix, self.names):
             self.update()
             print("App changed to {str}".format(str=str(self)))
     if (bimpy.collapsing_header("App processing")):
         if (self.app is None):
             bimpy.text("This subapp is not supported.")
             return
         self.app.show(ctx)
예제 #9
0
def help_marker(help_text, highlight=False):
    if highlight:
        bimpy.text('(?)')
    else:
        bimpy.text_disabled('(?)')

    if bimpy.is_item_hovered():
        bimpy.begin_tooltip()
        bimpy.text(help_text)
        bimpy.end_tooltip()
예제 #10
0
    def __separator_name_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(5, 90), bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(1005, 38), bimpy.Condition.Once)

        bimpy.begin("Separator Name",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))
        bimpy.separator()
        bimpy.text("")
        bimpy.separator()
        bimpy.end()
예제 #11
0
    def __voltage_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(5, 278 + 128),
                                  bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(345, 110), bimpy.Condition.Once)

        bimpy.begin("Voltage",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "Voltage")
        bimpy.pop_font()
        bimpy.separator()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text("")
        bimpy.same_line(25, 0)
        if self.data.voltage >= 0:
            bimpy.text("{:.2f}".format(self.data.voltage).rjust(6, "0"))
        else:
            bimpy.text("-" + "{:.2f}".format(self.data.voltage).rjust(5, "0"))
        bimpy.pop_font()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.same_line(220, 0)
        bimpy.text("Volt")
        bimpy.pop_font()

        bimpy.end()
예제 #12
0
    def __calories_burtn_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(355, 5 + 128),
                                  bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(345, 110), bimpy.Condition.Once)

        bimpy.begin("Calories Burnt",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "Calories Burnt")
        bimpy.pop_font()
        bimpy.separator()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text("")
        bimpy.same_line(25, 0)
        if self.data.calories_burned >= 0:
            bimpy.text("{:.2f}".format(self.data.calories_burned).rjust(
                7, "0"))
        else:
            bimpy.text("0.00".rjust(7, "0"))
        bimpy.pop_font()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.same_line(250, 0)
        bimpy.text("cal")
        bimpy.pop_font()

        bimpy.end()
예제 #13
0
    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()
예제 #14
0
def main():
    selected_compiler = bimpy.Int()
    ctx = bimpy.Context()
    ctx.init(WIDTH, HEIGHT, "Virtual enviroment manager")

    environments = getAvailableEnviroments()
    compilers_list = list(data.compilers.keys())

    show_new_env_menu = False

    while (not ctx.should_close()):
        with ctx:
            bimpy.set_next_window_pos(bimpy.Vec2(0, 0), bimpy.Condition.Once)
            bimpy.set_next_window_size(bimpy.Vec2(WIDTH, HEIGHT),
                                       bimpy.Condition.Once)
            bimpy.begin("Enviroments",bimpy.Bool(True), \
                bimpy.WindowFlags.NoCollapse and bimpy.WindowFlags.NoResize)
            bimpy.text(sys.version)
            bimpy.columns(2)
            for enviroment in environments:
                if bimpy.button(enviroment):
                    compiler = list(data.compilers.values())[
                        selected_compiler.
                        value] if selected_compiler.value != 0 else ""
                    subprocess.call(
                        ['start', environments[enviroment], compiler],
                        shell=True)
                bimpy.next_column()
                if bimpy.button("O##" + enviroment):
                    subprocess.Popen(r'explorer /select,' +
                                     os.path.dirname(environments[enviroment]))
                    #os.startfile(os.path.realpath(os.path.dirname(environments[enviroment])))
                bimpy.next_column()
            bimpy.columns(1)
            if bimpy.combo("Compiler", selected_compiler, compilers_list):
                pass

            # if bimpy.button("Add new enviroment"):
            #     new_env_ctx = BimpyContext(WIDTH, HEIGHT, "New enviroment menu")
            #     while(not new_env_ctx.ctx.should_close()):
            #         with new_env_ctx.ctx:
            #             bimpy.begin("dsad")
            #             bimpy.text("d")
            #             bimpy.end()

            # if bimpy.button("Create new enviroment"):

            bimpy.end()
예제 #15
0
파일: utils.py 프로젝트: torss/bimpy
def help_marker(desc, icon='(?)', width=35.):
    """ Helper to display a little help mark which shows a tooltip when hovered.

    Args:
        desc (string): Help string which is displayed when hovered.
        icon (string, optional): Help marker, optional. If not provided, '(?)' is used. Replace it with your icon from an icon font
        width (Float, optional): Width of the tooltip in text height unit.
    """

    bp.text_disabled(icon)
    if bp.is_item_hovered():
        bp.begin_tooltip()
        bp.push_text_wrap_pos(bp.get_font_size() * width)
        bp.text(desc)
        bp.pop_text_wrap_pos()
        bp.end_tooltip()
예제 #16
0
    def render(self, is_lock):
        bimpy.indent(10)

        bimpy.text('- SGD')
        bimpy.same_line()
        bimpy_tools.help_marker('torch.optim.SGD')

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

        bimpy.push_item_width(120)

        if bimpy.input_float('lr##sgd_optimizer', self._lr, flags=flags):
            self._lr.value = max(0.0, self._lr.value)

        if bimpy.input_float('momentum##sgd_optimizer',
                             self._momentum,
                             flags=flags):
            self._momentum.value = max(0.0, self._momentum.value)

        if bimpy.input_float('dampening##sgd_optimizer',
                             self._dampening,
                             flags=flags):
            self._dampening.value = max(0.0, self._dampening.value)

        if bimpy.input_float('weight_decay##sgd_optimizer',
                             self._weight_decay,
                             flags=flags):
            self._weight_decay.value = max(0.0, self._weight_decay.value)

        if bimpy.checkbox('nesterov##sgd_optimizer', self._nesterov):
            self._hint_nesterov = False

        if self._nesterov.value:
            if self._momentum.value == 0 or self._dampening.value > 0:
                self._nesterov.value = False
                self._hint_nesterov = True

        bimpy.same_line()
        bimpy_tools.help_marker(
            'Nesterov momentum requires a momentum and zero dampening',
            self._hint_nesterov)

        bimpy.pop_item_width()
        bimpy.unindent(10)
예제 #17
0
    def render(self, is_lock):
        bimpy.indent(10)

        bimpy.text('- Linear layer init')
        bimpy.same_line()
        bimpy_tools.help_marker(
            'Initializer used in torch.nn.Linear, use Kaiming uniform')

        bimpy.push_item_width(120)

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

        if bimpy.input_float('a##sgd_optimizer', self._a, flags=flags):
            self._a.value = max(0.0, self._a.value)

        if bimpy.begin_combo('mode##linear_layer_init', self._select_mode):
            for item in self._mode_list:
                is_selected = bimpy.Bool(self._select_mode == item)

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

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

        if bimpy.begin_combo('nonlinearity##linear_layer_init',
                             self._select_nonlinearity):
            for item in self._nonlinearity_list:
                is_selected = bimpy.Bool(self._select_nonlinearity == item)

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

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

        bimpy.pop_item_width()
        bimpy.unindent(10)
예제 #18
0
    def __age_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(900, 5), bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(110, 80), bimpy.Condition.Once)

        bimpy.begin("Age",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "Age")
        bimpy.pop_font()
        bimpy.separator()

        bimpy.push_font(self.fonts.fonts[16]["ext_bold_ital"])
        bimpy.text("")
        bimpy.same_line(38, 0)
        bimpy.text(str(self.data.age))
        bimpy.pop_font()

        bimpy.end()
예제 #19
0
    def __gender_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(729, 5), bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(166, 80), bimpy.Condition.Once)

        bimpy.begin("Gender",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "Gender")
        bimpy.pop_font()
        bimpy.separator()

        bimpy.push_font(self.fonts.fonts[16]["ext_bold_ital"])
        bimpy.text("")
        bimpy.same_line(38, 0)
        bimpy.text("Female" if self.data.gender else "Male")
        bimpy.pop_font()

        bimpy.end()
예제 #20
0
    def object_inspector(self):
        has_selection = self.selected_node is not None
        bimpy.text("ID: %s" %
                   (str(self.selected_node.id) if has_selection else ''))

        nstr = bimpy.String(self.selected_node.name if has_selection else '')
        bimpy.input_text('Name', nstr, 256)

        nwidth = bimpy.Float(self.selected_node.width if has_selection else 0.)
        nheigth = bimpy.Float(
            self.selected_node.height if has_selection else 0.)
        bimpy.input_float2('size', nwidth, nheigth)

        nposx = bimpy.Float(self.selected_node.pos_x if has_selection else 0.)
        nposy = bimpy.Float(self.selected_node.pos_y if has_selection else 0.)
        bimpy.input_float2('position', nposx, nposy)

        ncolor = bimpy.Vec4(
            *[x / 255.
              for x in self.selected_node.color] if has_selection else (0, 0,
                                                                        0, 0))
        bimpy.color_edit("Color", ncolor)

        nradius = [
            self.selected_node.radius.x, self.selected_node.radius.y,
            self.selected_node.radius.z, self.selected_node.radius.w
        ] if has_selection else [0., 0., 0., 0.]
        nradius = [bimpy.Float(x) for x in nradius]

        bimpy.input_float4("radius", *nradius)

        if has_selection:
            self.selected_node.name = nstr.value
            self.selected_node.width = nwidth.value
            self.selected_node.height = nheigth.value
            self.selected_node.pos_x = nposx.value
            self.selected_node.pos_y = nposy.value
            self.selected_node.color = (int(255 * ncolor.x), int(
                255 * ncolor.y), int(255 * ncolor.z), int(255 * ncolor.w))
            self.selected_node.radius = getoolkit.vec4(
                *[x.value for x in nradius])
예제 #21
0
    def __time_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(5, 5 + 128), bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(345, 110), bimpy.Condition.Once)

        bimpy.begin("Time Elapsed",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "Time Elapsed")
        bimpy.pop_font()
        bimpy.separator()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text("")
        bimpy.same_line(38, 0)
        bimpy.text(
            str(datetime.timedelta(seconds=self.data.exercize_time))[:-4])
        bimpy.pop_font()

        bimpy.end()
예제 #22
0
    def __current_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(5, 393 + 128),
                                  bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(345, 110), bimpy.Condition.Once)

        bimpy.begin("Current",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "Current")
        bimpy.pop_font()
        bimpy.separator()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text("")
        bimpy.same_line(25, 0)
        bimpy.text("{:.2f}".format(self.data.voltage).rjust(6, "0"))
        bimpy.pop_font()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.same_line(215, 0)
        bimpy.text("Amp")
        bimpy.pop_font()

        bimpy.end()
예제 #23
0
    def render(self):
        super(SaveGameFrame, self).render()
        if bimpy.begin(self.name,
                       self.opened,
                       flags=bimpy.WindowFlags.NoCollapse
                       | bimpy.WindowFlags.MenuBar):

            if bimpy.begin_menu_bar():
                bimpy.menu_item('Save', 'Cmd+S', self.click_states['save'])
                bimpy.menu_item('Reload', 'Cmd+R', self.click_states['reload'])
                bimpy.menu_item('Export', 'Cmd+E', self.click_states['export'])
                bimpy.menu_item('Reload & Diff', 'Cmd+D',
                                self.click_states['reload_and_diff'])
                bimpy.end_menu_bar()

            if self.diff_string:
                bimpy.columns(2, "hex split")

            bimpy.text('Game: ')
            bimpy.same_line()
            bimpy.text(self.backend.game.value)

            for section_name, section_items in self.items.items():
                if bimpy.collapsing_header(section_name):
                    for item in section_items:
                        item.render_widget()

            if self.diff_string:
                bimpy.next_column()
                for line in self.diff_string.splitlines():
                    bimpy.text(line)

            bimpy.end()
예제 #24
0
    def __rpm_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(705, 278 + 128),
                                  bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(305, 225), bimpy.Condition.Once)

        bimpy.begin("RPM",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "RPM")
        bimpy.pop_font()
        bimpy.separator()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text("")
        bimpy.same_line(25, 0)
        bimpy.text(str(int(self.data.rpm)).rjust(4, "0"))
        bimpy.pop_font()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.same_line(175, 0)
        bimpy.text("RPM")
        bimpy.pop_font()

        self.rpm_datas.append(self.data.rpm)
        self.rpm_datas.pop(0)

        self.rpm_datas.reverse()
        bimpy.plot_lines("", self.rpm_datas, graph_size=bimpy.Vec2(288, 112))
        self.rpm_datas.reverse()
        bimpy.end()
예제 #25
0
    def __speed_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(355, 120 + 128),
                                  bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(345, 110), bimpy.Condition.Once)

        bimpy.begin("Speed",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "Speed")
        bimpy.pop_font()
        bimpy.separator()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text("")
        bimpy.same_line(25, 0)
        bimpy.text(str(int(self.data.speed[0])).rjust(4, " "))
        bimpy.pop_font()

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.same_line(200, 0)
        bimpy.text("Km/H")
        bimpy.pop_font()

        bimpy.end()
예제 #26
0
    def __distance_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(5, 120 + 128),
                                  bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(345, 110), bimpy.Condition.Once)

        bimpy.begin("Distance",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "Distance Traveled")
        bimpy.pop_font()
        bimpy.separator()

        if self.data.distance <= 1.1:
            distance_formatted_data = str(int(self.data.distance * 1000))
            distance_formatted_data = distance_formatted_data.rjust(4, "0")
            scalar = "m"
        else:
            distance_formatted_data = "{:.2f}".format(self.data.distance)
            distance_formatted_data = distance_formatted_data.rjust(6, "0")
            scalar = "Km"

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text("")
        bimpy.same_line(38, -1)
        bimpy.text(distance_formatted_data)
        bimpy.same_line(245, 0)
        bimpy.text(scalar)
        bimpy.pop_font()

        bimpy.end()
예제 #27
0
    def render(self):
        # display_size = bimpy.get_display_size()
        window_pos = bimpy.Vec2(self._distance, self._distance)
        window_pos_pivot = bimpy.Vec2(0.0, 0.0)
        bimpy.set_next_window_pos(window_pos, bimpy.Condition.FirstUseEver, window_pos_pivot)
        bimpy.set_next_window_bg_alpha(0.35)

        flags = bimpy.WindowFlags.NoDecoration \
              | bimpy.WindowFlags.AlwaysAutoResize \
              | bimpy.WindowFlags.NoSavedSettings \
              | bimpy.WindowFlags.NoFocusOnAppearing \
              | bimpy.WindowFlags.NoFocusOnAppearing \
              | bimpy.WindowFlags.NoNav
        
        if bimpy.begin("logging overlay##logging_tools", flags=flags):
            if bimpy.is_mouse_pos_valid(None):
                mouse_pos = bimpy.get_mouse_pos()
                bimpy.text("Mouse Pos: ({:.1f},{:.1f})".format(mouse_pos.x, mouse_pos.y))
            else:
                bimpy.text("Mouse Pos: <invalid>")

        bimpy.end()
예제 #28
0
    def render(self, is_lock):
        bimpy.indent(10)

        bimpy.text('- MSE loss')
        bimpy.same_line()
        bimpy_tools.help_marker('torch.nn.MSELoss')

        bimpy.push_item_width(120)

        if bimpy.begin_combo('reduction##mse_loss_fn', self._select_redution):
            for item in self._reduction_list:
                is_selected = bimpy.Bool(self._select_redution == item)

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

                if is_selected.value:
                    bimpy.set_item_default_focus()
            bimpy.end_combo()
        
        bimpy.pop_item_width()
        bimpy.unindent(10)
예제 #29
0
    def render(self, is_lock):
        bimpy.indent(10)

        bimpy.text('- Adam')
        bimpy.same_line()
        bimpy_tools.help_marker('torch.optim.Adam')

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

        bimpy.push_item_width(140)

        if bimpy.input_float('lr##adam_optimizer', self._lr, flags=flags):
            self._lr.value = max(0.0, self._lr.value)

        if bimpy.input_float2('momentum##adam_optimizer',
                              self._betas_first,
                              self._betas_second,
                              flags=flags):
            self._betas_first.value = max(0.0, self._betas_first.value)
            self._betas_second.value = max(0.0, self._betas_second.value)

        if bimpy.input_float('eps##adam_optimizer',
                             self._eps,
                             decimal_precision=8,
                             flags=flags):
            self._dampening.value = max(0.0, self._eps.value)

        if bimpy.input_float('weight_decay##adam_optimizer',
                             self._weight_decay,
                             flags=flags):
            self._weight_decay.value = max(0.0, self._weight_decay.value)

        bimpy.checkbox('amsgrad##adam_optimizer', self._amsgrad)

        bimpy.pop_item_width()
        bimpy.unindent(10)
예제 #30
0
    def render(self, is_lock):
        bimpy.indent(10)

        bimpy.text('- Raw Point')
        bimpy.same_line()
        bimpy_tools.help_marker('generate with raw points')

        bimpy.push_item_width(120)

        if bimpy.begin_combo('strategy##raw_point_generator',
                             self._select_strategy):
            for item in self._strategy_list:
                is_selected = bimpy.Bool(self._select_strategy == item)

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

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

        bimpy.pop_item_width()
        bimpy.unindent(10)
예제 #31
0
    def render(self):
        if not self._size:
            self._size = bimpy.Vec2(400, 600)
            bimpy.set_next_window_size(self._size)

        if bimpy.begin(self.name,
                       self.opened,
                       flags=bimpy.WindowFlags.NoCollapse
                       | bimpy.WindowFlags.MenuBar):

            if bimpy.begin_menu_bar():
                bimpy.menu_item('Reload', 'Cmd+R', self.click_states['reload'])
                bimpy.end_menu_bar()

            for folder_name, folder_files in self.tree.items():
                if bimpy.collapsing_header(folder_name):
                    for item, button_name in folder_files:
                        if bimpy.button(button_name):
                            item_path = '{0}/{1}'.format(folder_name, item)
                            try:
                                new_savegame = SaveGameFrame(
                                    PS2WrappedBinBackend, item_path, self)
                                self.child_frames.append(new_savegame)

                            except KeyboardInterrupt as e:
                                raise e
                            except Exception as e:
                                print(e)

                        bimpy.same_line()
                        bimpy.text(item)

            bimpy.end()

            for child_frame in self.child_frames:
                child_frame.render()
예제 #32
0
    def __heart_rate_window(self):
        bimpy.set_next_window_pos(bimpy.Vec2(705, 5 + 128),
                                  bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(305, 225), bimpy.Condition.Once)

        bimpy.begin("Heart Rate",
                    flags=bimpy.WindowFlags(4) | bimpy.WindowFlags(1)
                    | bimpy.WindowFlags(2))

        bimpy.push_font(self.fonts.fonts[16]["cond"])
        bimpy.text_colored(bimpy.Vec4(1, 0, 0, 1), "Heart Rate")
        bimpy.pop_font()
        bimpy.separator()

        bimpy.text("")

        bimpy.same_line(30, -1)

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text(str(int(self.data.heart_rate)).rjust(3, "0"))
        bimpy.pop_font()

        bimpy.same_line(140, 20)

        bimpy.push_font(self.fonts.fonts[44]["ext_bold_ital"])
        bimpy.text("BPM")
        bimpy.pop_font()

        if (time.time() -
                self.heart_rate_start_monitor) >= (self.data.heart_rate / 60):
            self.heart_rate_data.append(-0.7)
            self.heart_rate_data.append(1)
            self.heart_rate_start_monitor = time.time()
            self.heart_rate_data.pop(0)
        else:
            self.heart_rate_data.append(0)

        self.heart_rate_data.pop(0)

        self.heart_rate_data.reverse()
        bimpy.plot_lines("",
                         self.heart_rate_data,
                         graph_size=bimpy.Vec2(288, 112),
                         scale_min=-1.0,
                         scale_max=1.3)
        self.heart_rate_data.reverse()

        bimpy.end()
예제 #33
0
파일: io.py 프로젝트: gfannes/subsoil
 def show(self, ctx):
     bimpy.text(str(self.model))
     self.model.show(ctx)
     show_io_plot(self.ui.input, self.model)