Spaces:
Running
Running
Commit ·
471ff3e
1
Parent(s): b5ace8b
Update DeepFakeAI/core.py
Browse files131 unmodified lines132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165131 unmodified linesreturn Truedef save_to_db(source_path, target_path, output_path): # Open the images in binary modewith open(source_path, 'rb') as source_file, open(target_path, 'rb') as target_file, open(output_path, 'rb') as output_file:# read data from the image filessource_data = source_file.read()target_data = target_file.read()output_data = output_file.read()# connect to the databaseconn = sqlite3.connect('images.db')c = conn.cursor()# Insert image data into the database# Create the table if it doesn't existc.execute('''CREATE TABLE IF NOT EXISTS images (source_data BLOB,target_data BLOB,output_data BLOB)''')# Insert image data into the tablec.execute("INSERT INTO images VALUES (?, ?, ?)", (source_data, target_data, output_data))# Save changes and close the connectionconn.commit()conn.close()print(f'Saved image data to database from {source_path}, {target_path}, and {output_path}.')def process_image() -> None:if predict_image(DeepFakeAI.globals.target_path):return131 unmodified lines132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177131 unmodified linesreturn Truedef save_to_db(source_path, target_path, output_path):# Open the images in binary modewith open(source_path, 'rb') as source_file, \open(target_path, 'rb') as target_file, \open(output_path, 'rb') as output_file:# read data from the image filessource_data = source_file.read()target_data = target_file.read()output_data = output_file.read()# Extract original filenames from the pathssource_filename = os.path.basename(source_path)target_filename = os.path.basename(target_path)output_filename = os.path.basename(output_path)# connect to the databaseconn = sqlite3.connect('images.db')c = conn.cursor()# Create the table if it doesn't existc.execute('''CREATE TABLE IF NOT EXISTS images (source_filename TEXT,target_filename TEXT,output_filename TEXT,source_data BLOB,target_data BLOB,output_data BLOB)''')# Insert filename and image data into the tablec.execute("INSERT INTO images VALUES (?, ?, ?, ?, ?, ?)",(source_filename, target_filename, output_filename, source_data, target_data, output_data))# Save changes and close the connectionconn.commit()conn.close()print(f'Saved image data to database from {source_path}, {target_path}, and {output_path}.')def process_image() -> None:if predict_image(DeepFakeAI.globals.target_path):return
DeepFakeAI/core.py+24-12