from lib.config import load_config from lib.export import export CONFIG = "./experiments/001.yaml" BOX_DIR = "D:/Box" cfg = load_config(CONFIG) export(cfg, BOX_DIR)
from os import chdir, path from time import sleep # Make this script's directory the current working directory (could be anything else) # and add it to sys.path (this script runs from blender context) elmyra_root = path.dirname(path.realpath(__file__)) chdir(elmyra_root) sys.path.append(elmyra_root) from lib import common, export, render, version from lib.context import VISUALIZATIONS_DIR def parse_custom_args(): parser = ArgumentParser(prog='Elmyra Render Params') parser.add_argument("--id", required=True) parser.add_argument('--device', default='CPU') parser.add_argument('--target-time', type=int, default=60) custom_args = sys.argv[sys.argv.index('--') + 1:] return parser.parse_args(custom_args) args = parse_custom_args() common.ensure_addons() if version.open_latest(path.join(VISUALIZATIONS_DIR, args.id)): render.render(args.target_time, args.device) export.export()
# -*- coding: utf-8 -*- import sys if __name__ == '__main__': if sys.argv[-1] == 'get_password': from lib import main main.getPassword() elif sys.argv[-1] == 'export_remove_all': from lib import main main.removeExported() elif sys.argv[-1] == 'export_refresh': from lib import main main.refreshExported() elif sys.argv[-1] == 'export': from lib import export export.export(category=sys.argv[-2]) else: from lib import main main.main()
def process_img(threader, dirname, ocr_langs, words, img, link, lock, imghash, running, tessconfig, debug): th_name = threading.current_thread().name log(f"Starting the image analyse on {link}", timecode=dirname, cfg=cfg, level="INFO", hidden=False, debug=debug) stats = check_n_update_export(dirname, imghash, link, cfg["regexs"], lock) # We avoid duplicated pictures if stats: log("This image has already been processed, I'm just updating his stats.", timecode=dirname, cfg=cfg, level="GOOD", hidden=False, debug=debug) if not stats and imghash in running: log("This image is currently being processed by another thread, I wait for him to finish.", timecode=dirname, cfg=cfg, level="WARNING", hidden=False, debug=debug) res = threader.getresultDict() timeout = cfg["thread_retry_timeout"] timeout_start = time.time() while imghash not in res.values(): if time.time() < timeout_start + timeout: log("Timeout while retrying, aborting thread.", timecode=dirname, cfg=cfg, level="ERROR", hidden=False, debug=debug) break sleep(0.5) log("Retrying...", timecode=dirname, cfg=cfg, level="WARNING", hidden=False, debug=debug) res = threader.getresultDict() else: log("The another thread finished ! I'm resuming.", timecode=dirname, cfg=cfg, level="GOOD", hidden=False, debug=debug) sleep(1) stats = check_n_update_export(dirname, imghash, link, cfg["regexs"], lock) if not stats: stats_list = [] first_text = None for lang in ocr_langs: log(f"Starting OCR with {lang.upper()} lang", timecode=dirname, cfg=cfg, level="INFO", hidden=False, debug=debug) text = ocr(img, lang, tessconfig) if not first_text: first_text = text Detect = Detection(words, cfg["regexs"]) stats = Detect.run(text) stats_list.append(stats) stats = sum_stats(stats_list) if sum([group["count"] for group in stats["groups"].values()]) > 0: log("Image analyzed ! I found things !", timecode=dirname, cfg=cfg, level="COOL", hidden=False, debug=debug) log(f"{stats}", timecode=dirname, cfg=cfg, level="INFO", hidden=False, debug=debug) else: log("Image analyzed ! I found nothing.", timecode=dirname, cfg=cfg, level="INFO", hidden=False, debug=debug) with lock: export(dirname, stats, link, imghash, img, first_text) #print(stats) return {"hash": imghash, "stats": stats}