예제 #1
0
    def __init__(self):
        self._convex_number = bimpy.Int(4)
        self._convex_data = [
            [bimpy.Float(0.15), bimpy.Float(0.15)],
            [bimpy.Float(0.85), bimpy.Float(0.15)],
            [bimpy.Float(0.85), bimpy.Float(0.85)],
            [bimpy.Float(0.15), bimpy.Float(0.85)],
        ]

        self._convex_data_backup = None
        self._convex_draw_flag = False
예제 #2
0
    def __init__(self):
        self._line_number = bimpy.Int(4)
        self._last_line_number_value = self._line_number.value

        self._line_data = [
            [bimpy.Float(1), bimpy.Float(1), bimpy.Float(-1)],
            [bimpy.Float(1), bimpy.Float(-1), bimpy.Float(-0.5)],
            [bimpy.Float(-1), bimpy.Float(1), bimpy.Float(-0.5)],
            [bimpy.Float(0), bimpy.Float(-1), bimpy.Float(0.5)],
        ]

        self.initializer_component = InitializerComponent()

        self._highlight_line_index = None
        self._waitting_draw_line_index = None
예제 #3
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()
예제 #4
0
    @property
    def x2(self):
        return self.x + self.w / 2

    @property
    def y2(self):
        return self.y + self.h / 2


anot_idx = 0
rect_db = [{} for x in range(video_len)]
rect_table_of_contents = set()
rect_table_of_contents_sorted = []
annotation_frame = 0
active_annotations = {}
current_label_idx = bimpy.Int(0)


def is_rect_active(rect):
    return rect.idx in active_annotations


def update_rect_toc(frame_idx):
    global rect_table_of_contents_sorted
    if len(rect_db[frame_idx]) == 0:
        rect_table_of_contents.discard(frame_idx)
        if len(rect_db) > frame_idx + 1 and len(rect_db[frame_idx + 1]) != 0:
            rect_table_of_contents.add(frame_idx + 1)
            rect_table_of_contents_sorted = sorted(rect_table_of_contents)

    elif len(rect_db[frame_idx]) == 1 and frame_idx == 0:
예제 #5
0
def sample(cfg, logger):
    model = Model(
        startf=cfg.MODEL.START_CHANNEL_COUNT,
        layer_count= cfg.MODEL.LAYER_COUNT,
        maxf=cfg.MODEL.MAX_CHANNEL_COUNT,
        latent_size=cfg.MODEL.LATENT_SPACE_SIZE,
        truncation_psi=cfg.MODEL.TRUNCATIOM_PSI,
        truncation_cutoff=cfg.MODEL.TRUNCATIOM_CUTOFF,
        mapping_layers=cfg.MODEL.MAPPING_LAYERS,
        channels=3)
    model.eval()

    logger.info("Trainable parameters generator:")
    count_parameters(model.generator)

    model_dict = {
        'generator_s': model.generator,
        'mapping_fl_s': model.mapping,
        'dlatent_avg': model.dlatent_avg,
    }

    checkpointer = Checkpointer(cfg,
                                model_dict,
                                logger=logger,
                                save=True)

    checkpointer.load()

    ctx = bimpy.Context()
    remove = bimpy.Bool(False)
    layers = bimpy.Int(8)

    ctx.init(1800, 1600, "Styles")

    rnd = np.random.RandomState(5)
    latents = rnd.randn(1, cfg.MODEL.LATENT_SPACE_SIZE)
    sample = torch.tensor(latents).float().cuda()

    def update_image(sample):
        with torch.no_grad():
            torch.manual_seed(0)
            model.eval()
            x_rec = model.generate(layers.value, remove.value, z=sample)
            #model.generator.set(l.value, c.value)
            resultsample = ((x_rec * 0.5 + 0.5) * 255).type(torch.long).clamp(0, 255)
            resultsample = resultsample.cpu()[0, :, :, :]

            return resultsample.type(torch.uint8).transpose(0, 2).transpose(0, 1)

    with torch.no_grad():
        save_image(model.generate(8, True, z=sample) * 0.5 + 0.5, 'sample.png')

    im = bimpy.Image(update_image(sample))
    while(not ctx.should_close()):
        with ctx:

            bimpy.set_window_font_scale(2.0)

            if bimpy.checkbox('REMOVE BLOB', remove):
                im = bimpy.Image(update_image(sample))
            if bimpy.button('NEXT'):
                latents = rnd.randn(1, cfg.MODEL.LATENT_SPACE_SIZE)
                sample = torch.tensor(latents).float().cuda()
                im = bimpy.Image(update_image(sample))
            if bimpy.slider_int("Layers", layers, 0, 8):
                im = bimpy.Image(update_image(sample))
            bimpy.image(im, bimpy.Vec2(1024, 1024))
