Spaces:
Build error
Build error
Download deploy/app.py from AsusHP/Digit_Recognizer: direct link, hf CLI and curl.
- Browser
- Download file 966 Bytes
-
https://huggingface.co/spaces/AsusHP/Digit_Recognizer/resolve/main/deploy/app.py
- Command line
-
hf download hf://spaces/AsusHP/Digit_Recognizer/deploy/app.py
-
curl -L -o app.py https://huggingface.co/spaces/AsusHP/Digit_Recognizer/resolve/main/deploy/app.py
966 Bytes
| #Import Library | |
| from flask import Flask, request, jsonify, render_template, send_from_directory | |
| import os | |
| from keras.models import load_model | |
| #Import functions and model | |
| from functions import predict | |
| model = load_model('model_mnist.h5') | |
| app = Flask('my app', template_folder='templates') | |
| def index(): | |
| return render_template('webpage.html') | |
| def serve_static(filename): | |
| return send_from_directory(os.path.join(app.root_path, 'static'), filename) | |
| def process_drawing(): | |
| data = request.json | |
| image_data = data.get("imageData") | |
| if image_data: | |
| value_1, value_2 = predict(image_data, model) | |
| response = { | |
| "value_1": value_1, | |
| "value_2": value_2 | |
| } | |
| return jsonify(response) | |
| return jsonify({"response": "Erro: Image data not received."}) | |
| if __name__ == '__main__': | |
| app.run() | |