Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,144 +2,123 @@ import gradio as gr
|
|
| 2 |
import cv2
|
| 3 |
import numpy as np
|
| 4 |
|
| 5 |
-
# ----------
|
| 6 |
|
| 7 |
def diamond_price(carat):
|
| 8 |
-
price = int(carat *
|
| 9 |
-
return f"
|
| 10 |
|
| 11 |
def face_detect(image):
|
|
|
|
|
|
|
|
|
|
| 12 |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 13 |
face_cascade = cv2.CascadeClassifier(
|
| 14 |
cv2.data.haarcascades + "haarcascade_frontalface_default.xml"
|
| 15 |
)
|
| 16 |
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
|
|
|
|
| 17 |
for (x, y, w, h) in faces:
|
| 18 |
-
cv2.rectangle(image, (x,y), (x+w,y+h), (
|
|
|
|
| 19 |
return image
|
| 20 |
|
| 21 |
-
# ---------- CREATIVE
|
| 22 |
|
| 23 |
css = """
|
| 24 |
body {
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
color: #0f172a;
|
| 29 |
-
font-family: 'Poppins', 'Segoe UI', sans-serif;
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
.hero {
|
| 33 |
-
background: linear-gradient(135deg, #6366f1, #ec4899);
|
| 34 |
-
color: white;
|
| 35 |
-
padding: 35px;
|
| 36 |
-
border-radius: 24px;
|
| 37 |
-
box-shadow: 0 20px 40px rgba(99,102,241,0.35);
|
| 38 |
-
margin-bottom: 30px;
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
.hero h1 {
|
| 42 |
-
font-size: 38px;
|
| 43 |
-
margin-bottom: 5px;
|
| 44 |
}
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
.card {
|
| 51 |
-
background: white;
|
| 52 |
-
border-radius: 20px;
|
| 53 |
-
padding: 22px;
|
| 54 |
-
box-shadow: 0 15px 35px rgba(15,23,42,0.12);
|
| 55 |
-
margin-bottom: 22px;
|
| 56 |
-
transition: all 0.3s ease;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
.card:hover {
|
| 60 |
-
transform: translateY(-6px);
|
| 61 |
-
box-shadow: 0 25px 50px rgba(99,102,241,0.25);
|
| 62 |
}
|
| 63 |
|
| 64 |
h2 {
|
| 65 |
-
|
| 66 |
}
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
}
|
| 71 |
|
| 72 |
.gr-button {
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
}
|
| 78 |
|
| 79 |
.gr-button:hover {
|
| 80 |
-
|
| 81 |
}
|
| 82 |
"""
|
| 83 |
|
| 84 |
-
# ---------- UI ---------- #
|
| 85 |
|
| 86 |
with gr.Blocks(css=css, title="Simranpreet Kaur | AI Portfolio") as demo:
|
| 87 |
|
| 88 |
gr.Markdown("""
|
| 89 |
-
<div class="
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
</div>
|
| 95 |
""")
|
| 96 |
|
| 97 |
gr.Markdown("""
|
| 98 |
<div class="card">
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
</div>
|
| 106 |
""")
|
| 107 |
|
| 108 |
with gr.Tabs():
|
| 109 |
|
| 110 |
with gr.Tab("π Diamond Price Prediction"):
|
| 111 |
-
gr.Markdown("<div class='card'><h3>Diamond Price Prediction</h3><
|
| 112 |
-
carat = gr.Slider(0.1, 5.0, step=0.1, label="
|
| 113 |
-
|
| 114 |
-
carat.change(diamond_price, carat,
|
| 115 |
|
| 116 |
with gr.Tab("π§ Face Detection"):
|
| 117 |
-
gr.Markdown("<div class='card'><h3>Face Detection</h3><
|
| 118 |
-
img = gr.Image(type="numpy")
|
| 119 |
-
|
| 120 |
-
img.change(face_detect, img,
|
| 121 |
|
| 122 |
with gr.Tab("π Text to Speech"):
|
| 123 |
-
gr.Markdown("<div class='card'><h3>Text to Speech</h3><
|
| 124 |
-
gr.Textbox(label="Enter text")
|
| 125 |
|
| 126 |
with gr.Tab("π Stock Market Analysis"):
|
| 127 |
gr.Markdown("""
|
| 128 |
<div class="card">
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
</div>
|
| 136 |
""")
|
| 137 |
|
| 138 |
gr.Markdown("""
|
| 139 |
<div class="card">
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
</div>
|
| 144 |
""")
|
| 145 |
|
|
|
|
| 2 |
import cv2
|
| 3 |
import numpy as np
|
| 4 |
|
| 5 |
+
# ---------------- FUNCTIONS ---------------- #
|
| 6 |
|
| 7 |
def diamond_price(carat):
|
| 8 |
+
price = int(carat * 85000)
|
| 9 |
+
return f"Estimated Diamond Price: βΉ{price:,}"
|
| 10 |
|
| 11 |
def face_detect(image):
|
| 12 |
+
if image is None:
|
| 13 |
+
return None
|
| 14 |
+
|
| 15 |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 16 |
face_cascade = cv2.CascadeClassifier(
|
| 17 |
cv2.data.haarcascades + "haarcascade_frontalface_default.xml"
|
| 18 |
)
|
| 19 |
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
|
| 20 |
+
|
| 21 |
for (x, y, w, h) in faces:
|
| 22 |
+
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 180, 255), 2)
|
| 23 |
+
|
| 24 |
return image
|
| 25 |
|
| 26 |
+
# ---------------- CREATIVE SAFE CSS ---------------- #
|
| 27 |
|
| 28 |
css = """
|
| 29 |
body {
|
| 30 |
+
background: linear-gradient(120deg, #fdf2f8, #eef2ff, #ecfeff);
|
| 31 |
+
font-family: 'Segoe UI', sans-serif;
|
| 32 |
+
color: #1e293b;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
}
|
| 34 |
|
| 35 |
+
h1 {
|
| 36 |
+
color: #4338ca;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
}
|
| 38 |
|
| 39 |
h2 {
|
| 40 |
+
color: #0f172a;
|
| 41 |
}
|
| 42 |
|
| 43 |
+
.card {
|
| 44 |
+
background: white;
|
| 45 |
+
border-radius: 16px;
|
| 46 |
+
padding: 20px;
|
| 47 |
+
box-shadow: 0 12px 30px rgba(0,0,0,0.08);
|
| 48 |
+
margin-bottom: 20px;
|
| 49 |
}
|
| 50 |
|
| 51 |
.gr-button {
|
| 52 |
+
background: linear-gradient(135deg, #6366f1, #ec4899);
|
| 53 |
+
color: white;
|
| 54 |
+
border-radius: 14px;
|
| 55 |
+
font-weight: 600;
|
| 56 |
}
|
| 57 |
|
| 58 |
.gr-button:hover {
|
| 59 |
+
box-shadow: 0 8px 20px rgba(236,72,153,0.35);
|
| 60 |
}
|
| 61 |
"""
|
| 62 |
|
| 63 |
+
# ---------------- UI ---------------- #
|
| 64 |
|
| 65 |
with gr.Blocks(css=css, title="Simranpreet Kaur | AI Portfolio") as demo:
|
| 66 |
|
| 67 |
gr.Markdown("""
|
| 68 |
+
<div class="card">
|
| 69 |
+
<h1>Simranpreet Kaur</h1>
|
| 70 |
+
<p><b>AI β’ Machine Learning β’ Computer Vision</b></p>
|
| 71 |
+
<p>π Fatehgarh Sahib, Punjab</p>
|
| 72 |
+
<p>π§ spreetkaur937@gmail.com</p>
|
| 73 |
</div>
|
| 74 |
""")
|
| 75 |
|
| 76 |
gr.Markdown("""
|
| 77 |
<div class="card">
|
| 78 |
+
<h2>About Me</h2>
|
| 79 |
+
<p>
|
| 80 |
+
B.Tech Computer Science (2022β2026) student passionate about building
|
| 81 |
+
intelligent and practical AI systems including prediction models and
|
| 82 |
+
real-time computer vision applications.
|
| 83 |
+
</p>
|
| 84 |
</div>
|
| 85 |
""")
|
| 86 |
|
| 87 |
with gr.Tabs():
|
| 88 |
|
| 89 |
with gr.Tab("π Diamond Price Prediction"):
|
| 90 |
+
gr.Markdown("<div class='card'><h3>Diamond Price Prediction</h3></div>")
|
| 91 |
+
carat = gr.Slider(0.1, 5.0, step=0.1, label="Carat")
|
| 92 |
+
output = gr.Textbox(label="Predicted Price")
|
| 93 |
+
carat.change(diamond_price, carat, output)
|
| 94 |
|
| 95 |
with gr.Tab("π§ Face Detection"):
|
| 96 |
+
gr.Markdown("<div class='card'><h3>Face Detection</h3></div>")
|
| 97 |
+
img = gr.Image(type="numpy", label="Upload Image")
|
| 98 |
+
out = gr.Image(label="Detected Faces")
|
| 99 |
+
img.change(face_detect, img, out)
|
| 100 |
|
| 101 |
with gr.Tab("π Text to Speech"):
|
| 102 |
+
gr.Markdown("<div class='card'><h3>Text to Speech</h3></div>")
|
| 103 |
+
gr.Textbox(label="Enter text (demo description only)")
|
| 104 |
|
| 105 |
with gr.Tab("π Stock Market Analysis"):
|
| 106 |
gr.Markdown("""
|
| 107 |
<div class="card">
|
| 108 |
+
<h3>Stock Market Analysis</h3>
|
| 109 |
+
<ul>
|
| 110 |
+
<li>Trend Analysis</li>
|
| 111 |
+
<li>Pattern Recognition</li>
|
| 112 |
+
<li>Data Visualization</li>
|
| 113 |
+
</ul>
|
| 114 |
</div>
|
| 115 |
""")
|
| 116 |
|
| 117 |
gr.Markdown("""
|
| 118 |
<div class="card">
|
| 119 |
+
<h3>Contact</h3>
|
| 120 |
+
<p>Email: <b>spreetkaur937@gmail.com</b></p>
|
| 121 |
+
<p>Hosted on Hugging Face Spaces</p>
|
| 122 |
</div>
|
| 123 |
""")
|
| 124 |
|