예제 #6
0
파일: sliders.py 프로젝트: zakx/bimpy
    bimpy.themes.set_light_theme()

#slider float3    
f1 = bimpy.Float();
f2 = bimpy.Float();
f3 = bimpy.Float();

#vertical slider 
f4 = bimpy.Float();
f5 = bimpy.Float();
    
#slider_angle
f6 = bimpy.Float();

#slider int2
i1 = bimpy.Int();
i2 = bimpy.Int();

while(not ctx.should_close()):
    ctx.new_frame()

    bimpy.begin("Sliders!", flags=bimpy.WindowFlags.AlwaysAutoResize)
    
    bimpy.slider_float3("float3", f1, f2, f3, 0.0, 1.0)
    
    bimpy.v_slider_float("v_slider", bimpy.Vec2(20, 300), f4, 0.0, 1.0)
    
    bimpy.same_line()
    
    bimpy.v_slider_float("v_slider2", bimpy.Vec2(50, 300), f5, -100.0, 100.0, "[%.1f]")
    
class file_brewswer_ui:
    fb = file_broswer()
    preidx = -1
    selected = bimpy.Int(-1)

    im = None
    process = (0, len(fb.file_list))

    def render(self, ctx, windows_info):

        pos = bimpy.Vec2(conf.margin, conf.margin)
        size_min = bimpy.Vec2(conf.min_file_browser_width,
                              ctx.height() - 2 * conf.margin)
        size_max = bimpy.Vec2(conf.max_file_browser_width,
                              ctx.height() - 2 * conf.margin)

        bimpy.set_next_window_pos(pos, bimpy.Condition.Once)
        bimpy.set_next_window_size_constraints(size_min, size_max)

        bimpy.begin(LANG.file_brewswer_ui_title, bimpy.Bool(True),
                    bimpy.WindowFlags.NoCollapse | bimpy.WindowFlags.NoMove)

        ###########UI###########
        if bimpy.button(LANG.file_brewswer_ui_refresh) == True:
            self.fb.refresh_file_list()

        bimpy.same_line()
        if bimpy.button(LANG.about) == True:
            bimpy.open_popup(LANG.about)

        # call render about ui
        # print(dir(windows_info['about_ui']))
        windows_info['about_ui']['self'].about()

        for idx, f_name in enumerate(self.fb.file_list):
            # print(self.selected.value)
            if bimpy.selectable(
                    f_name.split('\\')[-1], self.selected.value == idx):
                self.selected.value = idx

                if self.selected.value != -1 and self.selected.value != self.preidx:
                    self.preidx = self.selected.value
                    windows_info['image_shower_ui']['self'].update_pic(f_name)
                    windows_info['meta_info_ui']['self'].update_meta_info(
                        f_name)

        # progress bar
        if not self.fb.q.empty():
            self.process = self.fb.q.get()

            f, d = self.process[-2], self.process[-1]
            # update if new
            if d != {}:
                self.fb.pp.yolo_res[f] = d

            self.process = (self.process[0] + 1, self.process[1])

            if self.process[0] == self.process[1]:
                with open('yolo_res', 'wb') as f:
                    pickle.dump(self.fb.pp.yolo_res, f)

                # build retrieval index
                windows_info['retrival_ui']['self'].init = False

        sz = bimpy.get_window_size()
        bimpy.set_cursor_pos(bimpy.Vec2(conf.margin, sz.y - conf.margin * 2))
        bimpy.push_item_width(sz.x - conf.margin * 3 - 60)

        process = self.process
        bimpy.progress_bar(process[0] / float(process[1]),
                           bimpy.Vec2(0.0, 0.0),
                           "{}/{}".format(process[0], process[1]))

        bimpy.same_line()
        if bimpy.button(LANG.reindex) == True and process[0] == process[1]:
            self.fb.refresh()

        ########################

        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,
        }

        bimpy.end()

        return t
