Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify
|
| 2 |
+
import cv2
|
| 3 |
+
import numpy as np
|
| 4 |
+
from sign_language_model import predict_sign_language
|
| 5 |
+
|
| 6 |
+
app = Flask(__name__)
|
| 7 |
+
|
| 8 |
+
@app.route('/')
|
| 9 |
+
def home():
|
| 10 |
+
return "Welcome to the Learning App for Deaf and Mute"
|
| 11 |
+
|
| 12 |
+
@app.route('/convert', methods=['POST'])
|
| 13 |
+
def convert_sign_to_text():
|
| 14 |
+
"""
|
| 15 |
+
Accepts an image of a sign language gesture and converts it to text.
|
| 16 |
+
"""
|
| 17 |
+
try:
|
| 18 |
+
file = request.files['image']
|
| 19 |
+
image = cv2.imdecode(np.fromstring(file.read(), np.uint8), cv2.IMREAD_COLOR)
|
| 20 |
+
text = predict_sign_language(image)
|
| 21 |
+
return jsonify({"text": text, "status": "success"}), 200
|
| 22 |
+
except Exception as e:
|
| 23 |
+
return jsonify({"error": str(e), "status": "failure"}), 500
|
| 24 |
+
|
| 25 |
+
@app.route('/learn', methods=['GET'])
|
| 26 |
+
def learning_module():
|
| 27 |
+
"""
|
| 28 |
+
Provides learning content for deaf and mute individuals.
|
| 29 |
+
"""
|
| 30 |
+
# Example learning content (can be extended)
|
| 31 |
+
content = {
|
| 32 |
+
"title": "Learn Sign Language",
|
| 33 |
+
"lessons": [
|
| 34 |
+
{"id": 1, "title": "Alphabet A-Z"},
|
| 35 |
+
{"id": 2, "title": "Common Words and Phrases"},
|
| 36 |
+
{"id": 3, "title": "Numbers 1-10"}
|
| 37 |
+
]
|
| 38 |
+
}
|
| 39 |
+
return jsonify(content), 200
|
| 40 |
+
|
| 41 |
+
if __name__ == '__main__':
|
| 42 |
+
app.run(debug=True)
|