Skip to main content
MSant.11
Associate III
September 12, 2021
Solved

Warning error in ASC training script. AI Resources from FP-AI-SENSING1

  • September 12, 2021
  • 16 replies
  • 3172 views

I'm running your acoustic_scene_classification.ipynb, available in FP-AI-SENSING1, the Middleware ASC (acoustic scene classification):

https://www.st.com/en/embedded-software/fp-ai-sensing1.html

When I try to import and convert data, I get the following error warning:

---------------------------------------------------------------------------

OSError Traceback (most recent call last)

<ipython-input-9-87cd88dbb12e> in <module>

1 dataset_dir = './Dataset'

2 meta_path = path = os.path.join(dataset_dir, 'TrainSet.txt')

----> 3 fileset = np.loadtxt(meta_path, dtype=str)

4

5 # 3 classes : 0 indoor, 1 outdoor, 2 in-vehicle

C:\ST\Anaconda3\lib\site-packages\numpy\lib\npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows, like)

1063 raise ValueError("Wrong number of columns at line %d"

1064 % line_num)

-> 1065

1066 # Convert each value according to its column and store

1067 items = [conv(val) for (conv, val) in zip(converters, vals)]

C:\ST\Anaconda3\lib\site-packages\numpy\lib\_datasource.py in open(path, mode, destpath, encoding, newline)

192 """

193

--> 194 ds = DataSource(destpath)

195 return ds.open(path, mode, encoding=encoding, newline=newline)

196

C:\ST\Anaconda3\lib\site-packages\numpy\lib\_datasource.py in open(self, path, mode, encoding, newline)

529 _fname, ext = self._splitzipext(found)

530 if ext == 'bz2':

--> 531 mode.replace("+", "")

532 return _file_openers[ext](found, mode=mode,

533 encoding=encoding, newline=newline)

OSError: ./Dataset\TrainSet.txt not found.

....................................................................................................................

TrainSet.tx is inside the Dataset folder, as you settled.

Did you fix this issue ?

Thanks

    This topic has been closed for replies.
    Best answer by Laurent

    then maybe the versions are not compatible with one another, you should install older versions it should work . this pack was developed ages ago ...

    16 replies

    Laurent
    ST Employee
    September 13, 2021

    Hello

    I just run the jupyter notebook ( from version 4.0.3) on windows10 without an issue on my side .

    Could you check you are using TrainSet.txt and not TrainSet.tx like you wrote ?

    try to clear output & restart

    best regards

    L.

    Laurent
    ST Employee
    September 13, 2021

    you may also want to check the "/" vs "\" in your environment

    MSant.11
    MSant.11Author
    Associate III
    September 13, 2021

    Yes, it works. I was using a wrong path in my environment. Thank you!

    I anyway changed "keras.utils.to_categorical" to "tf.keras.utils.to_categorical" when preparing output data, because I got an error warning.

    Compiling the model I get:

    sgd = optimizers.SGD(lr=0.01, momentum=0.9, nesterov=True)

    model.compile(optimizer=sgd, loss='categorical_crossentropy', metrics=['acc'])

    ---------------------------------------------------------------------------

    AttributeError Traceback (most recent call last)

    <ipython-input-14-c51f12e1fab9> in <module>

    ----> 1 sgd = optimizers.SGD(lr=0.01, momentum=0.9, nesterov=True)

    2 model.compile(optimizer=sgd, loss='categorical_crossentropy', metrics=['acc'])

    AttributeError: module 'keras.optimizers' has no attribute 'SGD'

    Thanks

    M

    Laurent
    ST Employee
    September 14, 2021

    Can you check the keras & tf version ?

    In my environment I get ( you can see it from cell 3 of the jupyter notebook) :

    try to align the versions and check

    best regards

    L.

    Laurent
    ST Employee
    September 14, 2021

    0693W00000Dn4gBQAR.png

    MSant.11
    MSant.11Author
    Associate III
    September 14, 2021

    Keras: 2.6.0

    TensorFlow: 2.6.0

    librosa: 2.6.0

    Laurent
    LaurentBest answer
    ST Employee
    September 14, 2021

    then maybe the versions are not compatible with one another, you should install older versions it should work . this pack was developed ages ago ...

    MSant.11
    MSant.11Author
    Associate III
    September 14, 2021

    sgd = tf.keras.optimizers.SGD(lr=0.01, momentum=0.9, nesterov=True)

    works well in this way .............. no warning

    MSant.11
    MSant.11Author
    Associate III
    September 14, 2021

    I updated this instruction too:

    converter = tf.compat.v1.lite.TFLiteConverter.from_keras_model_file(out_dir + "model.h5" )

    for generating the TFLite model.

    Thank you !

    M

    MSant.11
    MSant.11Author
    Associate III
    September 23, 2021

    Could you please comment the statement in the ASC pack: " Slice Data into frames

    Each frame will contain 16,896 samples (32 * 512 + 512) to create a 32 column spectrogram with n_fft=1024 and hop_length=512"

    You are using 30-second audio data, sampled at 16 kHz in your file. Why did you choose this particular shape for each frame ?

    Thanks,

    M