NeuroDonu commited on
Commit
a8dc809
·
verified ·
1 Parent(s): a23feab

Update updater.py

Browse files
Files changed (1) hide show
  1. updater.py +0 -91
updater.py CHANGED
@@ -3,8 +3,6 @@ import subprocess
3
  import locale
4
  import winreg
5
  import argparse
6
- import inspect
7
- import ast
8
 
9
  abs_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
10
  git = os.path.join(abs_path, "s", "git", "cmd", "git.exe")
@@ -23,93 +21,6 @@ args = parser.parse_args()
23
  def run_git_command(args):
24
  subprocess.run([git] + args, check=True)
25
 
26
- def uncensore(branch):
27
- file_path = os.path.join(master_path, branch, 'facefusion', 'content_analyser.py')
28
-
29
- if not os.path.exists(file_path):
30
- print(f"Файл {file_path} не найден.")
31
- return
32
-
33
- print(f"Радикально снимаем цензуру с {file_path}...")
34
-
35
- with open(file_path, 'r', encoding='utf-8') as file:
36
- source_code = file.read()
37
-
38
- tree = ast.parse(source_code)
39
-
40
- class ModifyFunctions(ast.NodeTransformer):
41
- def visit_FunctionDef(self, node):
42
- if node.name in ['analyse_frame', 'analyse_stream', 'analyse_video', 'analyse_image',
43
- 'detect_nsfw', 'detect_with_nsfw_1', 'detect_with_nsfw_2', 'detect_with_nsfw_3']:
44
- node.body = [ast.Return(value=ast.Constant(value=False))]
45
-
46
- elif node.name == 'pre_check':
47
- node.body = [ast.Return(value=ast.Constant(value=True))]
48
-
49
- elif node.name == 'get_inference_pool':
50
- node.body = [ast.Return(value=ast.Dict(keys=[], values=[]))]
51
-
52
- elif node.name == 'collect_model_downloads':
53
- node.body = [ast.Return(value=ast.Tuple(elts=[ast.Dict(keys=[], values=[]), ast.Dict(keys=[], values=[])], ctx=ast.Load()))]
54
-
55
- elif node.name == 'create_static_model_set':
56
- node.body = [ast.Return(value=ast.Dict(keys=[], values=[]))]
57
-
58
- elif node.name == 'resolve_execution_providers':
59
- node.body = [ast.Return(value=ast.List(elts=[], ctx=ast.Load()))]
60
-
61
- elif node.name == 'forward_nsfw':
62
- node.body = [ast.Return(value=ast.List(elts=[], ctx=ast.Load()))]
63
-
64
- elif node.name == 'prepare_detect_frame':
65
- node.body = [ast.Return(value=ast.Name(id='temp_vision_frame', ctx=ast.Load()))]
66
-
67
- elif node.name == 'clear_inference_pool':
68
- node.body = [ast.Pass()]
69
-
70
- else:
71
- if hasattr(node, 'returns') and node.returns:
72
- if isinstance(node.returns, ast.Name) and node.returns.id == 'bool':
73
- node.body = [ast.Return(value=ast.Constant(value=False))]
74
- elif isinstance(node.returns, ast.Constant) and node.returns.value == bool:
75
- node.body = [ast.Return(value=ast.Constant(value=False))]
76
- else:
77
- node.body = [ast.Return(value=ast.Constant(value=None))]
78
- else:
79
- node.body = [ast.Return(value=ast.Constant(value=None))]
80
-
81
- return node
82
-
83
- modified_tree = ModifyFunctions().visit(tree)
84
- modified_code = ast.unparse(modified_tree)
85
-
86
- with open(file_path, 'w', encoding='utf-8') as file:
87
- file.write(modified_code)
88
-
89
- print("Цензура радикально снята! Все модели отключены, никаких загрузок не будет!")
90
-
91
- def patch_core(branch):
92
- core_path = os.path.join(master_path, branch, 'facefusion', 'core.py')
93
-
94
- if not os.path.exists(core_path):
95
- print(f"Файл {core_path} не найден.")
96
- return
97
-
98
- print(f"Патчим проверку хеша в {core_path}...")
99
-
100
- with open(core_path, 'r', encoding='utf-8') as file:
101
- content = file.read()
102
-
103
- content = content.replace(
104
- "content_analyser_content = inspect.getsource(content_analyser).encode()\n\tis_valid = hash_helper.create_hash(content_analyser_content) == 'b159fd9d'",
105
- "content_analyser_content = inspect.getsource(content_analyser).encode()\n\tis_valid = True"
106
- )
107
-
108
- with open(core_path, 'w', encoding='utf-8') as file:
109
- file.write(content)
110
-
111
- print("Проверка хеша успешно обойдена!")
112
-
113
  def prepare_environment(branch):
114
  branch_path = os.path.join(master_path, branch)
115
  os.chdir(branch_path)
@@ -117,8 +28,6 @@ def prepare_environment(branch):
117
  run_git_command(['reset', '--hard'])
118
  run_git_command(['checkout', branch])
119
  run_git_command(['pull', 'origin', branch, '--rebase'])
120
- uncensore(branch)
121
- patch_core(branch)
122
 
123
  def ask_webcam_mode(language):
124
  """Спрашивает у пользователя режим вебкамеры и возвращает определенный результат"""
 
3
  import locale
4
  import winreg
5
  import argparse
 
 
6
 
7
  abs_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
8
  git = os.path.join(abs_path, "s", "git", "cmd", "git.exe")
 
21
  def run_git_command(args):
22
  subprocess.run([git] + args, check=True)
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  def prepare_environment(branch):
25
  branch_path = os.path.join(master_path, branch)
26
  os.chdir(branch_path)
 
28
  run_git_command(['reset', '--hard'])
29
  run_git_command(['checkout', branch])
30
  run_git_command(['pull', 'origin', branch, '--rebase'])
 
 
31
 
32
  def ask_webcam_mode(language):
33
  """Спрашивает у пользователя режим вебкамеры и возвращает определенный результат"""