def train_algorithm(request): module_id = request.GET.get('module_id') scene_id = request.GET.get('scene_id') limit = request.GET.get('limit') if scene_id and module_id: tmp = utils.get_scene_record(module_id,scene_id) for i in tmp: i['data_length'] = range(len(i['data'][i['data'].keys()[0]])) i['resources'] = [] i['apis'] = [] i['api_info'] = [] api_dict = {} for k in i['data'].keys(): if k != 'total' and k.find('#api#') != 0: i['resources'].append(k) if k != 'total' and k.find('#api#') == 0: api_dict[k[5:]] = i['data'][k] #this_api_id = utils.get_api_by_name(k[5:]) i['api_info'].append(k) # TODO for j in i['data_length']: current_api_dict = {} for k,v in api_dict.iteritems(): current_api_dict[k] = v[j] i['apis'].append(current_api_dict) if limit and int(limit) > 0: ret = {'scene_records' : tmp[:int(limit)]} else: ret = {'scene_records': tmp} ret['module_id'] = module_id ret['scene_id'] = scene_id scene_api = utils.get_scene_api(module_id, scene_id) for s in scene_api: s['api_info'] = utils.get_api(s.get('api_id')) # ge threhold if s['api_info']: s['api_info']['threholds'] = utils.get_api_resource(s.get('api_id')) for th in s['api_info']['threholds'].get('resource_list'): th['name'] = utils.get_resource(th.get('resource_id')).get('name') ret['scene_info'] = utils.get_scene(scene_id) ret['module_info'] = utils.get_module(module_id) ret['scene_api'] = scene_api ret['all_resource'] = [] all_resource_ids = [] # get all resource need for s in scene_api: for id in s.get('api_info').get('threholds').get('resource_id'): if not id in all_resource_ids: all_resource_ids.append(id) ret['all_resource'].append(utils.get_resource(id)) ret["public"] = utils.get_public(request) return render(request, 'assess/train_algorithm.html', {'data': ret}) else: return render(request, 'error.html')
def resize_xy(xy, vname, resize_w, resize_h): """Resize the xy coordinates.""" x_, y_ = xy w, h = scene2imgsize[get_scene(vname)] diff_w = resize_w / float(w) diff_h = resize_h / float(h) x_ *= diff_w y_ *= diff_h # normalize coordinates? return [x_, y_]
def resize_box(box, vname, resize_w, resize_h): """Resize the box coordintates.""" x1, y1, x2, y2 = [float(o) for o in box] w, h = scene2imgsize[get_scene(vname)] diff_w = resize_w / float(w) diff_h = resize_h / float(h) x1 *= diff_w x2 *= diff_w y1 *= diff_h y2 *= diff_h return [x1, y1, x2, y2]
def module_view(request): module_id = request.GET.get("module_id") data = {} data["module_id"] = module_id data["public"] = utils.get_public(request) scenes = utils.get_scene() data["scene"] = scenes for scene in scenes: scene_id = scene["id"] api_list = utils.get_scene_api(module_id, scene_id) scene["api_list"] = [] for api in api_list: api["info"] = utils.get_api(api["api_id"]) scene["api_list"].append(api) return render(request, 'assess/module.html', {"data":data})
if __name__ == "__main__": args = parser.parse_args() video_filenames = [line.strip() for line in open(args.filelst).readlines()] if not os.path.exists(args.out_path): os.makedirs(args.out_path) count = 0 for video_filename in tqdm(video_filenames): count += 1 if (count % args.job) != (args.curJob - 1): continue scene = get_scene(video_filename) imgsize = scene2imgsize[scene] box_file = os.path.join(args.anno_path, video_filename + ".geom.yml") type_file = os.path.join(args.anno_path, video_filename + ".types.yml") act_file = os.path.join(args.anno_path, video_filename + ".activities.yml") # load each track id and its trajectories origin_trackid2object = load_tracks(type_file) trackid2object = {trackid: origin_trackid2object[trackid] for trackid in origin_trackid2object if origin_trackid2object[trackid] in object2id} # load traj boxes for the trackid person_tracks = {} # trackid -> boxes
# set the world to sync mode settings = world.get_settings() settings.synchronous_mode = True settings.fixed_delta_seconds = 1.0 / 30.0 world.apply_settings(settings) client_clock = pygame.time.Clock() # the main loop, go over each trajectory files for traj_file in tqdm(traj_files): filename = os.path.splitext(os.path.basename(traj_file))[0] this_moment_count, this_success_count = 0, 0 if args.is_actev: scene = get_scene(filename) if args.only_scene is not None: if scene != args.only_scene: continue else: scene = filename static_scene = static_scenes[scene] # changing the map everytime to reset world = client.load_world(static_scene["map"]) # set world fps settings = world.get_settings() settings.synchronous_mode = True settings.fixed_delta_seconds = 1.0 / static_scene["fps"] world.apply_settings(settings)
def train_algorithm(request): module_id = request.GET.get('module_id') scene_id = request.GET.get('scene_id') limit = request.GET.get('limit') if scene_id and module_id: tmp = utils.get_scene_record(module_id, scene_id) for i in tmp: i['data_length'] = range(len(i['data'][i['data'].keys()[0]])) i['resources'] = [] i['apis'] = [] i['api_info'] = [] api_dict = {} for k in i['data'].keys(): if k != 'total' and k.find('#api#') != 0: i['resources'].append(k) if k != 'total' and k.find('#api#') == 0: api_dict[k[5:]] = i['data'][k] #this_api_id = utils.get_api_by_name(k[5:]) i['api_info'].append(k) # TODO for j in i['data_length']: current_api_dict = {} for k, v in api_dict.iteritems(): current_api_dict[k] = v[j] i['apis'].append(current_api_dict) if limit and int(limit) > 0: ret = {'scene_records': tmp[:int(limit)]} else: ret = {'scene_records': tmp} ret['module_id'] = module_id ret['scene_id'] = scene_id scene_api = utils.get_scene_api(module_id, scene_id) for s in scene_api: s['api_info'] = utils.get_api(s.get('api_id')) # ge threhold if s['api_info']: s['api_info']['threholds'] = utils.get_api_resource( s.get('api_id')) for th in s['api_info']['threholds'].get('resource_list'): th['name'] = utils.get_resource( th.get('resource_id')).get('name') ret['scene_info'] = utils.get_scene(scene_id) ret['module_info'] = utils.get_module(module_id) ret['scene_api'] = scene_api ret['all_resource'] = [] all_resource_ids = [] # get all resource need for s in scene_api: for id in s.get('api_info').get('threholds').get('resource_id'): if not id in all_resource_ids: all_resource_ids.append(id) ret['all_resource'].append(utils.get_resource(id)) ret["public"] = utils.get_public(request) return render(request, 'assess/train_algorithm.html', {'data': ret}) else: return render(request, 'error.html')
def get_scene_view(request): id = request.GET.get("id") ret = utils.get_scene(id) return public.success_result_http(ret)
def scene_view(request): data = {} data["public"] = utils.get_public(request) data["scene"] = utils.get_scene() return render(request, 'assess/scene.html', {"data":data})