Giving a file path that works on any computer

43 Views Asked by At

I'm trying to give a path for one file that needs to be used in my face recognition program, but it is stored in another folder, like ...Projects/programs/MyProg/FaceRec, but the file that I want to use is part of dlib library and stored in ...Projects/myvenv/dlib/NeededFile.

I want to give one address without searching for this file so that it won't work slow. I'm sending projects folder because all neccessary files are there.

base_path = os.path.dirname(os.path.abspath(__file__))
# Load the detector and predictor from dlib
detector = dlib.get_frontal_face_detector()
predictor_path = os.path.join(base_path, 'myvenv', 'Lib', 'site-packages', 'face_recognition_models',          'models', 'shape_predictor_68_face_landmarks.dat')
predictor = dlib.shape_predictor(predictor_path)
face_rec_model_path = os.path.join(base_path, 'myvenv', 'Lib', 'site-packages', 'face_recognition_models', 'models', 'dlib_face_recognition_resnet_model_v1.dat')
face_rec_model = dlib.face_recognition_model_v1(face_rec_model_path)

But it is searching for file from my program, I'm not getting what the problem is.

0

There are 0 best solutions below