Spaces:
Sleeping
Sleeping
Rename requirements.txt to app.py
Browse files- app.py +74 -0
- requirements.txt +0 -0
app.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from fer import FER
|
| 3 |
+
import cv2
|
| 4 |
+
import numpy as np
|
| 5 |
+
import random
|
| 6 |
+
|
| 7 |
+
# Example ayahs
|
| 8 |
+
ayahs = {
|
| 9 |
+
"sad": [
|
| 10 |
+
{
|
| 11 |
+
"ayah": "2:286",
|
| 12 |
+
"arabic": "ููุง ููููููููู ุงูููููู ููููุณูุง ุฅููููุง ููุณูุนูููุง",
|
| 13 |
+
"translation": "Allah does not burden a soul beyond that it can bear.",
|
| 14 |
+
"tafsir": "Every test is within your capacity, with Allahโs help."
|
| 15 |
+
}
|
| 16 |
+
],
|
| 17 |
+
"happy": [
|
| 18 |
+
{
|
| 19 |
+
"ayah": "94:5-6",
|
| 20 |
+
"arabic": "ููุฅูููู ู
ูุนู ุงููุนูุณูุฑู ููุณูุฑูุง ุฅูููู ู
ูุนู ุงููุนูุณูุฑู ููุณูุฑูุง",
|
| 21 |
+
"translation": "Indeed, with hardship comes ease.",
|
| 22 |
+
"tafsir": "Your happiness is part of Allahโs ease."
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"angry": [
|
| 26 |
+
{
|
| 27 |
+
"ayah": "3:134",
|
| 28 |
+
"arabic": "ููุงููููุงุธูู
ูููู ุงููุบูููุธู",
|
| 29 |
+
"translation": "Those who restrain anger...",
|
| 30 |
+
"tafsir": "Patience and controlling anger are rewarded."
|
| 31 |
+
}
|
| 32 |
+
]
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
st.title("๐ Qurโan Healing Soul - FER Version")
|
| 36 |
+
|
| 37 |
+
uploaded_file = st.file_uploader("Upload your selfie", type=["jpg", "png", "jpeg"])
|
| 38 |
+
|
| 39 |
+
if uploaded_file is not None:
|
| 40 |
+
# Convert to OpenCV image
|
| 41 |
+
file_bytes = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8)
|
| 42 |
+
image = cv2.imdecode(file_bytes, 1)
|
| 43 |
+
st.image(image, channels="BGR")
|
| 44 |
+
|
| 45 |
+
# Detect emotion
|
| 46 |
+
detector = FER(mtcnn=True)
|
| 47 |
+
result = detector.top_emotion(image)
|
| 48 |
+
st.write(f"Detected: {result}")
|
| 49 |
+
|
| 50 |
+
if result is not None:
|
| 51 |
+
emotion, score = result
|
| 52 |
+
st.write(f"Dominant Emotion: **{emotion}** ({round(score*100, 2)}%)")
|
| 53 |
+
|
| 54 |
+
if emotion in ["sad", "fear"]:
|
| 55 |
+
key = "sad"
|
| 56 |
+
elif emotion in ["happy", "surprise"]:
|
| 57 |
+
key = "happy"
|
| 58 |
+
elif emotion in ["angry", "disgust"]:
|
| 59 |
+
key = "angry"
|
| 60 |
+
else:
|
| 61 |
+
key = "sad"
|
| 62 |
+
|
| 63 |
+
ayah = random.choice(ayahs[key])
|
| 64 |
+
st.markdown(f"""
|
| 65 |
+
**๐ Ayah ({ayah['ayah']})**
|
| 66 |
+
|
| 67 |
+
Arabic: *{ayah['arabic']}*
|
| 68 |
+
|
| 69 |
+
Translation: {ayah['translation']}
|
| 70 |
+
|
| 71 |
+
Tafsir: {ayah['tafsir']}
|
| 72 |
+
""")
|
| 73 |
+
else:
|
| 74 |
+
st.warning("No face detected.")
|
requirements.txt
DELETED
|
File without changes
|