예제 #8
0
import sys
import os

if os.path.exists("../cmake-build-debug/"):
    print('Running Debugging session!')
    sys.path.insert(0, "../cmake-build-debug/")

import bimpy as bp
from bimpy.utils import help_marker

check = bp.Bool(True)
e = bp.Int(0)
clicked = 0
counter = 0
item_current = bp.Int(0)
str0 = bp.String("Hello, world!")
buf = bp.String("\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e")


def show_demo_window():
    bp.begin_root(menu=True)

    #  Menu Bar
    if bp.begin_menu_bar():
        if bp.begin_menu("Menu"):
            bp.end_menu()

        if bp.begin_menu("Examples"):
            bp.end_menu()

        if bp.begin_menu("Tools"):
예제 #9
0
파일: test.py 프로젝트: 0xMDIV/RoboterGUI
    bimpy.themes.set_light_theme()

#slider float3
f1 = bimpy.Float()
f2 = bimpy.Float()
f3 = bimpy.Float()

#vertical slider
f4 = bimpy.Float()
f5 = bimpy.Float()

#slider_angle
f6 = bimpy.Float()

#slider int2
i1 = bimpy.Int()
i2 = bimpy.Int()

while (not ctx.should_close()):
    ctx.new_frame()

    bimpy.begin("Sliders!", flags=bimpy.WindowFlags.AlwaysAutoResize)

    bimpy.slider_float3("float3", f1, f2, f3, 0.0, 1.0)

    bimpy.v_slider_float("v_slider", bimpy.Vec2(20, 300), f4, 0.0, 1.0)

    bimpy.same_line()

    bimpy.v_slider_float("v_slider2", bimpy.Vec2(50, 300), f5, -100.0, 100.0,
                         "[%.1f]")
예제 #10
0
            else:
                # print(img)
                if first:
                    # first image is ready, tell imgui to start refreshing the images
                    refresh = True
                    first = False
                imgdict[img_url] = img
                q.put((img_url, img))
    imgs_downloading = False


ctx = bimpy.Context()
ctx.init(1200, 768, "Spotify Collage")

playlist_url = bimpy.String()
b_col_count = bimpy.Int(0)
refresh = False
COL_COUNT = 8
saved = ""
saved_time = 0
credentials = oauth2.SpotifyClientCredentials(*get_credentials())
while (not ctx.should_close()):
    with ctx:
        # bimpy.themes.set_light_theme()
        bimpy.set_next_window_pos(bimpy.Vec2(20, 20), bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(600, 600), bimpy.Condition.Once)
        bimpy.begin(
            "Track Listing", bimpy.Bool(True),
            bimpy.WindowFlags.HorizontalScrollbar
            | bimpy.WindowFlags.NoSavedSettings)
        bimpy.text('Spotify Playlist URI')
예제 #11
0
ply = bimpy.Bool(False)

pcd = bimpy.Bool(False)

nom = bimpy.String()

atx

ctx = bimpy.Context()

ctx.init(800, 400, "Scanner 3D")

with ctx:
    bimpy.themes.set_light_theme()

taille_cible = bimpy.Int(150)

largeur_cible = bimpy.Int(150)

while not ctx.should_close():
    ctx.new_frame()

    bimpy.set_next_window_pos(bimpy.Vec2(0, 0), bimpy.Condition.Once)
    bimpy.set_next_window_size(bimpy.Vec2(800, 400), bimpy.Condition.Once)
    bimpy.begin("Controls")

    bimpy.input_text("Nom du fichier", nom, 15)

    if bimpy.button("Visualisation"):
        while (i < 1000000):
            num = i / 1000000
예제 #12
0
#win.mainloop()

# get logged in user
system_user = getpass.getuser()

