The local python notebook is giving errors

Question/Issue:
It says that data directory and output direcotry are needed:
train.py [-h] [–info-file INFO_FILE] --data-directory DATA_DIRECTORY --out-directory OUT_DIRECTORY [–epochs EPOCHS] [–learning-rate LEARNING_RATE]
train.py: error: the following arguments are required: --data-directory, --out-directory

Do I need to specify where they are? And if so, how is it made?

The code giving error is the next one:
dir_path = os.path.dirname(os.path.realpath(file))
parser = argparse.ArgumentParser(description=‘Edge Impulse training scripts’)
parser.add_argument(’–info-file’, type=str, required=False,
help=‘train_input.json file with info about classes and input shape’,
default=os.path.join(dir_path, ‘train_input.json’))
parser.add_argument(’–data-directory’, type=str, required=True,
help=‘Where to read the data from’)
parser.add_argument(’–out-directory’, type=str, required=True,
help=‘Where to write the data’)

parser.add_argument(’–epochs’, type=int, required=False,
help=‘Number of training cycles’)
parser.add_argument(’–learning-rate’, type=float, required=False,
help=‘Learning rate’)

args, unknown = parser.parse_known_args()

Project ID:

Context/Use case:

Hi @JosuGaztelu,

Yes you need to give the input data directory (your training dataset) and the output directory (where the trained model will be saved).

Aurelien

I have been trying for a while and didn’t find a way to resolve the problem, also my knowledge on python is not that much and all the documents I find are not giving results, is there any examples of working project I could use as a reference?

@JosuGaztelu,

Just follow the instructions in the readme, it should be quite straightforward using Docker, ie:

docker build -t custom-block-14299 .
docker run --rm -v $PWD:/scripts custom-block-14299 --data-directory data --out-directory out

Aurelien

@aurel ,
When doing the
docker run --rm -v "%cd%":/scripts custom-block-138189 --data-directory data --out-directory out
it does nothing and prints this message:
docker: invalid reference format. See 'docker run --help'.

How can I solve that because I have not found any solution.
Do I need to add something in any document such as requirements.txt or something like that?

I also tryied using docker run --rm -v cd:/scripts custom-block-138189 --data-directory data --out-directory out and as a result this was printed in the terminal:
Unable to find image 'custom-block-138189:latest' locally docker: Error response from daemon: pull access denied for custom-block-138189, repository does not exist or may require 'docker login': denied: requested access to the resource is denied. See 'docker run --help'.
But the image is already created so I don’t know what else to do.

Thanks

Hi @JosuGaztelu,

So the docker build ran succefully right?
I’m not sure about the syntax for Windows but instead of $PWD you can just put the absolute path where you run the command (ie: C:\Users\Josu\Desktop).
If it still complains about not finding the image, most likely the build failed.

Aurelien

I fixed the run issue, i runned the container usin the image ID instead of the name, but still have an error when importing ei_tensorflow from resources, I’ve been looking for references for sys.path.append and added this: sys.path.append("C:\\Users\\jgaztelu\\Documents\\VSCODE_PYTHON\\ei_sound32_64conv2d_nn_classifier\\resources\\libraries\\ei_tensorflow")
but still have an error: Traceback (most recent call last): File "train.py", line 61, in <module> import ei_tensorflow.training ModuleNotFoundError: No module named 'ei_tensorflow'

Just got it working if someone has the same issues here is my solution:
So the issues were docker couldn’t find the image by name so instead of runnin docker run --rm -v custom-block138189 I used the command docker run --rm -v 04896…(the id of the image).
so the command will look like this:docker run --rm -v C:/Users/jgaztelu/Documents/VSCODE_PYTHON/ei_sound32_64conv2d_nn_classifier:/scripts f8cb5052788f --data-directory data --out-directory out
And for the second error I just pasted the ei_tensorflow forlder in the main path of the project