def wrap(render): global i # animation stops when res is False res = steps(DF) ## if fn is a path each image will be saved to that path #fn = None if i%2==0: fn = './ani{:04d}.png'.format(i) else: fn = None ## render outline num = DF.np_get_edges_coordinates(np_coords) show(render,np_coords[:num,:],fn,r=1.3*ONE) ## render solid #sorted_vert_coordinates = DF.get_sorted_vert_coordinates() #show_closed(render,sorted_vert_coordinates,fn) ## render outline with marked circles #num = DF.np_get_edges_coordinates(np_coords) #show_detail(render,np_coords[:num,:],fn) i += 1 return res
def wrap(render): global i # animation stops when res is False res = steps(DF) ## if fn is a path each image will be saved to that path ## render outline num = DF.np_get_edges_coordinates(np_edges) if not i % 100: show(render,np_edges[:num,:], None, r=1.3*ONE) # render.write_to_png(fn.name()) exporter( DF, fn.name()+'.2obj' ) ## render solid # num = DF.get_sorted_vert_coordinates(np_verts) #show_closed(render,np_verts[:num,:],fn) i += 1 return res
def wrap(steps_itt, render): global i t1 = time() steps(DF) fn = None #edges_coordinates = DF.get_edges_coordinates() #sorted_vert_coordinates = DF.get_sorted_vert_coordinates() #fn = './res/ani{:04d}.png'.format(i) #show_detail(render,edges_coordinates,sorted_vert_coordinates,fn) edges_coordinates = DF.get_edges_coordinates() fn = './res/ani{:04d}.png'.format(i) show(render,edges_coordinates,fn) #sorted_vert_coordinates = DF.get_sorted_vert_coordinates() #fn = './res/ani{:04d}.png'.format(i) #show_closed(render,sorted_vert_coordinates,fn) t2 = time() print_stats(render.steps, t2-t1, DF) i += 1 return True
def main(): from time import time from itertools import count from render.render import Render from modules.helpers import print_stats from modules.show import show from differentialLine import DifferentialLine DF = DifferentialLine(NMAX, NZ, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) #angles = sorted(random(INIT_NUM)*TWOPI) #DF.init_passive_circle_segment(MID,MID,100*ONE, angles) angles = sorted(random(INIT_NUM)*pi*5/8) xys = [] for a in angles: x = 0.5 + cos(a)*0.01 y = 0.5 + sin(a)*0.01 xys.append((x,y)) DF.init_passive_line_segment(xys) for i in count(): t_start = time() steps(DF,STEPS_ITT) t_stop = time() print_stats(i*STEPS_ITT,t_stop-t_start,DF) fn = './res/collapse_e_{:010d}.png'.format(i*STEPS_ITT) num = DF.np_get_edges_coordinates(np_coords) show(render,np_coords[:num,:],fn,ONE)
def main(): from time import time from itertools import count from render.render import Render from modules.helpers import print_stats from modules.show import show from modules.show import show_closed from differentialLine import DifferentialLine DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(NINIT)*TWOPI) DF.init_circle_segment(MID,MID,RAD, angles) t_start = time() for i in count(): DF.optimize_position(STP) spawn_curl(DF,NEARL) if i % STAT_ITT == 0: print_stats(i,time()-t_start,DF) if i % EXPORT_ITT == 0: fn = './res/oryx_bb_{:010d}.png'.format(i) num = DF.np_get_edges_coordinates(np_edges) show(render,np_edges[:num,:],fn) fn = './res/oryx_bb_closed_{:010d}.png'.format(i) num = DF.np_get_sorted_vert_coordinates(np_verts) show_closed(render,np_verts[:num,:],fn)
def main(): from time import time from itertools import count from render.render import Render from modules.helpers import print_stats from modules.show import show from modules.show import show_closed from differentialLine import DifferentialLine DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(NINIT)) DF.init_circle_segment(MID,MID,RAD, angles) for i in count(): t_start = time() steps(DF,STEPS_ITT) t_stop = time() print_stats(i*STEPS_ITT,t_stop-t_start,DF) fn = './res/oryx_bb_{:010d}.png'.format(i*STEPS_ITT) edges_coordinates = DF.get_edges_coordinates() show(render,edges_coordinates,fn) fn = './res/oryx_bb_closed_{:010d}.png'.format(i*STEPS_ITT) sorted_vert_coordinates = DF.get_sorted_vert_coordinates() show_closed(render,sorted_vert_coordinates,fn)
def wrap(render): global i # animation stops when res is False res = steps(DF) ## if fn is a path each image will be saved to that path fn = None ## render outline num = DF.np_get_edges_coordinates(np_edges) show(render,np_edges[:num,:],fn,r=1.3*ONE) ## render solid # num = DF.get_sorted_vert_coordinates(np_verts) #show_closed(render,np_verts[:num,:],fn) i += 1 return res
def wrap(render): global i # animation stops when res is False res = steps(DF) ## if fn is a path each image will be saved to that path fn = None ## render outline num = DF.np_get_edges_coordinates(np_edges) show(render, np_edges[:num, :], fn, r=1.3 * ONE) ## render solid # num = DF.get_sorted_vert_coordinates(np_verts) #show_closed(render,np_verts[:num,:],fn) i += 1 return res
def main(): from time import time from itertools import count from render.render import Render from modules.helpers import print_stats from modules.show import show from modules.show import show_closed from differentialLine import DifferentialLine DF = DifferentialLine(NMAX, FARL * 2, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(NINIT)) DF.init_circle_segment(MID, MID, RAD, angles) for i in count(): t_start = time() steps(DF, STEPS_ITT) t_stop = time() print_stats(i * STEPS_ITT, t_stop - t_start, DF) fn = './res/oryx_bb_{:010d}.png'.format(i * STEPS_ITT) edges_coordinates = DF.get_edges_coordinates() show(render, edges_coordinates, fn) fn = './res/oryx_bb_closed_{:010d}.png'.format(i * STEPS_ITT) sorted_vert_coordinates = DF.get_sorted_vert_coordinates() show_closed(render, sorted_vert_coordinates, fn)
def wrap(steps_itt, render): global i global np_coords t1 = time() steps(DF)# if i%3 == 0: fn = './res/ani{:04d}.png'.format(i) else: fn = None num = DF.np_get_edges_coordinates(np_coords) show(render,np_coords[:num,:],fn,ONE) #sandstroke(render,np_coords[:num,:],8,None) t2 = time() print_stats(render.steps, t2-t1, DF) i += 1 return True
def main(): from time import time from itertools import count from render.render import Render from modules.helpers import print_stats from modules.show import show # from modules.show import show_closed from differentialLine import DifferentialLine from modules.helpers import get_exporter from numpy.random import random from fn import Fn DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) fn = Fn(prefix='./res/') exporter = get_exporter( NMAX, { 'nearl': NEARL, 'farl': FARL, 'stp': STP, 'size': SIZE, 'procs': PROCS } ) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,INIT_RAD, angles) t_start = time() for i in count(): DF.optimize_position(STP) # spawn_curl(DF,NEARL) spawn(DF, NEARL, 0.03) if i % STAT_ITT == 0: print_stats(i,time()-t_start,DF) if i % EXPORT_ITT == 0: name = fn.name() num = DF.np_get_edges_coordinates(np_edges) show(render,np_edges[:num,:],name+'.png') exporter( DF, name+'.2obj' )
def bounding_boxes_images(args, DEFAULT_OID_DIR): if not args.Dataset: dataset_dir = os.path.join(DEFAULT_OID_DIR, 'Dataset') csv_dir = os.path.join(DEFAULT_OID_DIR, 'csv_folder') else: dataset_dir = os.path.join(DEFAULT_OID_DIR, args.Dataset) csv_dir = os.path.join(DEFAULT_OID_DIR, 'csv_folder') name_file_class = 'class-descriptions-boxable.csv' CLASSES_CSV = os.path.join(csv_dir, name_file_class) if args.command == 'downloader': utils.logo(args.command) if args.type_csv is None: print(bc.FAIL + 'Missing type_csv argument.' + bc.ENDC) exit(1) if args.classes is None: print(bc.FAIL + 'Missing classes argument.' + bc.ENDC) exit(1) if args.multiclasses is None: args.multiclasses = 0 folder = ['train', 'validation', 'test'] file_list = {'train':'train-annotations-bbox.csv', 'validation':'validation-annotations-bbox.csv', 'test':'test-annotations-bbox.csv'} if args.classes[0].endswith('.txt'): with open(args.classes[0]) as f: args.classes = f.readlines() args.classes = [x.strip() for x in args.classes] else: args.classes = [arg.replace('_', ' ') for arg in args.classes] if args.additional_label_classes[0].endswith('.txt'): with open(args.additional_label_classes[0]) as f: args.additional_label_classes = f.readlines args.additional_label_classes = [x.strip() for x in args.classes] else: args.additional_label_classes = [arg.replace('_', ' ') for arg in args.additional_label_classes ] if args.multiclasses == '0': utils.mkdirs(dataset_dir, csv_dir, args.classes, args.type_csv) for classes in args.classes: print(bc.INFO + 'Downloading {}.'.format(classes) + bc.ENDC) class_name = classes csvdl.error_csv(name_file_class, csv_dir) df_classes = csvdl.pd.read_csv(CLASSES_CSV, header=None) class_code = df_classes.loc[df_classes[1] == class_name].values[0][0] if args.type_csv in folder: name_file = file_list[args.type_csv] df_val = csvdl.TTV(csv_dir, name_file) if not args.n_threads: download(args, df_classes, df_val, args.type_csv, dataset_dir, class_name, class_code) else: download(args, df_classes, df_val, args.type_csv, dataset_dir, class_name, class_code, threads=int(args.n_threads)) elif args.type_csv == 'all': for i in folder: name_file = file_list[i] df_val = csvdl.TTV(csv_dir, name_file) if not args.n_threads: download(args, df_classes, df_val, folder[i], dataset_dir, class_name, class_code) else: download(args, df_classes, df_val, folder[i], dataset_dir, class_name, class_code, threads=int(args.n_threads)) else: print(bc.FAIL + 'csv file not specified' + bc.ENDC) exit(1) elif args.multiclasses == '1': class_list = args.classes print(bc.INFO + 'Downloading {} together.'.format(class_list) + bc.ENDC) multiclass_name = ['_'.join(class_list)] utils.mkdirs(dataset_dir, csv_dir, multiclass_name, args.type_csv) csvdl.error_csv(name_file_class, csv_dir) df_classes = csvdl.pd.read_csv(CLASSES_CSV, header=None) class_dict = {} for class_name in class_list: class_dict[class_name] = df_classes.loc[df_classes[1] == class_name].values[0][0] for class_name in class_list: if args.type_csv in folder: name_file = file_list[args.type_csv] df_val = csvdl.TTV(csv_dir, name_file) if not args.n_threads: download(args, df_classes, df_val, args.type_csv, dataset_dir, class_name, class_dict[class_name], class_list) else: download(args, df_classes, df_val, args.type_csv, dataset_dir, class_name, class_dict[class_name], class_list, threads=int(args.n_threads)) elif args.type_csv == 'all': for i in folder: name_file = file_list[i] df_val = csvdl.TTV(csv_dir, name_file) if not args.n_threads: download(args, df_classes, df_val, folder[i], dataset_dir, class_name, class_dict[class_name], class_list) else: download(args, df_classes, df_val, folder[i], dataset_dir, class_name, class_dict[class_name], class_list, threads=int(args.n_threads)) elif args.command == 'visualizer': utils.logo(args.command) flag = 0 while True: if flag == 0: print("Which folder do you want to visualize (train, test, validation)? <exit>") image_dir = input("> ") flag = 1 if image_dir == 'exit': exit(1) class_image_dir = os.path.join(dataset_dir, image_dir) print("Which class? <exit>") utils.show_classes(os.listdir(class_image_dir)) class_name = input("> ") if class_name == 'exit': exit(1) download_dir = os.path.join(dataset_dir, image_dir, class_name) label_dir = os.path.join(dataset_dir, image_dir, class_name, 'Label') if not os.path.isdir(download_dir): print("[ERROR] Images folder not found") exit(1) if not os.path.isdir(label_dir): print("[ERROR] Labels folder not found") exit(1) index = 0 print(dedent(""" -------------------------------------------------------- INFO: - Press 'd' to select next image - Press 'a' to select previous image - Press 'e' to select a new class - Press 'w' to select a new folder - Press 'q' to exit You can resize the window if it's not optimal -------------------------------------------------------- """)) show(class_name, download_dir, label_dir, len(os.listdir(download_dir))-1, index) while True: utils.progression_bar(len(os.listdir(download_dir))-1, index+1) k = cv2.waitKey(0) & 0xFF if k == ord('d'): cv2.destroyAllWindows() if index < (len(os.listdir(download_dir)) - 2): index += 1 show(class_name, download_dir, label_dir, len(os.listdir(download_dir))-1, index) elif k == ord('a'): cv2.destroyAllWindows() if index > 0: index -= 1 show(class_name, download_dir, label_dir, len(os.listdir(download_dir))-1, index) elif k == ord('e'): cv2.destroyAllWindows() break elif k == ord('w'): flag = 0 cv2.destroyAllWindows() break elif k == ord('q'): cv2.destroyAllWindows() exit(1) break
def main(): from time import time from itertools import count from iutils.render import Render from modules.helpers import print_stats from modules.show import show # from modules.show import show_closed from differentialLine import DifferentialLine from modules.helpers import get_exporter from numpy.random import random from fn import Fn DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) fn = Fn(prefix='./res/') exporter = get_exporter( NMAX, { 'nearl': NEARL, 'farl': FARL, 'stp': STP, 'size': SIZE, 'procs': PROCS } ) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,INIT_RAD, angles) t_start = time() for i in count(): DF.optimize_position(STP) # spawn_curl(DF,NEARL) spawn(DF, NEARL, 0.03) if i % STAT_ITT == 0: print_stats(i,time()-t_start,DF) if i % EXPORT_ITT == 0: name = fn.name() num = DF.np_get_edges_coordinates(np_edges) show(render,np_edges[:num,:],name+'.png') exporter( DF, name+'.2obj' )
def menu(): print("[{0:.3f}s]".format(time.time() - start_time), end='\n') # while True: try: #inp = raw_input(bold('pc> ')).strip() inp = raw_input(bold('{prompt}> '.format(prompt=os.getcwd()))).strip() except (KeyboardInterrupt, EOFError): print() my_exit(0) if len(inp) == 0: continue if inp in ('h', 'help()'): info() elif inp in ('q', 'qq', ':q', ':x', 'quit()', 'exit()'): my_exit(0) elif inp in ('c', 'clear()'): os.system('clear') print_header() elif inp in ('light()', 'dark()'): if inp == 'light()': cfg.g.BACKGROUND = cfg.LIGHT else: cfg.g.BACKGROUND = cfg.DARK elif inp in ('t', 'tags()', 'all()', 'd'): SearchHits.show_tag_list(tag2keys.keys()) elif inp == 'p': os.system("python") elif inp == 'p3': os.system("python3") elif inp == 'bpy': os.system("bpython") elif inp == 'last()': print(last_key) elif inp == '!!': if last_key: perform_action(last_key) elif inp.startswith('!'): cmd = inp[1:] os.system(cmd) elif inp == 'edit()': if last_key: edit(last_key) elif inp == 'gedit()': if last_key: gedit(last_key) elif inp == 'less()': if last_key: less(last_key) elif inp in ('urls()', 'links()'): if last_key: show_urls(last_key) elif inp in ('cb()', 'tocb()'): if last_key: to_clipboards(last_key) elif inp == 'path()': if last_key: path_to_clipboards(last_key) elif inp == "doc()": if last_key: show_doc(last_key) elif inp == 'json.reload()': read_json() elif inp in ('json.view()', 'json.edit()'): if last_key: view_edit_json(last_key) read_json() elif inp in ("json.edit(this)", "jet()"): if last_key: edit_entry(last_key) elif inp == 'reddit()': reddit.reddit() elif inp == 'conferences()': conferences.conferences() elif inp == 'mute()': apps.radio.radio(None, stop=True) elif inp == 'myip()': my_ip.show_my_ip() elif inp in ('v', 'version()'): version() elif inp == 'commands()': show_commands() elif inp == 'add()': add_item() read_json() elif inp == 'hits()': SearchHits.show_tag_list() elif inp.startswith("pymotw:"): site = "pymotw.com" cmd_go1(inp[inp.find(':')+1:], site=site) elif inp.startswith("go:"): cmd_google(inp[inp.find(':')+1:]) elif inp.startswith("go1:"): cmd_go1(inp[inp.find(':')+1:]) elif inp.startswith("imdb:"): site = "imdb.com" cmd_go1(inp[inp.find(':')+1:], site=site) elif inp.startswith("amazon:"): site = "amazon.com" cmd_go1(inp[inp.find(':')+1:], site=site) elif inp.startswith("youtube:"): cmd_youtube(inp[inp.find(':')+1:]) elif inp.startswith("wp:"): site = "wikipedia.org" cmd_go1(inp[inp.find(':')+1:], site=site) elif inp.startswith("lib:") or inp.startswith("lib2:"): site = "docs.python.org/2/library/" cmd_go1(inp[inp.find(':')+1:], site=site) elif inp.startswith("lib3:"): site = "docs.python.org/3/library/" cmd_go1(inp[inp.find(':')+1:], site=site) elif inp.startswith("golib:"): site = "http://golang.org/pkg/" lib = inp[inp.find(':')+1:] open_url(urljoin(site, lib)) elif inp.startswith("shorten:"): urlshortener.shorten_url(inp[inp.find(':')+1:]) elif inp.startswith("def:"): cmd_def(inp[inp.find(':')+1:]) elif inp.startswith("pep:"): open_pep(inp[inp.find(':')+1:]) elif inp == 'pep()': open_pep(None) elif inp == 'show()': show.show() elif inp == 'numbers()': toggle_line_numbers() elif re.search(r"^l([\d,-]+)\.(sh|py|py2|py3|cb|cb\(>\))$", inp): fname = key_to_file(last_key) selected_lines.process_selected_lines(inp, fname) elif inp == 'cd' or inp.startswith('cd '): change_dir(inp) elif inp == 'pwd()': print(os.getcwd()) elif inp == 'userpass()': username_password() elif inp == 'apps()': apps.menu.main() elif inp == 'k': os.system("konsole 2>/dev/null &") elif inp.startswith("filter:"): term = inp[inp.find(':')+1:] if last_key: perform_action(last_key, term) elif inp.startswith("app:"): val = inp[inp.find(':')+1:] if not val: apps.menu.main() else: apps.menu.start_app(val) # shortcuts elif inp == 'radio()': apps.menu.start_app_by_shortcut('radio') # disabled, always show the search hits #elif inp in tag2keys: # tag = inp # command(tag) elif re.search(r'^\d+$', inp): try: index = int(inp) - 1 if index < 0: raise IndexError tag = SearchHits.hits[index].tag command(tag) except IndexError: print("out of range...") elif re.search(r'^\d+\.(doc|action|tags|json|url|link|key|jet|edit)(\(\))?$', inp): try: pos = inp.find('.') index = int(inp[:pos]) - 1 what = inp[pos+1:].rstrip("()") if index < 0: raise IndexError hit = SearchHits.hits[index] hit.inspect(what) except IndexError: print("out of range...") elif re.search(r'^this.(doc|action|tags|json|url|link|key|jet|edit)(\(\))?$', inp): try: if not last_key: raise NoLastKeyError pos = inp.find('.') what = inp[pos+1:].rstrip("()") hit = Hit(tag=None, key=last_key) hit.inspect(what) except NoLastKeyError: pass elif inp == 'pid()': pidcheck.pid_alert() elif inp == 'debug()': debug(None) elif inp == 'song()': print("Playing:", apps.radio.get_song()) else: if len(inp) == 1: print("too short...") else: inp = inp.lower() SearchHits.show_hint(inp)