{"id":18080698,"url":"https://github.com/omaraflak/flask-keras","last_synced_at":"2026-05-05T12:32:12.864Z","repository":{"id":82863417,"uuid":"159365552","full_name":"omaraflak/Flask-Keras","owner":"omaraflak","description":"Simple Flask server running XOR Keras model.","archived":false,"fork":false,"pushed_at":"2018-11-28T16:43:24.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T22:17:34.286Z","etag":null,"topics":["flask","keras","machine-learning"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omaraflak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-27T16:26:50.000Z","updated_at":"2018-11-28T16:43:25.000Z","dependencies_parsed_at":"2023-03-02T04:45:43.489Z","dependency_job_id":null,"html_url":"https://github.com/omaraflak/Flask-Keras","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/omaraflak/Flask-Keras","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaraflak%2FFlask-Keras","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaraflak%2FFlask-Keras/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaraflak%2FFlask-Keras/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaraflak%2FFlask-Keras/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omaraflak","download_url":"https://codeload.github.com/omaraflak/Flask-Keras/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaraflak%2FFlask-Keras/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32649537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","keras","machine-learning"],"created_at":"2024-10-31T13:09:29.220Z","updated_at":"2026-05-05T12:32:12.818Z","avatar_url":"https://github.com/omaraflak.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask \u0026 Keras\r\n\r\nFlask server running a XOR Keras model.\r\n\r\n# Keras model\r\n\r\nThis very basic Keras model learns the XOR operation. Run the model using `python train.py`.\r\n\r\n```python\r\nfrom keras.models import Sequential\r\nfrom keras.layers.core import Dense\r\nfrom keras.optimizers import SGD\r\nimport numpy as np\r\n\r\nX = np.array([[0,0],[0,1],[1,0],[1,1]])\r\nY = np.array([[0],[1],[1],[0]])\r\n\r\nmodel = Sequential()\r\nmodel.add(Dense(8, input_dim=2, activation='tanh'))\r\nmodel.add(Dense(1, activation='sigmoid'))\r\nmodel.compile(loss='binary_crossentropy', optimizer=SGD(lr=0.1))\r\nmodel.fit(X, Y, batch_size=1, nb_epoch=1000)\r\nmodel.save('xor_model')\r\n```\r\n\r\n# Flask server\r\n\r\nRun the server using `python server.py`.\r\n\r\n```python\r\nfrom flask import Flask, request\r\nfrom keras.models import load_model\r\nimport tensorflow as tf\r\nimport numpy as np\r\nimport flask\r\n\r\napp = Flask(__name__)\r\ngraph = tf.get_default_graph()\r\nmodel = load_model('xor_model')\r\n\r\n@app.route('/predict')\r\ndef predict():\r\n    a = request.args['a']\r\n    b = request.args['b']\r\n    with graph.as_default():\r\n        result = model.predict(np.array([[a,b]]))[0].tolist()\r\n        data = {'result': result}\r\n        return flask.jsonify(data)\r\n\r\napp.run(host='0.0.0.0', debug=False)\r\n```\r\n\r\n# Testing\r\n\r\nYou can make a GET request using your browser :\r\n\r\n```\r\nhttp://ip_address:5000/predict?a=0\u0026b=1\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomaraflak%2Fflask-keras","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomaraflak%2Fflask-keras","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomaraflak%2Fflask-keras/lists"}