How to send AWS IoT core data to ML model which is already deployed on AWS EC2 instance by using Flask API??
I have to deploy my ML model on AWS ec2-instance by using Flask API and make public URL like as :' http://ec2-16-171-143-........compute.amazonaws.com:8080'.
I also connect my hardware IoT device with AWS IoT core, and properly getting data on IOT core. Then, I have to make a AWS Lambda function and triggering Lambda function by IOT core. Hence I tried to send data to Flask api(web address), but failed.
I have to used 'app.py' code and 'index.html' for deploying ML model to AWS ec2 instance using Flask API.
The Lambda Function is triggering properly by AWS iot Core ,but couldn't send data to Flask API URL!!!! No error finding after running code ,but not showing any data on web address.
I want to send data to Flask api web address, apply ML model on the data and get predicted result, finally show the predicted result on the web to user.
No ,it is not recorded. Please correct my Flask API code which is deployed on AWS ec2 instance for receiving data from AWS lambda function and show the incoming data and predicted result on the web. Here is my code:
import logging import pickle app = Flask(name) model = pickle.load(open('model.pkl', 'rb')) @app.route('/') def home(): return render_template('index.html') @app.route('/api', methods=['POST']) def api(): data = request.get_json() cg = data['CGPA'] iq = data['IQ'] ps = data['Profile Score'] session['cg'] = cg session['iq'] = iq session['ps'] = ps return redirect(url_for('result')) @app.route('/result') def result(): try: cg = session.get('cg') iq = session.get('iq') ps = session.get('ps') cg = float(cg) iq = float(iq) ps = float(ps) prediction = model.predict([[cg, iq, ps]]) predicted_result = prediction[0].item()
result_data = { 'CGPA': cg, 'IQ': iq, 'Profile Score': ps, 'Predicted Result': predicted_result } return render_template('result.html',result=result_data)
if name == 'main': app.run(host='0.0.0.0', port=8084)