Exception: ImpulseRunner is not initialized

Hi. I am trying to perform inference on a sample data on my raspberry pi. When I call ImpulseRunner(model_path), I get this error:

Traceback (most recent call last):
File “/home/pi/Projects/test-static-dnn/pypy.py”, line 16, in
res = runner.classify(features)
File “/home/pi/.local/lib/python3.9/site-packages/edge_impulse_linux/runner.py”, line 60, in classify
return self.send_msg(msg)
File “/home/pi/.local/lib/python3.9/site-packages/edge_impulse_linux/runner.py”, line 66, in send_msg
raise Exception(‘ImpulseRunner is not initialized’)
Exception: ImpulseRunner is not initialized

Is there something I’m not doing to initialize ImpulseRunner?

Hello @professor,

Ho do you call your script? Are you using the default examples?
If not, can you share your code?

Regards,

Louis

I am not using the default examples quite exactly. Yes I called the script. This is all that’s in the script below. Returns an error on the runner = ImpulseRunner(model_path) line.

import os, time
from edge_impulse_linux.runner import ImpulseRunner

model_file = "modelfile.eim"
features = [0.0118, 0.0118, 0.0118, 0.0118, 0.0118, 0.0118, 0.0118, 0.0078, 0.0078, 0.0078, 0.0078, 0.0078, 0.0118, …]

dir_path = os.path.dirname(os.path.realpath(__file__))
model_path = os.path.join(dir_path, model_file)

runner = ImpulseRunner(model_path)
try:
        start_time = time.time_ns()
        res = runner.classify(features)
        elapsed_time = time.time_ns() - start_time
        print(res)
finally:
        if (runner):
                runner.stop()
        print()

Hello @professor,

Ok I don’t see anything weird now…
We agree that the modelfile.eim is present?

Can you print your model_path to make sure it is the proper one?

Regards,

Louis

Oh, can you initialize the runner with model_info = runner.init()?

try:
        model_info = runner.init()
        print('Loaded runner for "' + model_info['project']['owner'] + ' / ' + model_info['project']['name'] + '"')
        res = runner.classify(features)

finally:
        if (runner):
            runner.stop()

This worked! Thanks a million Louis!

1 Like