forked from codebox/image_augmentor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounter.py
29 lines (23 loc) · 793 Bytes
/
counter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from multiprocessing.dummy import Lock
class Counter:
def __init__(self):
self.lock = Lock()
self._processed = 0
self._error = 0
self._skipped_no_match = 0
self._skipped_augmented = 0
def processed(self):
with self.lock:
self._processed += 1
def error(self):
with self.lock:
self._error += 1
def skipped_no_match(self):
with self.lock:
self._skipped_no_match += 1
def skipped_augmented(self):
with self.lock:
self._skipped_augmented += 1
def get(self):
with self.lock:
return {'processed' : self._processed, 'error' : self._error, 'skipped_no_match' : self._skipped_no_match, 'skipped_augmented' : self._skipped_augmented}