Commit 809dfc99 authored by Manilka Shalinda's avatar Manilka Shalinda 💻

Merge branch 'it20617028/handwritingrecognizion' into 'master'

It20617028/handwritingrecognizion

See merge request 2023-24-027/implementation-of-an-intelligent-virtual-tutor-to-enhance-english-vocabulary-skills-of-grade-6-students!2
parents 8d7065ec b929d420
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyOcwN4hTrwFblLIGBmjUo1/"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","source":["from google.colab import drive\n","drive.mount('/content/drive')"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"cHhaLANYlk12","executionInfo":{"status":"ok","timestamp":1698233246284,"user_tz":-330,"elapsed":29915,"user":{"displayName":"Piumi Rathnayaka","userId":"02254013807970830484"}},"outputId":"4ae76d70-b1eb-4085-e538-744845f48ac7"},"execution_count":3,"outputs":[{"output_type":"stream","name":"stdout","text":["Mounted at /content/drive\n"]}]},{"cell_type":"code","execution_count":4,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"oJIjvLhOlA2J","executionInfo":{"status":"ok","timestamp":1698233362578,"user_tz":-330,"elapsed":116298,"user":{"displayName":"Piumi Rathnayaka","userId":"02254013807970830484"}},"outputId":"a99a8ad0-3f5c-43aa-874c-820ae1a12752"},"outputs":[{"output_type":"stream","name":"stdout","text":[" * Serving Flask app '__main__'\n"," * Debug mode: on\n"]},{"output_type":"stream","name":"stderr","text":["INFO:werkzeug:\u001b[31m\u001b[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.\u001b[0m\n"," * Running on http://127.0.0.1:5000\n","INFO:werkzeug:\u001b[33mPress CTRL+C to quit\u001b[0m\n","INFO:werkzeug: * Restarting with stat\n"]}],"source":["from flask import Flask, request, jsonify\n","import tensorflow as tf\n","import numpy as np\n","\n","app = Flask(__name__)\n","\n","# Load the Keras model from the .h5 file\n","model = tf.keras.models.load_model('/content/drive/MyDrive/Research_Test/Handwritten-Character-Recognition/best_model.h5')\n","\n","@app.route('/predict', methods=['POST'])\n","def predict():\n"," try:\n"," data = request.json # Assuming you are sending JSON data\n"," # Preprocess the input data if needed\n"," input_data = np.array(data['input_data']) # Adjust this based on your input format\n"," # Make predictions using the loaded Keras model\n"," predictions = model.predict(input_data)\n"," # You can post-process the predictions if needed\n"," response = {'predictions': predictions.tolist()}\n"," return jsonify(response)\n"," except Exception as e:\n"," return jsonify({'error': str(e)})\n","\n","if __name__ == '__main__':\n"," app.run(debug=True)\n","\n","# Make sure to replace 'your_model.h5' with the actual path to your .h5 model file. Also, adjust the code to preprocess and format the input data and post-process the predictions as needed for your specific use case.\n","\n","# Running the API: Save this code in a Python script, and run the script. Your Flask API should start and listen on the default address and port (http://127.0.0.1:5000/). You can access it by making POST requests to the /predict endpoint with the input data.\n","\n","# **Making Predict\n","\n","\n"]},{"cell_type":"code","source":[],"metadata":{"id":"iwvKO3cUlRGO"},"execution_count":null,"outputs":[]}]}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
1. tensorflow==2.8.0
2. numpy==1.21.4
3. pandas==1.4.2
4. opencv-python==4.5.5.64
5. matplotlib==3.5.1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment