BlackBeenie commited on
Commit
708bd64
1 Parent(s): fe3fdf0

feat: Add runnable python files

Browse files
Files changed (2) hide show
  1. run.py +6 -0
  2. settings.py +56 -0
run.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+
3
+ from roop import core
4
+
5
+ if __name__ == '__main__':
6
+ core.run()
settings.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yaml
2
+
3
+ class Settings:
4
+ def __init__(self, config_file):
5
+ self.config_file = config_file
6
+ self.load()
7
+
8
+ def default_get(_, data, name, default):
9
+ value = default
10
+ try:
11
+ value = data.get(name, default)
12
+ except:
13
+ pass
14
+ return value
15
+
16
+
17
+ def load(self):
18
+ try:
19
+ with open(self.config_file, 'r') as f:
20
+ data = yaml.load(f, Loader=yaml.FullLoader)
21
+ except:
22
+ data = None
23
+
24
+ self.selected_theme = self.default_get(data, 'selected_theme', "Default")
25
+ self.server_name = self.default_get(data, 'server_name', "")
26
+ self.server_port = self.default_get(data, 'server_port', 0)
27
+ self.server_share = self.default_get(data, 'server_share', True)
28
+ self.output_image_format = self.default_get(data, 'output_image_format', 'png')
29
+ self.output_video_format = self.default_get(data, 'output_video_format', 'mp4')
30
+ self.output_video_codec = self.default_get(data, 'output_video_codec', 'libx264')
31
+ self.video_quality = self.default_get(data, 'video_quality', 14)
32
+ self.clear_output = self.default_get(data, 'clear_output', True)
33
+ self.max_threads = self.default_get(data, 'max_threads', 8)
34
+ self.provider = self.default_get(data, 'provider', 'cuda')
35
+
36
+
37
+
38
+ def save(self):
39
+ data = {
40
+ 'selected_theme': self.selected_theme,
41
+ 'server_name': self.server_name,
42
+ 'server_port': self.server_port,
43
+ 'server_share': self.server_share,
44
+ 'output_image_format' : self.output_image_format,
45
+ 'output_video_format' : self.output_video_format,
46
+ 'output_video_codec' : self.output_video_codec,
47
+ 'video_quality' : self.video_quality,
48
+ 'clear_output' : self.clear_output,
49
+ 'max_threads' : self.max_threads,
50
+ 'provider' : self.provider
51
+ }
52
+ with open(self.config_file, 'w') as f:
53
+ yaml.dump(data, f)
54
+
55
+
56
+