Muhammad2026 commited on
Commit
27b9658
·
1 Parent(s): 0a3a5cf

Optimize: Fast transport and build-time warming

Browse files
download_weights.py CHANGED
@@ -35,6 +35,17 @@ def main():
35
  print("Starting KlingTeam weights download...")
36
  for path, url in models.items():
37
  download_file(url, path)
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  if __name__ == "__main__":
40
  main()
 
35
  print("Starting KlingTeam weights download...")
36
  for path, url in models.items():
37
  download_file(url, path)
38
+
39
+ # Pre-warm insightface (buffalo_l) to avoid runtime download
40
+ print("Pre-warming insightface models...")
41
+ try:
42
+ from insightface.app import FaceAnalysis
43
+ # This will trigger the download of buffalo_l if not present
44
+ app = FaceAnalysis(name='buffalo_l', root='pretrained_weights', providers=['CPUExecutionProvider'])
45
+ app.prepare(ctx_id=0, det_size=(640, 640))
46
+ print("Insightface pre-warmed successfully.")
47
+ except Exception as e:
48
+ print(f"Insightface warmup failed (optional): {e}")
49
 
50
  if __name__ == "__main__":
51
  main()
live_portrait_bridge_template.py CHANGED
@@ -170,7 +170,7 @@ def generate_frames(current_char_data):
170
  current_char_data['mask_ori_float']
171
  )
172
 
173
- _, buffer_rest = cv2.imencode('.jpg', I_rest_pstbk[..., ::-1], [cv2.IMWRITE_JPEG_QUALITY, 95])
174
 
175
 
176
  # 2. Generate BLINK Frame
@@ -212,7 +212,7 @@ def generate_frames(current_char_data):
212
  current_char_data['mask_ori_float']
213
  )
214
 
215
- _, buffer_blink = cv2.imencode('.jpg', I_blink_pstbk[..., ::-1], [cv2.IMWRITE_JPEG_QUALITY, 95])
216
 
217
  return buffer_rest, buffer_blink
218
 
 
170
  current_char_data['mask_ori_float']
171
  )
172
 
173
+ _, buffer_rest = cv2.imencode('.jpg', I_rest_pstbk[..., ::-1], [cv2.IMWRITE_JPEG_QUALITY, 80])
174
 
175
 
176
  # 2. Generate BLINK Frame
 
212
  current_char_data['mask_ori_float']
213
  )
214
 
215
+ _, buffer_blink = cv2.imencode('.jpg', I_blink_pstbk[..., ::-1], [cv2.IMWRITE_JPEG_QUALITY, 80])
216
 
217
  return buffer_rest, buffer_blink
218