def __init__(self, model_path, ui, kNN=3, buffer_length=4): self._engine = kNNEmbeddingEngine(model_path, kNN) self._ui = ui self._buffer = deque(maxlen=buffer_length) self._kNN = kNN self._start_time = time.time() self._frame_times = deque(maxlen=40) self.clean_shutdown = False
def __init__(self, model_path, ui, kNN=3, buffer_length=4): assert os.path.isfile( model_path), 'Model file %s not found' % model_path self._engine = kNNEmbeddingEngine(model_path, kNN) self._ui = ui self._buffer = deque(maxlen=buffer_length) self._kNN = kNN self._start_time = time.time() self._frame_times = deque(maxlen=40)
def __init__(self, model_path, ui, kNN=3, buffer_length=4): assert os.path.isfile(model_path), 'Model file %s not found'%model_path self._engine = kNNEmbeddingEngine(model_path, kNN) self._ui = ui self._buffer = deque(maxlen = buffer_length) self._kNN = kNN self._start_time = time.time() self._frame_times = deque(maxlen=40) self._servoFlag = threading.Event() #this controls when the thread runs self._servo = threading.Thread(target=self.servoRun, args=tuple([self._servoFlag]), daemon=True) #daemon means it shuts off w/ rest of program self._servo.start()
def __init__(self, model_path, kNN=3, buffer_length=4, session=False): self._engine = kNNEmbeddingEngine(model_path, kNN) self._buffer = deque(maxlen=buffer_length) self._kNN = kNN self._start_time = time.time() self._frame_times = deque(maxlen=40) self.clean_shutdown = False self.session_name = session self.categoriesImageDic = dict() if session: self.load(session) else: print("No session name specified. Saving and loading is disabled") BLACK = (0, 0, 0) self.SCREENDIMENSIONS = (800, 600) self.screen = pygame.display.set_mode(self.SCREENDIMENSIONS, 0, 32) self.screen.fill(BLACK)
from PIL import Image from io import BytesIO from threading import Lock, Thread lock = Lock() # edge-tpu from embedding import kNNEmbeddingEngine ## parameter configuration model_path = "test_data/mobilenet_v2_1.0_224_quant_edgetpu.tflite" width = 224 height = 224 kNN = 3 engine = kNNEmbeddingEngine(model_path, kNN) app = Flask(__name__, static_url_path = "") # global variables brokerURL = '' outputs = [] timer = None lock = threading.Lock() counter = 0 camera = None cameraURL = '' @app.errorhandler(400) def not_found(error):