# gui setup with bimpy
# render new window
ctx = bimpy.Context()
# init main window
ctx.init(1280, 720, "Haus Management")
max_height = ctx.height()
max_width = ctx.width()

string = bimpy.String()
f = bimpy.Float()
i = bimpy.Int()

while (not ctx.should_close()):
    # display new window and set pos and size
    ctx.new_frame()

    bimpy.set_next_window_pos(bimpy.Vec2(10, 10), bimpy.Condition.Once)
    bimpy.set_next_window_size(bimpy.Vec2(max_width - 20, max_height - 20),
                               bimpy.Condition.Once)

    bimpy.begin("Willkommen {} es ist der {}".format(
        system_user,
        datetime.now().strftime('%d.%m.%Y um %H:%M:%S')))

    bimpy.input_text('Besitzer', string, 25)
예제 #13
0
 def __init__(self):
     self._epoch = bimpy.Int(500)
     self._batch_size = bimpy.Int(256)
     self._batch_per_epoch = bimpy.Int(10)
     self._valid_size = bimpy.Int(1024)
예제 #14
0
def main():

    parser = ArgumentParser(description="Preview animations")

    parser.add_argument("--version",
                        action="version",
                        version="%(prog)s " + __version__)
    parser.add_argument("--width",
                        dest="width",
                        type=int,
                        default=DEF_WIDTH,
                        help="frame width (default: %s)" % DEF_WIDTH)
    parser.add_argument("--height",
                        dest="height",
                        type=int,
                        default=DEF_HEIGHT,
                        help="frame height (default: %s)" % DEF_HEIGHT)
    parser.add_argument("--scale",
                        dest="scale",
                        type=int,
                        default=DEF_SCALE,
                        help="scale preview (default: %s)" % DEF_SCALE)
    parser.add_argument("--double-w",
                        dest="dw",
                        action="store_true",
                        help="double width for 2:1")
    parser.add_argument(
        "--mtime",
        dest="mtime",
        type=int,
        default=DEF_MTIME,
        help="seconds between checks for changes (default: %s)" % DEF_MTIME)

    parser.add_argument("image", help="image to convert")

    args = parser.parse_args()

    def load_image(filename):
        @with_retry
        def load():
            return Image.open(filename).convert("RGB")

        try:
            image = load()
        except IOError:
            parser.error("failed to open the image")

        (w, h) = image.size

        if w % args.width or h % args.height:
            parser.error("%s size is not multiple of tile size (%s, %s)" %
                         (filename, args.width, args.height))

        frames = []
        for y in range(0, h, args.height):
            for x in range(0, w, args.width):
                frames.append((x, y, x + args.width, y + args.height))

        return image, frames

    image, frames = load_image(args.image)
    frame_list = list(range(len(frames)))

    def scale_image(scale, frameno):
        scale_w = scale if not args.dw else scale * 2
        current = image.resize((args.width * scale_w, args.height * scale),
                               box=frames[frame_list[frameno]],
                               resample=0)
        return bimpy.Image(current)

    ctx = bimpy.Context()

    ctx.init(320, 420, "Preview animation")
    orig = bimpy.Image(image)
    scale = bimpy.Int(args.scale)
    fps = bimpy.Int(args.scale)
    frame_list_str = bimpy.String(','.join(map(str, frame_list)))
    im = scale_image(scale.value, 0)

    cur_frame = 0
    paused = False
    start_time = time()
    check_mtime = time()
    last_mtime = os.stat(args.image).st_mtime
    while (not ctx.should_close()):

        if time() - check_mtime > args.mtime:
            if os.stat(args.image).st_mtime != last_mtime:
                last_mtime = os.stat(args.image).st_mtime
                image, frames = load_image(args.image)
                cur_frame = 0
                start_time = time()
                if any([f >= len(frames) for f in frame_list]):
                    frame_list = list(range(len(frames)))
                    frame_list_str = bimpy.String(','.join(map(
                        str, frame_list)))

        ctx.new_frame()
        bimpy.set_next_window_pos(bimpy.Vec2(10, 10), bimpy.Condition.Once)
        bimpy.set_next_window_size(bimpy.Vec2(300, 400), bimpy.Condition.Once)
        bimpy.begin("Image: %s" % args.image)

        if not paused:
            if time() - start_time >= 1. / fps.value:
                start_time = time()
                cur_frame += 1
                if cur_frame == len(frame_list):
                    cur_frame = 0
                im = scale_image(scale.value, cur_frame)

        bimpy.image(orig)
        bimpy.image(im)
        bimpy.text("Frame: %02d" % frame_list[cur_frame])

        if bimpy.slider_int("Scale", scale, 1, 20):
            im = scale_image(scale.value, cur_frame)
        if bimpy.slider_int("FPS", fps, 1, 30):
            start_time = time()
            cur_frame = 0
        if bimpy.input_text("Frames", frame_list_str, 64,
                            bimpy.InputTextFlags.EnterReturnsTrue):
            try:
                new_frame_list = [
                    int(i.strip()) for i in frame_list_str.value.split(",")
                ]
                frame_list = new_frame_list
                start_time = time()
                cur_frame = 0
            except Exception as ex:
                print("Error parsing frame list: %s" % ex)

        if bimpy.button("Play" if paused else "Pause"):
            paused = not paused

        bimpy.end()
        ctx.render()
