diff --git a/Check_Up.py b/Check_Up.py index 2a2fc36c2..b2522dfd6 100644 --- a/Check_Up.py +++ b/Check_Up.py @@ -1,5 +1,7 @@ import os import DBHelper +from joblib import Parallel, delayed +import multiprocessing def update(): @@ -13,8 +15,8 @@ def update(): count += 1 if not os.path.isdir("Facial_images/face_rec/train/User_" + str(count)): os.makedirs("Facial_images/face_rec/train/User_" + str(count)) - for i in range(50): - DBHelper.download_user_photo("User_" + str(count) + "/" + str(i) + ".jpg") + Parallel(n_jobs=multiprocessing.cpu_count())( + delayed(download_parallel_user_photos)(i, count) for i in range(50)) print("Success.") except: print("No Users are registered.") @@ -25,8 +27,8 @@ def update(): count += 1 if not os.path.isdir("Photos_of_Thieves/Thief_" + str(count)): os.makedirs("Photos_of_Thieves/Thief_" + str(count)) - for i in range(50): - DBHelper.download_thief_photo("Thief_" + str(count) + "/" + str(i) + ".jpg") + Parallel(n_jobs=multiprocessing.cpu_count())( + delayed(download_parallel_thief_photos)(i, count) for i in range(50)) print("Success.") except: print("No Thieves are registered.") @@ -34,3 +36,11 @@ def update(): if __name__ == "__main__": update() + + +def download_parallel_user_photos(i, count): + DBHelper.download_user_photo("User_" + str(count) + "/" + str(i) + ".jpg") + + +def download_parallel_thief_photos(i, count): + DBHelper.download_thief_photo("Thief_" + str(count) + "/" + str(i) + ".jpg") diff --git a/Main.py b/Main.py index d15af145e..f956fa105 100644 --- a/Main.py +++ b/Main.py @@ -5,7 +5,7 @@ import Remove_Face import Check_Up if __name__ == "__main__": - print("Must do the check up First. (This may take long time.)") + print("Must do the check up First, this may take long...") Check_Up.update() print("Starting the program.") while True: diff --git a/__pycache__/Check_Up.cpython-36.pyc b/__pycache__/Check_Up.cpython-36.pyc index 1e0d4a5f6..14764f192 100644 Binary files a/__pycache__/Check_Up.cpython-36.pyc and b/__pycache__/Check_Up.cpython-36.pyc differ diff --git a/__pycache__/Facial_Recognition_Inference.cpython-36.pyc b/__pycache__/Facial_Recognition_Inference.cpython-36.pyc index 5afd27ce4..f65cbb488 100644 Binary files a/__pycache__/Facial_Recognition_Inference.cpython-36.pyc and b/__pycache__/Facial_Recognition_Inference.cpython-36.pyc differ diff --git a/__pycache__/Upload_Face.cpython-36.pyc b/__pycache__/Upload_Face.cpython-36.pyc index 065f8a812..a1538623d 100644 Binary files a/__pycache__/Upload_Face.cpython-36.pyc and b/__pycache__/Upload_Face.cpython-36.pyc differ diff --git a/__pycache__/Upload_Thief.cpython-36.pyc b/__pycache__/Upload_Thief.cpython-36.pyc index 94b0a4ef9..42239d728 100644 Binary files a/__pycache__/Upload_Thief.cpython-36.pyc and b/__pycache__/Upload_Thief.cpython-36.pyc differ