simran40 commited on
Commit
418428b
Β·
verified Β·
1 Parent(s): 0184259

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -79
app.py CHANGED
@@ -2,144 +2,123 @@ import gradio as gr
2
  import cv2
3
  import numpy as np
4
 
5
- # ---------- LOGIC ---------- #
6
 
7
  def diamond_price(carat):
8
- price = int(carat * 88000)
9
- return f"πŸ’Ž Estimated Diamond Price: β‚Ή{price:,}"
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), (255,100,100), 2)
 
19
  return image
20
 
21
- # ---------- CREATIVE LIGHT CSS ---------- #
22
 
23
  css = """
24
  body {
25
- background: radial-gradient(circle at top left, #dbeafe, transparent 40%),
26
- radial-gradient(circle at bottom right, #fce7f3, transparent 40%),
27
- linear-gradient(120deg, #f8fafc, #eef2ff);
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
- .hero p {
47
- font-size: 16px;
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
- color: #4338ca;
66
  }
67
 
68
- h3 {
69
- color: #334155;
 
 
 
 
70
  }
71
 
72
  .gr-button {
73
- background: linear-gradient(135deg, #6366f1, #ec4899);
74
- color: white;
75
- border-radius: 16px;
76
- font-weight: 600;
77
  }
78
 
79
  .gr-button:hover {
80
- box-shadow: 0 10px 25px rgba(236,72,153,0.45);
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="hero">
90
- <h1>Simranpreet Kaur</h1>
91
- <p><b>AI β€’ Machine Learning β€’ Computer Vision</b></p>
92
- <p>Building intelligent systems with creativity & impact</p>
93
- <p>πŸ“ Fatehgarh Sahib, Punjab | πŸ“§ spreetkaur937@gmail.com</p>
94
  </div>
95
  """)
96
 
97
  gr.Markdown("""
98
  <div class="card">
99
- <h2>About Me</h2>
100
- <p>
101
- I am a <b>B.Tech Computer Science (2022–2026)</b> student passionate about
102
- <b>Artificial Intelligence, Machine Learning, and Computer Vision</b>.
103
- I love creating <b>modern, interactive, and real-world AI applications</b>.
104
- </p>
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><p>ML-based prediction using diamond features.</p></div>")
112
- carat = gr.Slider(0.1, 5.0, step=0.1, label="Diamond Carat")
113
- out = gr.Textbox(label="Predicted Price")
114
- carat.change(diamond_price, carat, out)
115
 
116
  with gr.Tab("πŸ§‘ Face Detection"):
117
- gr.Markdown("<div class='card'><h3>Face Detection</h3><p>Real-time face detection using OpenCV.</p></div>")
118
- img = gr.Image(type="numpy")
119
- out_img = gr.Image()
120
- img.change(face_detect, img, out_img)
121
 
122
  with gr.Tab("πŸ”Š Text to Speech"):
123
- gr.Markdown("<div class='card'><h3>Text to Speech</h3><p>Convert written text into natural voice.</p></div>")
124
- gr.Textbox(label="Enter text")
125
 
126
  with gr.Tab("πŸ“Š Stock Market Analysis"):
127
  gr.Markdown("""
128
  <div class="card">
129
- <h3>Stock Market Analysis</h3>
130
- <ul>
131
- <li>Trend Detection</li>
132
- <li>Pattern Analysis</li>
133
- <li>Data-driven Insights</li>
134
- </ul>
135
  </div>
136
  """)
137
 
138
  gr.Markdown("""
139
  <div class="card">
140
- <h3>Contact</h3>
141
- <p><b>Email:</b> spreetkaur937@gmail.com</p>
142
- <p>⭐ Hosted on Hugging Face Spaces</p>
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