Spaces:
Running
Running
Update roop/globals.py
Browse files- roop/globals.py +65 -67
roop/globals.py
CHANGED
@@ -1,76 +1,74 @@
|
|
1 |
-
|
2 |
|
3 |
-
#
|
4 |
-
source_path
|
5 |
-
target_path
|
6 |
-
output_path
|
7 |
-
frame_processors
|
8 |
-
keep_fps
|
9 |
-
keep_audio
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
video_quality: Optional[int] = None
|
14 |
-
max_memory: Optional[int] = None
|
15 |
-
execution_providers: List[str] = []
|
16 |
-
execution_threads: Optional[int] = None
|
17 |
-
headless: Optional[bool] = None
|
18 |
-
log_level: str = 'error'
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
def
|
22 |
-
source_path: Optional[str] = None,
|
23 |
-
target_path: Optional[str] = None,
|
24 |
-
output_path: Optional[str] = None,
|
25 |
-
frame_processors: List[str] = [],
|
26 |
-
keep_fps: Optional[bool] = None,
|
27 |
-
keep_audio: Optional[bool] = None,
|
28 |
-
keep_frames: Optional[bool] = None,
|
29 |
-
many_faces: Optional[bool] = None,
|
30 |
-
video_encoder: Optional[str] = None,
|
31 |
-
video_quality: Optional[int] = None,
|
32 |
-
max_memory: Optional[int] = None,
|
33 |
-
execution_providers: List[str] = [],
|
34 |
-
execution_threads: Optional[int] = None,
|
35 |
-
headless: Optional[bool] = None,
|
36 |
-
log_level: str = 'error'
|
37 |
-
) -> None:
|
38 |
"""
|
39 |
-
|
40 |
|
41 |
Args:
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
frame_processors (List[str]): List of frame processors.
|
46 |
-
keep_fps (Optional[bool]): Whether to keep the original FPS.
|
47 |
-
keep_audio (Optional[bool]): Whether to keep the original audio.
|
48 |
-
keep_frames (Optional[bool]): Whether to keep temporary frames.
|
49 |
-
many_faces (Optional[bool]): Whether to process every face.
|
50 |
-
video_encoder (Optional[str]): Video encoder to use.
|
51 |
-
video_quality (Optional[int]): Video quality setting.
|
52 |
-
max_memory (Optional[int]): Maximum amount of memory in GB.
|
53 |
-
execution_providers (List[str]): List of execution providers.
|
54 |
-
execution_threads (Optional[int]): Number of execution threads.
|
55 |
-
headless (Optional[bool]): Whether to run in headless mode.
|
56 |
-
log_level (str): Log level to use.
|
57 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
global source_path, target_path, output_path, frame_processors, keep_fps, keep_audio
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
-
source_path = source_path
|
63 |
-
target_path = target_path
|
64 |
-
output_path = output_path
|
65 |
-
frame_processors = frame_processors
|
66 |
-
keep_fps = keep_fps
|
67 |
-
keep_audio = keep_audio
|
68 |
-
keep_frames = keep_frames
|
69 |
-
many_faces = many_faces
|
70 |
-
video_encoder = video_encoder
|
71 |
-
video_quality = video_quality
|
72 |
-
max_memory = max_memory
|
73 |
-
execution_providers = execution_providers
|
74 |
-
execution_threads = execution_threads
|
75 |
-
headless = headless
|
76 |
-
log_level = log_level
|
|
|
1 |
+
# globals.py
|
2 |
|
3 |
+
# Module-level variables
|
4 |
+
source_path = None
|
5 |
+
target_path = None
|
6 |
+
output_path = None
|
7 |
+
frame_processors = []
|
8 |
+
keep_fps = True
|
9 |
+
keep_audio = True
|
10 |
+
video_encoder = 'libx264' # Example value
|
11 |
+
video_quality = 23 # Example value
|
12 |
+
log_level = 'error' # Example value
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
def set_global_paths(src: str, tgt: str, out: str) -> None:
|
15 |
+
"""
|
16 |
+
Set global paths for source, target, and output.
|
17 |
+
|
18 |
+
Args:
|
19 |
+
src (str): Source path.
|
20 |
+
tgt (str): Target path.
|
21 |
+
out (str): Output path.
|
22 |
+
"""
|
23 |
+
global source_path, target_path, output_path
|
24 |
+
source_path = src
|
25 |
+
target_path = tgt
|
26 |
+
output_path = out
|
27 |
|
28 |
+
def set_processing_options(encoder: str, quality: int, log: str) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
"""
|
30 |
+
Set options for video processing.
|
31 |
|
32 |
Args:
|
33 |
+
encoder (str): Video encoder.
|
34 |
+
quality (int): Video quality.
|
35 |
+
log (str): Log level.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
"""
|
37 |
+
global video_encoder, video_quality, log_level
|
38 |
+
video_encoder = encoder
|
39 |
+
video_quality = quality
|
40 |
+
log_level = log
|
41 |
+
|
42 |
+
def set_frame_processors(processors: list) -> None:
|
43 |
+
"""
|
44 |
+
Set the frame processors.
|
45 |
+
|
46 |
+
Args:
|
47 |
+
processors (list): List of frame processors.
|
48 |
+
"""
|
49 |
+
global frame_processors
|
50 |
+
frame_processors = processors
|
51 |
+
|
52 |
+
def set_keep_options(fps: bool, audio: bool) -> None:
|
53 |
+
"""
|
54 |
+
Set options to keep FPS and audio.
|
55 |
+
|
56 |
+
Args:
|
57 |
+
fps (bool): Whether to keep FPS.
|
58 |
+
audio (bool): Whether to keep audio.
|
59 |
+
"""
|
60 |
+
global keep_fps, keep_audio
|
61 |
+
keep_fps = fps
|
62 |
+
keep_audio = audio
|
63 |
+
|
64 |
+
# Example usage of global variables
|
65 |
+
def some_function():
|
66 |
global source_path, target_path, output_path, frame_processors, keep_fps, keep_audio
|
67 |
+
# Function implementation using global variables
|
68 |
+
print(f"Source Path: {source_path}")
|
69 |
+
print(f"Target Path: {target_path}")
|
70 |
+
print(f"Output Path: {output_path}")
|
71 |
+
print(f"Frame Processors: {frame_processors}")
|
72 |
+
print(f"Keep FPS: {keep_fps}")
|
73 |
+
print(f"Keep Audio: {keep_audio}")
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|