def main(ttype, ddirs): conf = parse_ymal(consts.CONFIG_FILE)[ttype] for ddir in ddirs: # obj = TrainPrepareV1(conf, ddir) # obj = TrainCutV1(conf, ddir) obj = TrainClusterV1(conf, ddir) obj.run()
def tasks(request): conf = utils.parse_ymal(consts.CONFIG_FILE)['train'] videos = [] [[videos.append(os.path.join(p, ele)) for ele in os.listdir(p)] for p in conf['video']] schedule = [{ 'video': v, 'ticket': 'Ready' if os.path.exists( os.path.join(conf['identity_dir'], os.path.basename(v), 'id_data_ticket')) else 'unReady', 'identity': 'Ready' if os.path.exists( os.path.join(conf['identity_dir'], os.path.basename(v), 'id_data_cluster')) else 'unReady' } for v in videos] tasks = Task.objects.all() running = [{ 'name': t.name, 'detail': t.detail, 'procedure': t.procedure } for t in tasks] context = {'schedule': schedule, 'running': running} return render(request, 'tasks.html', context)
def _report_status(path): conf = utils.parse_ymal(consts.CONFIG_FILE)['train'] headers = {'Content-Type': 'application/json'} url = 'http://{}/task/update'.format(conf['server']['controller']) data = {'path': path, 'type': 'cluster'} resp = requests.post(url, data=json.dumps(data), headers=headers)
def start(request): # import pdb;pdb.set_trace() body = json.loads(request.body) try: path = body['path'] except KeyError: resp = {'code': 1, 'msg': 'path param is None'} return HttpResponse(json.dumps(resp)) conf = utils.parse_ymal(consts.CONFIG_FILE)['train'] obj = TrainClusterV1(conf, path) pool.apply_async(_wrapper, (obj, path)) resp = {'code': 0, 'msg': 'success'} return HttpResponse(json.dumps(resp))
def _clean(path): conf = utils.parse_ymal(consts.CONFIG_FILE)['train'] scenario = os.path.basename(path) actual_count = len( os.listdir( os.path.join( conf['output']['path'][int(scenario) % conf['output']['total']], scenario, 'cluster/id_data_result'))) identity_path = os.path.join(conf['identity_dir'], scenario, 'id_data_cluster') total_count = len(os.listdir(identity_path)) / 2 url = 'http://{}/task/start'.format(conf['server']['clean']) data = { 'path': path, 'date': '{}_{}_{}'.format(scenario, actual_count, total_count) } _send_request(url, data)
def start(request): body = json.loads(request.body) try: paths = body['paths'] except KeyError: resp = {'code': 1, 'msg': 'missing paths args'} return HttpResponse(json.dumps(resp)) if not isinstance(paths, list): resp = {'code': 1, 'msg': 'paths must be list'} return HttpResponse(json.dumps(resp)) conf = utils.parse_ymal(consts.CONFIG_FILE)['train'] _prepare(conf, paths) _remount(conf) _cut(conf, paths) resp = {'code': 0, 'msg': 'SUCCESS'} return HttpResponse(json.dumps(resp))
def main(process, ddirs): conf = utils.parse_ymal(consts.CONFIG_FILE) cclass = conf['classes'][process]['process'] obj = utils.get_subclass('process', Process, cclass)(process, conf, ddirs) obj.run()
import json import requests from django.http import HttpResponse from face.common import utils from face.common import constants as consts from face.cut import _wapper from face.cut.train import TrainIpcV1 from utils.pools import GPUPool index = 0 conf = utils.parse_ymal(consts.CONFIG_FILE)['train'] def _report_status(path): headers = {'Content-Type': 'application/json'} url = 'http://{}/task/update'.format(conf['server']['controller']) data = {'path': path} resp = requests.post(url, data=json.dumps(data), headers=headers) def wrapper(obj, path): _wapper(obj) _report_status(path) gpupool = GPUPool(conf['cut']['gpu']['total'], conf['cut']['gpu']['process']) # Create your views here.
def _cluster(path): conf = utils.parse_ymal(consts.CONFIG_FILE)['train'] url = 'http://{}/cluster/start'.format(conf['server']['cluster']) data = {'path': path} _send_request(url, data)