From aca97cea75d2d1021293c906dc138002079feef6 Mon Sep 17 00:00:00 2001 From: iperov Date: Sun, 29 Aug 2021 16:15:44 +0400 Subject: [PATCH] upd developer_faq.md --- __dev_archived/_trash.txt | 91 ++++++++++++++++++++++++++++++ doc/developer_faq/developer_faq.md | 13 +++++ 2 files changed, 104 insertions(+) diff --git a/__dev_archived/_trash.txt b/__dev_archived/_trash.txt index 3b244db..1f8c111 100644 --- a/__dev_archived/_trash.txt +++ b/__dev_archived/_trash.txt @@ -1,3 +1,94 @@ +from collections import deque +from queue import Queue +from typing import Any, Union, Tuple + +def MTOrderedData(queue_size=0): + """ + Multithreaded ordered work. + + Ensures the order of work done by threads. + returns (host,client) classes. + """ + h2c, c2h = Queue(maxsize=queue_size), Queue(maxsize=queue_size) + + host = _MTOrderedDataHost(h2c, c2h) + cli = _MTOrderedDataClient(h2c, c2h) + return host, cli + +class _MTOrderedDataHost: + """ + """ + def __init__(self, h2c : Queue, c2h : Queue): + self._h2c = h2c + self._c2h = c2h + self._counter = 0 + + self._sent_ids = deque() + self._done_datas = {} + + def send(self, data): + """ + send the data to the clients + """ + if data is None: + raise ValueError('data cannot be None') + + c = self._counter + self._counter += 1 + self._sent_ids.append(c) + + self._h2c.put( (c, data) ) + + def recv(self) -> Union[Any, None]: + sent_ids = self._sent_ids + + if len(sent_ids) != 0: + done_datas = self._done_datas + + while not self._c2h.empty(): + id, data = self._c2h.get() + done_datas[id] = data + + id = sent_ids[0] + + if id in done_datas: + done_data = done_datas.pop(id) + sent_ids.popleft() + print('len(sent_ids) ', len(sent_ids)) + return done_data + + return None + + +class _MTOrderedDataClient: + + + def __init__(self, h2c : Queue, c2h : Queue): + self._h2c = h2c + self._c2h = c2h + + + def send(self, data_id, data): + """ + """ + self._c2h.put( (data_id, data) ) + + + def recv(self, wait=True) -> Tuple[int, Any]: + """ + returns ( data_id(int), data(Any) ) or None + """ + h2c = self._h2c + + if not wait and h2c.empty(): + return None + + id, data = h2c.get() + return id, data + + + + from xlib import time as lib_time import numpy as np diff --git a/doc/developer_faq/developer_faq.md b/doc/developer_faq/developer_faq.md index 37795e8..c120153 100644 --- a/doc/developer_faq/developer_faq.md +++ b/doc/developer_faq/developer_faq.md @@ -9,7 +9,20 @@ All CPU-intensive tasks are done by native libraries compiled for Python, such a It consists of backend modules that work in separate processes. The modules work like a conveyor belt. CameraSource(FileSource) generates the frame and sends it to the next module for processing. The final output module outputs the stream to the screen with the desired delay. Backend modules manage the abstract controls that are implemented in the UI. Thus, the Model-View-Controller pattern is implemented. To reduce latency, some custom interprocess communication elements are implemented. +## What are the current problems for implementation for AMD ? +* Very slow inference in DirectML build of onnxruntime. + +* no alternative for CuPy. Without CuPy FaceMerger will only work on the CPU, which is only applicable for frames less than 720p. + + +## What are the current problems for implementation for Linux ? + +No problems. Technically, you only need to write an installer, and check the work of all the modules. You may have to make some adjustments somewhere. I do not use linux, so I do not have time to support development on it. + +## How many people were involved in the development? + +Just me. It took eight months until the first release.