1

I check 20 other posts of people that keep getting this error, and none of em helped me solve my problem.

I am trying to load a file into a TorchNeuralNet, to use for face verification.

parser = argparse.ArgumentParser()

parser.add_argument('--images', type=str, nargs='+', help="Input Images.")
parser.add_argument('--dlibFacePredictor', type=str, help="Path to dlib's face predictor.",
                    default=os.path.join(dlibModelDir,"landmarks.dat"))
parser.add_argument('--networkModel', type=str, help="Path to Torch network model.",
                    default=os.path.join(openfaceModelDir, "nn4.small2.v1.t7"))
parser.add_argument('--imgDim', type=str, help="Default image dimension.", default=96)
parser.add_argument('--verbose', action=('store_true'))

args = parser.parse_args()

The error happens on this line.

net = openface.TorchNeuralNet(args.networkModel, args.imgDim)

At first I thought the issue was the path to the file but it isnt I check in the varible explorer and the parser saves it ok.

The error full error is:

Exception ignored in: <function TorchNeuralNet.__del__ at 0x00000235C5A80D30>
Traceback (most recent call last):
  File "C:\Users\user\anaconda3\envs\virenv\lib\site-packages\openface\torch_neural_net.py", line 109, in __del__
if self.p.poll() is None:
 AttributeError: 'TorchNeuralNet' object has no attribute 'p'
Traceback (most recent call last):

   File "C:\Users\user\Desktop\Diplomski\main2.py", line 39, in <module>
     net = openface.TorchNeuralNet(args.networkModel, args.imgDim)

   File "C:\Users\user\anaconda3\envs\virenv\lib\site- 
   packages\openface\torch_neural_net.py", line 
     84, in __init__
     self.p = Popen(self.cmd, stdin=PIPE, stdout=PIPE, bufsize=0, 
universal_newlines=True)

   File "C:\Users\user\anaconda3\envs\virenv\lib\site- 
        packages\spyder_kernels\customize\spydercustomize.py", line 108, in 
__init__
     super(SubprocessPopen, self).__init__(*args, **kwargs)

   File "C:\Users\user\anaconda3\envs\virenv\lib\subprocess.py", line 951, in __init__
     self._execute_child(args, executable, preexec_fn, close_fds,

   File "C:\Users\user\anaconda3\envs\virenv\lib\subprocess.py", line 1420, in _execute_child
     hp, ht, pid, tid = _winapi.CreateProcess(executable, args,

 FileNotFoundError: [WinError 2] The system cannot find the file specified

Here is the documentation for openface: https://openface-api.readthedocs.io/en/latest/openface.html

jkr
  • 17,119
  • 2
  • 42
  • 68
Josip Juros
  • 349
  • 2
  • 12
  • Considering that the default is 96, shouldn't `imgDim` be type `int`, and not `str` – PaulMcG Apr 19 '21 at 07:09
  • This does not seem related to ``argparse`` at all – you should be able to extract the paths/namespace of ``argparse`` and reproduce the issue statically. So, please [edit] your question to provide a proper [mcve]. Note that the error message indicates the path *of an executable* was not found or is not executable, not that some save file is missing. – MisterMiyagi Apr 19 '21 at 07:32
  • As the docs on ``openface.TorchNeuralNet`` say "Use a Torch subprocess for feature extraction.", this likely means that either Torch is not installed properly or openface is not configured properly to find it. – MisterMiyagi Apr 19 '21 at 08:30
  • The [source code](https://github.com/cmusatyalab/openface/blob/master/openface/openface_server.lua) and [related questions](https://stackoverflow.com/questions/50218869/whats-the-difference-between-using-th-and-lua-commands-to-run-a-lua-script) suggest that torch is run via a lua script, and the ``th`` lua interpreter/wrapper. You would have to check whether this is available. – MisterMiyagi Apr 19 '21 at 08:33
  • Do a `print(args)` to see what the parser produced. If the values look right, then this isn't an `argparse` issue. Try to understand where in your code the error occurs. This will be more productive than searching the world for someone with exactly your error. – hpaulj Apr 19 '21 at 16:02

1 Answers1

0

It was the parser also OpenFace doesnt work well with Windows. Tried some Docker stuff but didnt work. Transitioned to dlib and opencv and im making progress.

Josip Juros
  • 349
  • 2
  • 12