def main(imageDirectory): fileExtension = ('*.jpg', '*.JPEG', '*.png') images = [] for ext in fileExtension: images.extend(glob.glob(imageDirectory + '/' + ext)) kernelDir = "kernel_zoo" graphJson = "graph_zoo/graph_googlenet.json" graphName = "googlenet" sysMan = aks.SysManager() sysMan.loadKernels(kernelDir) sysMan.loadGraphs(graphJson) graph = sysMan.getGraph(graphName) print("[INFO] Starting enqueue... ") print("[INFO] Running", len(images), "images") sysMan.resetTimer() t0 = time.time() for i, img in enumerate(images): sysMan.enqueueJob(graph, img) sysMan.waitForAllResults() t1 = time.time() print("[INFO] Overall FPS : ", len(images) / (t1 - t0)) sysMan.report(graph) # Destroy SysMan sysMan.clear()
def main(imageDirectory): imgDir = os.path.abspath(imageDirectory) with open(os.path.join(imgDir, 'FDDB_list.txt'), 'r') as f: images = f.readlines() kernelDir = "kernel_zoo" graphJson = "graph_zoo/graph_facedetect.json" graphName = "facedetect" sysMan = aks.SysManager() sysMan.loadKernels(kernelDir) sysMan.loadGraphs(graphJson) graph = sysMan.getGraph(graphName) print("[INFO] Starting enqueue... ") print("[INFO] Running", len(images), "images") sysMan.resetTimer() t0 = time.time() for i, img in enumerate(images): imgPath = os.path.join(imgDir, img.strip()+'.jpg') sysMan.enqueueJob(graph, imgPath) sysMan.waitForAllResults() t1 = time.time() print("[INFO] Overall FPS : ", len(images)/(t1-t0)) sysMan.report(graph) # Destroy SysMan sysMan.clear()
def main(imageDirectory, graphs): fileExtension = ('*.jpg', '*.JPEG', '*.png') kernelDir = "kernel_zoo" sysMan = aks.SysManager() sysMan.loadKernels(kernelDir) lgraphs = {} images = {} # Load graphs for graphName, graphJson in graphs.items(): sysMan.loadGraphs(graphJson) lgraphs[graphName] = sysMan.getGraph(graphName) images = {} total_images = 0 for graphName in lgraphs.keys(): images[graphName] = [] for ext in fileExtension: images[graphName].extend( glob.glob(imageDirectory[graphName] + '/' + ext)) total_images += len(images[graphName]) pushThreads = [] sysMan.resetTimer() t0 = time.time() for name, gr in lgraphs.items(): th = threading.Thread(target=enqJobThread, args=( name, gr, images[name], )) th.start() pushThreads.append(th) for th in pushThreads: th.join() sysMan.waitForAllResults() t1 = time.time() print("\n[INFO] Overall FPS:", total_images / (t1 - t0)) for name, gr in lgraphs.items(): print("\n[INFO] Graph:", name) sysMan.report(gr) print("") # Destroy SysMan sysMan.clear()
def main(imageDirectory): fileExtension = ('*.jpg', '*.JPEG', '*.png') images = [] for ext in fileExtension: images.extend(glob.glob(imageDirectory + '/' + ext)) kernelDir = "kernel_zoo" graphJson = "graph_zoo/graph_resnet50_dpucadf8h.json" graphName = "resnet50" sysMan = aks.SysManager() sysMan.loadKernels(kernelDir) sysMan.loadGraphs(graphJson) graph = sysMan.getGraph(graphName) print("[INFO] Starting enqueue... ") print("[INFO] Running", len(images), "images") batch_size = 1 sysMan.resetTimer() t0 = time.time() for i in range(0, len(images), batch_size): bimg = [] diff = len(images) - i if diff < batch_size: for b in range(batch_size): if b < diff: bimg.append(images[i+b]) else: bimg.append(images[i]) else: for b in range(batch_size): bimg.append(images[i+b]) sysMan.enqueueJob(graph, bimg) bimg.clear() sysMan.waitForAllResults() t1 = time.time() print("[INFO] Overall FPS : ", len(images)/(t1-t0)) sysMan.report(graph) # Destroy SysMan sysMan.clear()
def enqJobThread(name, graph, images): # Get AKS Sys Manager sysMan = aks.SysManager() print("[INFO] Starting Enqueue:", name) for img in images: sysMan.enqueueJob(graph, img)