예제 #15
0
파일: widgets.py 프로젝트: zakx/bimpy
print(pkg_resources.get_distribution("bimpy").version)

ctx = bimpy.Context()

ctx.init(1200, 1200, "Hello")

with ctx:
    bimpy.themes.set_light_theme()

opened = bimpy.Bool(True)

a = 0.0

mylist = ["aaa", "bbb", "ccc"]

selectedItem = bimpy.Int()

vals = [0., 0.1, 0.2, 0.1, 0.4, 0.2]

while (not ctx.should_close()):
    ctx.new_frame()

    if opened.value:
        if bimpy.begin("Hello!", opened=opened):
            bimpy.columns(4, "mycolumns")
            bimpy.separator()
            bimpy.text("Some text")
            bimpy.next_column()
            bimpy.text("Some text")
            bimpy.next_column()
            bimpy.text("Some text")
예제 #16
0
import bimpy
import numpy as np

ctx = bimpy.Context()

ctx.init(1200, 1200, "Draw Commands Test")

with ctx:
    bimpy.themes.set_light_theme()

DATA_POINTS = bimpy.Int(30)
CLASTERS = bimpy.Int(4)

std = bimpy.Float(0.5)

colors = [
    0x4b19e6, 0x4bb43c, 0x19e1ff, 0xc88200, 0x3182f5, 0xb41e91, 0xf0f046,
    0xf032e6, 0xd2f53c, 0xfabebe, 0x008080, 0xe6beff, 0xaa6e28, 0xfffac8,
    0x800000, 0xaaffc3, 0x808000, 0xffd8b1, 0x000080, 0x808080, 0xFFFFFF,
    0x000000
]

datapoints = []


def generate_fake_data():
    datapoints.clear()
    for i in range(CLASTERS.value):
        x = np.random.normal(size=(DATA_POINTS.value, 2))
        alpha = np.random.rand()
        scale = std.value * np.random.rand(2) * np.eye(2, 2)
예제 #17
0
from pyfirmata import Arduino, util, pyfirmata
from array import array
import threading
import time
import bimpy

finalCom = 1 # Minimum port is 1
maxInterval = bimpy.Float()
pinNumber = bimpy.Int()
minPWM = bimpy.Int(0)
maxPWM = bimpy.Int(1)
# trueBool = bimpy.Bool(True)
toggleLight = False
plot_values = array('f',[])
textToggleButton = 'Start flashing LED'
buttonNewColorEnabled = bimpy.Vec4(0,0.33,0.0078,1);

# bimpy.push_style_color(bimpy.Colors.Button,buttonColoredEnabled)

def checkPWM():
    if (currentBoard.digital[pinNumber.value].mode == pyfirmata.PWM):
        return 1
    try:
        currentBoard.digital[pinNumber.value].mode = pyfirmata.PWM
        return 1
    except:
        return 0

def flashLED():
    for i in range(0,9999999):
        if (toggleLight == True):