- abort by user [q]
- cycle through training patetrn by [+],[-] keys
[Status]
- improved report interval
- added on_report(): called every report iterval
This commit is contained in:
2025-12-17 19:14:57 +01:00
parent 866b61c77b
commit 8dcf0872b9
2 changed files with 22 additions and 10 deletions
+19 -8
View File
@@ -15,19 +15,30 @@ class MyStatus(Status):
Status.__init__(self, update_interval=2)
self.stack = _stack
self.batch = _batch
self.index = 0
def on_report(self, status: dict) -> bool:
# Show reconstruction
do_continue = True
# print status values
Status.print_status(status)
# Shape of training vector
shape = self.stack.from_index(0).shape[0:2] + (1,)
for n in range(self.batch.shape[0]):
img = self.stack.pass_down_up(self.batch[n,:])
cv_show("img", img, shape)
cv.waitKeyEx(1)
# User input
max_index = self.batch.shape[0]
key = cv.waitKeyEx(1)
if key == ord('q'):
do_continue = False
if key == ord('-'):
self.index = max(0, self.index-1)
if key == ord('+'):
self.index = min(max_index, self.index+1)
Status.print_status(status)
return True
# Show reconstruction
img = self.stack.pass_down_up(self.batch[self.index,:])
cv_show("img", img, shape)
return do_continue
def read_armadillo(filename: str) -> np.ndarray:
result = None
@@ -76,7 +87,7 @@ def main(prj_name: str = "test"):
stack.state_save()
if __name__ == "__main__":
main("prims")
main("norb_small_16h")
cv.destroyAllWindows()
print("Test: [passed]")
+3 -2
View File
@@ -15,6 +15,7 @@ class Status:
print(f"{key} : {value}{unit}")
def on_change(self, status: dict) -> bool:
do_continue = True
if status == {}:
self.progress = -1
@@ -22,9 +23,9 @@ class Status:
progress = status["progress"]['value']
if self.progress < 0 or progress - self.progress >= self.update_interval:
self.progress = progress
self.on_report(status=status)
do_continue = self.on_report(status=status)
return True
return do_continue
def on_report(self, status: dict) -> bool:
return True