-
Notifications
You must be signed in to change notification settings - Fork 9
/
sin.py
54 lines (44 loc) · 1.62 KB
/
sin.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
import os
import signal
import sys
from argparse import Namespace
if sys.version_info < (3, 10):
print('Python version is not supported - please upgrade to 3.10 or higher.')
quit()
from sinner.Benchmark import Benchmark
from sinner.Parameters import Parameters
from sinner.BatchProcessingCore import BatchProcessingCore
from sinner.Sinner import Sinner
from sinner.gui.GUIForm import GUIForm
from sinner.webcam.WebCam import WebCam
from sinner.utilities import limit_resources
class Sin(Sinner):
gui: bool
benchmark: bool
camera: bool
max_memory: int
parameters: Namespace
def __init__(self) -> None:
signal.signal(signal.SIGINT, lambda signal_number, frame: quit())
self.parameters = Parameters().parameters
super().__init__(parameters=self.parameters)
self.update_parameters(self.parameters)
limit_resources(self.max_memory)
def run(self) -> None:
if self.gui:
preview = GUIForm(parameters=self.parameters)
window = preview.show()
window.mainloop()
elif self.benchmark is True:
Benchmark(parameters=self.parameters)
elif self.camera is True:
WebCam(parameters=self.parameters).run()
else:
BatchProcessingCore(parameters=self.parameters).run()
if __name__ == '__main__':
# todo: remnants of roop code, needs to be checked
# single thread doubles cuda performance - needs to be set before torch import
if any(arg.startswith('--execution-provider') for arg in sys.argv):
os.environ['OMP_NUM_THREADS'] = '1'
Sin().run()