ds-ekaterina commited on
Commit
3e70fb3
·
1 Parent(s): b42453c
Files changed (1) hide show
  1. app.py +58 -11
app.py CHANGED
@@ -88,10 +88,10 @@ HTML_FACE_COMPARISON_EXPLANATION = """
88
  <h3 style="color:#2E86C1;">🔍 Face Comparison Results Explanation</h3>
89
  <p>The system compares two photos and provides one of four results:</p>
90
  <ul>
91
- <li><strong style="color:#28A745;">Same Person</strong>: The same person appears in both photos.</li>
92
- <li><strong style="color:#DC3545;">Different Person</strong>: The photos show different individuals.</li>
93
- <li><strong style="color:#F39C12;">Same Photo</strong>: Identical faces detected, possibly indicating a duplicate or edited image.</li>
94
- <li><strong style="color:#6C757D;">Failure</strong>: Face comparison failed due to undetected or unclear faces.</li>
95
  </ul>
96
  """
97
 
@@ -105,8 +105,8 @@ def check_liveness(file_path):
105
  liveness_result = response.json()
106
 
107
  if (
108
- "ran_checks" not in liveness_result.keys()
109
- or len(liveness_result["ran_checks"]) == 0
110
  ):
111
  msg = ""
112
  elif liveness_result["ran_checks"] == ["ImageQuality"]:
@@ -129,13 +129,13 @@ def check_liveness(file_path):
129
 
130
  def map_fc_result(api_status: str):
131
  mapping = {
132
- "FaceComparisonVerified": {"label": "Same Person", "color": "green"},
133
- "FaceComparisonUnknown": {"label": "Failure", "color": "gray"},
134
  "FaceComparisonFailedDifferentFaces": {
135
  "label": "Different Person",
136
- "color": "red",
137
  },
138
- "FaceComparisonFailedSamePhotos": {"label": "Same Photo", "color": "#F39C12"},
139
  }
140
  status = api_status["status"] if "status" in api_status.keys() else ""
141
  return mapping.get(status, {"label": "Unknown", "color": "gray"})
@@ -159,7 +159,53 @@ def compare_faces(image1_path, image2_path):
159
  return comparison_result, "", False
160
 
161
 
162
- with gr.Blocks(theme=gr.themes.Soft()) as Demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  with gr.Tabs():
164
  with gr.Tab("Liveness Detection"):
165
  header_box = gr.HTML(HTML_HEADER)
@@ -239,5 +285,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as Demo:
239
  outputs=[comparison_result, comparison_state],
240
  )
241
 
 
242
  if __name__ == "__main__":
243
  Demo.launch()
 
88
  <h3 style="color:#2E86C1;">🔍 Face Comparison Results Explanation</h3>
89
  <p>The system compares two photos and provides one of four results:</p>
90
  <ul>
91
+ <li><strong style="color:#2ECC71;">Same Person</strong>: The same person appears in both photos.</li>
92
+ <li><strong style="color:#E74C3C;">Different Person</strong>: The photos show different individuals.</li>
93
+ <li><strong style="color:#F1C40F;">Same Photo</strong>: Identical faces detected, possibly indicating a duplicate or edited image.</li>
94
+ <li><strong style="color:#95A5A6;">Failure</strong>: Face comparison failed due to undetected or unclear faces.</li>
95
  </ul>
96
  """
97
 
 
105
  liveness_result = response.json()
106
 
107
  if (
108
+ "ran_checks" not in liveness_result.keys()
109
+ or len(liveness_result["ran_checks"]) == 0
110
  ):
111
  msg = ""
112
  elif liveness_result["ran_checks"] == ["ImageQuality"]:
 
129
 
130
  def map_fc_result(api_status: str):
131
  mapping = {
132
+ "FaceComparisonVerified": {"label": "Same Person", "color": "#2ECC71"},
133
+ "FaceComparisonUnknown": {"label": "Failure", "color": "#95A5A6"},
134
  "FaceComparisonFailedDifferentFaces": {
135
  "label": "Different Person",
136
+ "color": "#E74C3C",
137
  },
138
+ "FaceComparisonFailedSamePhotos": {"label": "Same Photo", "color": "#F1C40F"},
139
  }
140
  status = api_status["status"] if "status" in api_status.keys() else ""
141
  return mapping.get(status, {"label": "Unknown", "color": "gray"})
 
159
  return comparison_result, "", False
160
 
161
 
162
+ tabs_css = """
163
+ /* Style all Gradio tab buttons */
164
+ button[role="tab"] {
165
+ font-size: 14px !important;
166
+ font-family: 'Montserrat', sans-serif !important;
167
+ font-weight: 600 !important;
168
+ padding: 12px 24px !important;
169
+ margin: 0 6px !important;
170
+ background-color: #0B0F19 !important;
171
+ color: #F3F4F6 !important;
172
+ border-radius: 8px !important;
173
+ border: 1px solid #1a1a1a !important;
174
+ box-shadow: none !important;
175
+ transition: all 0.2s ease !important;
176
+ }
177
+
178
+ /* Style selected tab button */
179
+ button[role="tab"].selected {
180
+ background-color: #635bff !important;
181
+ color: white !important;
182
+ box-shadow: 0 0 6px rgba(99, 91, 255, 0.5) !important;
183
+ }
184
+
185
+ /* Inactive tab style */
186
+ button[role="tab"]:not(.selected) {
187
+ font-size: 14px !important;
188
+ font-family: 'Montserrat', sans-serif !important;
189
+ font-weight: 600 !important;
190
+ padding: 12px 24px !important;
191
+ margin: 0 6px !important;
192
+ background-color: #9D2C53 !important;
193
+ color: #F3F4F6 !important;
194
+ border-radius: 8px !important;
195
+ border: 1px solid #1a1a1a !important;
196
+ box-shadow: none !important;
197
+ transition: all 0.2s ease !important;
198
+ }
199
+
200
+ /* Optional: hover effect */
201
+ button[role="tab"]:hover {
202
+ background-color: #1a1a2b !important;
203
+ color: white !important;
204
+ }
205
+ """
206
+
207
+
208
+ with gr.Blocks(theme=gr.themes.Soft(), css=tabs_css) as Demo:
209
  with gr.Tabs():
210
  with gr.Tab("Liveness Detection"):
211
  header_box = gr.HTML(HTML_HEADER)
 
285
  outputs=[comparison_result, comparison_state],
286
  )
287
 
288
+
289
  if __name__ == "__main__":
290
  Demo.launch()