Classify_picamera.py example help

Hello,

I am trying to run the classify_picamera.py example shown here.

when I try to run

python3 classify_picamera.py \
  --model /tmp/mobilenet_v1_1.0_224_quant.tflite \
  --labels /tmp/labels_mobilenet_quant_v1_224.txt

I get

Traceback (most recent call last):
      File "classify_picamera.py", line 96, in <module> main()
      File "classify_picamera.py", line 68, in main labels = load_labels(args.labels)
      File "classify_picamera.py", line 33, in load_labels with open(path, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/labels_mobilenet_quant_v1_224.txt'

I am feeling like I missed a step in the installation or maybe the instructions are not complete?

Has anyone run across these kinds of error or has gotten these errors?

Any help would be appreciated!

Thank you,
Sean Worcester

@khanhlvg might be able to help here

Hello @lgusm!

Thank you!

I hope @khanhlvg can give a little guidance.

@Sean_Worcester have you run the download.sh file as described in the documentation? This script should have downloaded the labels_mobilenet_quant_v1_224.txt and mobilenet_v1_1.0_224_quant.tflite files into the tmp directory.

I hope this helps. Kind regards,
Gilbert Tanner

1 Like

Hello Gi_T,

I followed the steps outlined in the both the Python Quickstart and in the Classify_picamera tutorials.

I noticed the download.sh, but I don’t think it is clearly called out in the Classify_picamera tutorial.

I ran

git clone https://github.com/tensorflow/examples --depth 1       (1)

and

cd examples/lite/examples/object_detection/raspberry_pi        (2)

As instructed and I saw

# The script takes an argument specifying where you want to save the model files
bash download.sh /tmp

I thought it was referring to (1), and talking about what that step was doing.

I do see on my Raspberry Pi where all the files have been copied to.

Did I not run the download.sh script?

Thank you,
Sean Worcester

OH…I think I see where I missed the command.

bash download.sh

It is so funny that NOW after I have copied it to this forum that it stands out.

HA HA HA

1 Like

Hello @Gi_T

Thank you for your help!

That did the trick.

Thanks,
Sean Worcester

@Sean_Worcester glad to hear that it worked.

1 Like

When you open a file with the name “filename.ext”; you are telling the open() function that your file is in the current working directory . This is called a relative path.

file = open('filename.ext') //relative path

In the above code, you are not giving the full path to a file to the open() function, just its name - a relative path. The error “FileNotFoundError: [Errno 2] No such file or directory” is telling you that there is no file of that name in the working directory. So, try using the exact, or absolute path.

file = open(r'C:\path\to\your\filename.ext') //absolute path

In the above code, all of the information needed to locate the file is contained in the path string - absolute path.