Using the trained model on a flask server?

I would like to use the generated model for my raspberry pi to process images coming as post requests to my flask server

Context/Use case:
I have already tested this model on my device and it working as desired it’s just that I want to extend this project a bit and add a flask server that receives images from POST request and then process them using the trained model

from cv2 import imread
from flask import Flask, request
from edge_impulse_linux.image import ImageImpulseRunner
import os
import cv2

model = "modelfile2.eim"

app = Flask(__name__)

@app.route('/get_features', methods=['POST'])
def get_features():
    if 'image' not in request.files:
        return 'No image provided', 400

    dir_path = os.path.dirname(os.path.realpath(__file__))
    modelfile = os.path.join(dir_path, model)

    with ImageImpulseRunner(modelfile) as runner:
            model_info = runner.init()
            print('Loaded runner for "' + model_info['project']['owner'] + ' / ' + model_info['project']['name'] + '"')
            labels = model_info['model_parameters']['labels']

            img = request.files['image'].read()
            img = imread(img)
            if img is None:
                raise Exception('Failed to load image')
            img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
            features, cropped = runner.get_features_from_image(img)

            return {'features': list(features)}
        except Exception as e:
            print('Failed to delete %s. Reason: %s' % ("Error :", e))
if __name__ == '__main__':

This is the code I am currently using but it throws an error saying
AttributeError: 'ImageImpulseRunner' object has no attribute 'get_features'
also :
Exec format error: '/file/test/modelfile2.eim'

Hello @browser,

How did you got the modelfile2.eim?
Using the edge-impulse-linux-runner --download modelfile2.eim, correct?

Is your path correct? Also, can you make sure you have execution rights on this file.

Let me know how it goes.

FYI, here is a workshop I ran in the past that is using a flask web app if you want to get inspired (not exactly the same logic as I don’t run the inference after receiving a post request but it can still give you hints I believe): GitHub - luisomoreau/workshop-intrusion-detection: Intrusion detection workshop using Edge Impulse for Linux Python SDK