simran40's picture
Update app.py
418428b verified
import gradio as gr
import cv2
import numpy as np
# ---------------- FUNCTIONS ---------------- #
def diamond_price(carat):
price = int(carat * 85000)
return f"Estimated Diamond Price: β‚Ή{price:,}"
def face_detect(image):
if image is None:
return None
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
face_cascade = cv2.CascadeClassifier(
cv2.data.haarcascades + "haarcascade_frontalface_default.xml"
)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
for (x, y, w, h) in faces:
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 180, 255), 2)
return image
# ---------------- CREATIVE SAFE CSS ---------------- #
css = """
body {
background: linear-gradient(120deg, #fdf2f8, #eef2ff, #ecfeff);
font-family: 'Segoe UI', sans-serif;
color: #1e293b;
}
h1 {
color: #4338ca;
}
h2 {
color: #0f172a;
}
.card {
background: white;
border-radius: 16px;
padding: 20px;
box-shadow: 0 12px 30px rgba(0,0,0,0.08);
margin-bottom: 20px;
}
.gr-button {
background: linear-gradient(135deg, #6366f1, #ec4899);
color: white;
border-radius: 14px;
font-weight: 600;
}
.gr-button:hover {
box-shadow: 0 8px 20px rgba(236,72,153,0.35);
}
"""
# ---------------- UI ---------------- #
with gr.Blocks(css=css, title="Simranpreet Kaur | AI Portfolio") as demo:
gr.Markdown("""
<div class="card">
<h1>Simranpreet Kaur</h1>
<p><b>AI β€’ Machine Learning β€’ Computer Vision</b></p>
<p>πŸ“ Fatehgarh Sahib, Punjab</p>
<p>πŸ“§ spreetkaur937@gmail.com</p>
</div>
""")
gr.Markdown("""
<div class="card">
<h2>About Me</h2>
<p>
B.Tech Computer Science (2022–2026) student passionate about building
intelligent and practical AI systems including prediction models and
real-time computer vision applications.
</p>
</div>
""")
with gr.Tabs():
with gr.Tab("πŸ’Ž Diamond Price Prediction"):
gr.Markdown("<div class='card'><h3>Diamond Price Prediction</h3></div>")
carat = gr.Slider(0.1, 5.0, step=0.1, label="Carat")
output = gr.Textbox(label="Predicted Price")
carat.change(diamond_price, carat, output)
with gr.Tab("πŸ§‘ Face Detection"):
gr.Markdown("<div class='card'><h3>Face Detection</h3></div>")
img = gr.Image(type="numpy", label="Upload Image")
out = gr.Image(label="Detected Faces")
img.change(face_detect, img, out)
with gr.Tab("πŸ”Š Text to Speech"):
gr.Markdown("<div class='card'><h3>Text to Speech</h3></div>")
gr.Textbox(label="Enter text (demo description only)")
with gr.Tab("πŸ“Š Stock Market Analysis"):
gr.Markdown("""
<div class="card">
<h3>Stock Market Analysis</h3>
<ul>
<li>Trend Analysis</li>
<li>Pattern Recognition</li>
<li>Data Visualization</li>
</ul>
</div>
""")
gr.Markdown("""
<div class="card">
<h3>Contact</h3>
<p>Email: <b>spreetkaur937@gmail.com</b></p>
<p>Hosted on Hugging Face Spaces</p>
</div>
""")
demo.launch()