Made Checkup.py faster.

This commit is contained in:
Batuhan Berk Başoğlu 2021-02-09 22:07:56 -05:00
parent 062a66cd95
commit c654b33941
6 changed files with 15 additions and 5 deletions

View file

@ -1,5 +1,7 @@
import os import os
import DBHelper import DBHelper
from joblib import Parallel, delayed
import multiprocessing
def update(): def update():
@ -13,8 +15,8 @@ def update():
count += 1 count += 1
if not os.path.isdir("Facial_images/face_rec/train/User_" + str(count)): if not os.path.isdir("Facial_images/face_rec/train/User_" + str(count)):
os.makedirs("Facial_images/face_rec/train/User_" + str(count)) os.makedirs("Facial_images/face_rec/train/User_" + str(count))
for i in range(50): Parallel(n_jobs=multiprocessing.cpu_count())(
DBHelper.download_user_photo("User_" + str(count) + "/" + str(i) + ".jpg") delayed(download_parallel_user_photos)(i, count) for i in range(50))
print("Success.") print("Success.")
except: except:
print("No Users are registered.") print("No Users are registered.")
@ -25,8 +27,8 @@ def update():
count += 1 count += 1
if not os.path.isdir("Photos_of_Thieves/Thief_" + str(count)): if not os.path.isdir("Photos_of_Thieves/Thief_" + str(count)):
os.makedirs("Photos_of_Thieves/Thief_" + str(count)) os.makedirs("Photos_of_Thieves/Thief_" + str(count))
for i in range(50): Parallel(n_jobs=multiprocessing.cpu_count())(
DBHelper.download_thief_photo("Thief_" + str(count) + "/" + str(i) + ".jpg") delayed(download_parallel_thief_photos)(i, count) for i in range(50))
print("Success.") print("Success.")
except: except:
print("No Thieves are registered.") print("No Thieves are registered.")
@ -34,3 +36,11 @@ def update():
if __name__ == "__main__": if __name__ == "__main__":
update() 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")

View file

@ -5,7 +5,7 @@ import Remove_Face
import Check_Up import Check_Up
if __name__ == "__main__": 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() Check_Up.update()
print("Starting the program.") print("Starting the program.")
while True: while True:

Binary file not shown.