Here is what I'm trying to do: I'm sending an Ajax request with an image as data to a php script that uploads it and execute a python script with the image name the python script loads a gender detection model and predict the gender on the person on the image.
The problem is the model doesn't load, I tried it with the php and python script in the same directory and it worked fine but I'm trying to use it in laravel so I can't do that anymore.
when I try running the python script manually like that :
python path/to/script.py
It throws this error : OpenCV(3.4.1) Error: Unspecified error (File can't be opened for reading!)
but when I do this it works:-
cd path/to/script.py ; python script.py
Here is my php:-
$file = $this->upload_Image($request->get('image'));
$path =public_path().'/app/Http/Controllers';
$command='cd '.$path.';';
$path= 'python '.$path.'/facifier.py '.storage_path('app').$file;
$command .= $path;
return exec($command);
Storage::disk('local')->delete($file);
return json_encode($orderedData);
The command ends up like this : cd absolute/path/to/script.py ; python script.py absolute/path/to/image.jpg
when I use it on a command prompt it works fine.
Here is where I get the error on my python script:-
fisher_face_gender = cv2.face.FisherFaceRecognizer_create()
fisher_face_gender.read('models/gender_classifier_model_kdef.xml')
does anyone know whats causing this, I'm on windows by the way.