feat: QoL & better UI
Browse files
app.py
CHANGED
|
@@ -89,61 +89,63 @@ def predict_and_compare(image):
|
|
| 89 |
ssim_value = compare_face_ssim(image, ssim_reference, face_area)
|
| 90 |
|
| 91 |
predicted_class = "True" if verified else "False"
|
| 92 |
-
probability = 1 - abs(distance)
|
| 93 |
|
| 94 |
success = f"""
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
Connecting to husseumi.space on port 22
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
{
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
Connection to husseumi.space closed.
|
|
|
|
| 128 |
"""
|
| 129 |
|
| 130 |
fail = f"""
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
Connecting to husseumi.space on port 22
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
Authentication Report
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
Permission denied (publickey,facial)
|
| 146 |
-
Connection to husseumi.space closed.
|
|
|
|
| 147 |
"""
|
| 148 |
return success if ssim_value>=0.96 and predicted_class == 'True' else fail
|
| 149 |
|
|
@@ -152,13 +154,36 @@ Connection to husseumi.space closed.
|
|
| 152 |
if os.path.exists(temp_path):
|
| 153 |
os.remove(temp_path)
|
| 154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
iface = gr.Interface(
|
| 156 |
fn=predict_and_compare,
|
| 157 |
-
inputs=gr.Image(type="pil"),
|
| 158 |
-
outputs=
|
| 159 |
title="Jelly's Authentication System 🌠",
|
| 160 |
description="Submit your image to authenticate!",
|
| 161 |
allow_flagging="never",
|
|
|
|
|
|
|
| 162 |
)
|
| 163 |
|
| 164 |
-
iface.
|
|
|
|
|
|
| 89 |
ssim_value = compare_face_ssim(image, ssim_reference, face_area)
|
| 90 |
|
| 91 |
predicted_class = "True" if verified else "False"
|
| 92 |
+
probability = 1 - abs(distance)
|
| 93 |
|
| 94 |
success = f"""
|
| 95 |
+
<div style="font-family: 'Courier New', monospace; background: #1a1b26; color: #a9b1d6; padding: 20px; border-radius: 8px;">
|
| 96 |
+
<span style="color: #7aa2f7">guest@terminal</span>:<span style="color: #9ece6a">~</span>$ ssh jerry@husseumi.space<br>
|
| 97 |
+
Connecting to husseumi.space on port 22...<br><br>
|
| 98 |
+
|
| 99 |
+
<span style="color: #bb9af7">✧ Initiating facial authentication... ✧</span><br>
|
| 100 |
+
<span style="color: #7dcfff">⋆。°✩ Scanning face... ✩°。⋆</span><br>
|
| 101 |
+
<span style="color: #7dcfff">.。*゚ Matching with database... ゚*。.</span><br>
|
| 102 |
+
<span style="color: #9ece6a">✧・゚: Biometric verification complete! :・゚✧</span><br><br>
|
| 103 |
+
|
| 104 |
+
<div style="background: #1f2335; padding: 10px; border-radius: 4px; margin: 10px 0;">
|
| 105 |
+
<pre style="color: #7aa2f7; margin: 0; font-family: monospace;">
|
| 106 |
+
╭──── 🌠 Welcome to Jelly's Space 🌠 ─────╮
|
| 107 |
+
│ *:・゚✧ Authentication successful! ✧゚・:* |
|
| 108 |
+
│ a-awawawa... welcome back! │
|
| 109 |
+
╰─────────────- ✧◝(⁰▿⁰)◜✧ -────────────╯</pre>
|
| 110 |
+
</div>
|
| 111 |
+
|
| 112 |
+
Last login: Wed Mar 13 12:34:56 2024 from 192.168.1.1<br>
|
| 113 |
+
<span style="color: #bb9af7">This server is powered by dewaweb™ - Empowering Your Digital Dreams ⋆。°✩</span><br><br>
|
| 114 |
+
|
| 115 |
+
<span style="color: #7aa2f7">jerry@husseumi</span>:<span style="color: #9ece6a">~</span>$ cat ~/.auth/metrics.log<br>
|
| 116 |
+
<span style="color: #7dcfff">⭑⋆˙⟡ Facial Match : {predicted_class}</span><br>
|
| 117 |
+
<span style="color: #7dcfff">⭑⋆˙⟡ Match Score : {probability:.4f}</span><br>
|
| 118 |
+
<span style="color: #7dcfff">⭑⋆˙⟡ Similarity : {ssim_value:.4f}</span><br><br>
|
| 119 |
+
|
| 120 |
+
<span style="color: #7aa2f7">jerry@husseumi</span>:<span style="color: #9ece6a">~</span>$ sudo cat /etc/secrets/flag.txt<br>
|
| 121 |
+
<span style="color: #f7768e">⋆。°✩ {flag} ✩°。⋆</span><br><br>
|
| 122 |
+
|
| 123 |
+
<span style="color: #7aa2f7">jerry@husseumi</span>:<span style="color: #9ece6a">~</span>$ exit<br>
|
| 124 |
+
<span style="color: #bb9af7">✧・゚: A-awawawa... goodbye! Have a lovely day! :・゚✧</span><br>
|
| 125 |
+
<span style="color: #bb9af7">.。*゚+.*.。(っ°v°c)。.*+.゚*。.</span><br><br>
|
| 126 |
+
|
| 127 |
+
Connection to husseumi.space closed.
|
| 128 |
+
</div>
|
| 129 |
"""
|
| 130 |
|
| 131 |
fail = f"""
|
| 132 |
+
<div style="font-family: 'Courier New', monospace; background: #1a1b26; color: #a9b1d6; padding: 20px; border-radius: 8px;">
|
| 133 |
+
<span style="color: #7aa2f7">guest@terminal</span>:<span style="color: #9ece6a">~</span>$ ssh jerry@husseumi.space<br>
|
| 134 |
+
Connecting to husseumi.space on port 22...<br><br>
|
| 135 |
+
|
| 136 |
+
<span style="color: #bb9af7">✧ Initiating facial authentication... ✧</span><br>
|
| 137 |
+
<span style="color: #7dcfff">⋆。°✩ Scanning face... ✩°。⋆</span><br>
|
| 138 |
+
<span style="color: #7dcfff">.。*゚ Matching with database... ゚*。.</span><br>
|
| 139 |
+
<span style="color: #f7768e">(◞‸◟;) Biometric verification failed</span><br><br>
|
| 140 |
+
|
| 141 |
+
Authentication Report:<br>
|
| 142 |
+
<span style="color: #7dcfff">。・゚゚・ Face Match : {predicted_class}</span><br>
|
| 143 |
+
<span style="color: #7dcfff">。・゚゚・ Match Score : {probability:.4f}</span><br>
|
| 144 |
+
<span style="color: #7dcfff">。・゚゚・ Similarity : {ssim_value:.4f}</span><br><br>
|
| 145 |
+
|
| 146 |
+
<span style="color: #f7768e">Permission denied (publickey,facial).</span><br>
|
| 147 |
+
Connection to husseumi.space closed.
|
| 148 |
+
</div>
|
| 149 |
"""
|
| 150 |
return success if ssim_value>=0.96 and predicted_class == 'True' else fail
|
| 151 |
|
|
|
|
| 154 |
if os.path.exists(temp_path):
|
| 155 |
os.remove(temp_path)
|
| 156 |
|
| 157 |
+
custom_css = """
|
| 158 |
+
#output-html {
|
| 159 |
+
font-family: 'Courier New', monospace;
|
| 160 |
+
background: #1a1b26;
|
| 161 |
+
color: #a9b1d6;
|
| 162 |
+
padding: 20px;
|
| 163 |
+
border-radius: 8px;
|
| 164 |
+
min-height: 200px;
|
| 165 |
+
margin-top: 10px;
|
| 166 |
+
}
|
| 167 |
+
"""
|
| 168 |
+
|
| 169 |
+
default_output = """
|
| 170 |
+
<div style="font-family: 'Courier New', monospace; background: #1a1b26; color: #a9b1d6; padding: 20px; border-radius: 8px;">
|
| 171 |
+
<span style="color: #7aa2f7">guest@terminal</span>:<span style="color: #9ece6a">~</span>$ ssh jerry@husseumi.space<br>
|
| 172 |
+
<span style="color: #7dcfff">Awaiting facial authentication...</span><br>
|
| 173 |
+
<span style="color: #bb9af7">Please submit an image to proceed ˚ ༘ ೀ⋆。˚</span>
|
| 174 |
+
</div>
|
| 175 |
+
"""
|
| 176 |
+
|
| 177 |
iface = gr.Interface(
|
| 178 |
fn=predict_and_compare,
|
| 179 |
+
inputs=gr.Image(type="pil", label="Upload Image"),
|
| 180 |
+
outputs=gr.HTML(value=default_output),
|
| 181 |
title="Jelly's Authentication System 🌠",
|
| 182 |
description="Submit your image to authenticate!",
|
| 183 |
allow_flagging="never",
|
| 184 |
+
css=custom_css,
|
| 185 |
+
theme="allenai/gradio-theme"
|
| 186 |
)
|
| 187 |
|
| 188 |
+
iface.queue()
|
| 189 |
+
iface.launch(show_api=False)
|