Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
4b15757
1
Parent(s):
4d81439
Update app.py
Browse files
app.py
CHANGED
|
@@ -254,12 +254,16 @@ def certification(hf_username, first_name, last_name):
|
|
| 254 |
|
| 255 |
df = df1[['passed', 'unit', 'env', 'min_result', 'best_result', 'best_model_id']]
|
| 256 |
|
| 257 |
-
certificate, message, pdf = verify_certification(results_certification, hf_username, first_name, last_name)
|
| 258 |
print("MESSAGE", message)
|
| 259 |
|
| 260 |
-
|
|
|
|
|
|
|
|
|
|
| 261 |
|
| 262 |
-
|
|
|
|
| 263 |
|
| 264 |
"""
|
| 265 |
Verify that the user pass.
|
|
@@ -275,6 +279,8 @@ def verify_certification(df, hf_username, first_name, last_name):
|
|
| 275 |
# Check that we pass
|
| 276 |
model_pass_nb = 0
|
| 277 |
pass_percentage = 0
|
|
|
|
|
|
|
| 278 |
for unit in df:
|
| 279 |
if unit["passed_"] is True:
|
| 280 |
model_pass_nb += 1
|
|
@@ -283,6 +289,7 @@ def verify_certification(df, hf_username, first_name, last_name):
|
|
| 283 |
print("pass_percentage", pass_percentage)
|
| 284 |
|
| 285 |
if pass_percentage == 100:
|
|
|
|
| 286 |
# Generate a certificate of excellence
|
| 287 |
certificate, pdf = generate_certificate("./certificate_models/certificate-excellence.png", first_name, last_name)
|
| 288 |
|
|
@@ -298,6 +305,7 @@ def verify_certification(df, hf_username, first_name, last_name):
|
|
| 298 |
"""
|
| 299 |
|
| 300 |
elif pass_percentage < 100 and pass_percentage >= 80:
|
|
|
|
| 301 |
# Certificate of completion
|
| 302 |
certificate, pdf = generate_certificate("./certificate_models/certificate-completion.png", first_name, last_name)
|
| 303 |
|
|
@@ -316,7 +324,7 @@ def verify_certification(df, hf_username, first_name, last_name):
|
|
| 316 |
else:
|
| 317 |
# Not pass yet
|
| 318 |
certificate = Image.new("RGB", (100, 100), (255, 255, 255))
|
| 319 |
-
pdf =
|
| 320 |
|
| 321 |
# Add a message
|
| 322 |
message = """
|
|
@@ -324,7 +332,7 @@ def verify_certification(df, hf_username, first_name, last_name):
|
|
| 324 |
Check below which units you need to do again to get your certificate 💪
|
| 325 |
"""
|
| 326 |
print("return certificate")
|
| 327 |
-
return certificate, message, pdf
|
| 328 |
|
| 329 |
|
| 330 |
def generate_certificate(certificate_model, first_name, last_name):
|
|
@@ -396,12 +404,12 @@ with gr.Blocks() as demo:
|
|
| 396 |
last_name = gr.Textbox(placeholder="Doe", label="Your Last Name")
|
| 397 |
#email = gr.Textbox(placeholder="[email protected]", label="Your Email (to receive your certificate)")
|
| 398 |
check_progress_button = gr.Button(value="Check if I pass")
|
| 399 |
-
#with gr.Row(visible=False) as output_row:
|
| 400 |
output_text = gr.components.Textbox()
|
| 401 |
-
|
| 402 |
-
|
|
|
|
| 403 |
output_dataframe = gr.components.Dataframe(headers=["Pass?", "Unit", "Environment", "Baseline", "Your best result", "Your best model id"], datatype=["markdown", "markdown", "markdown", "number", "number", "markdown", "bool"]) #value= certification(hf_username, first_name, last_name),
|
| 404 |
-
check_progress_button.click(fn=certification, inputs=[hf_username, first_name, last_name], outputs=[output_text, output_pdf, output_img, output_dataframe
|
| 405 |
|
| 406 |
|
| 407 |
demo.launch(debug=True)
|
|
|
|
| 254 |
|
| 255 |
df = df1[['passed', 'unit', 'env', 'min_result', 'best_result', 'best_model_id']]
|
| 256 |
|
| 257 |
+
certificate, message, pdf, pass_ = verify_certification(results_certification, hf_username, first_name, last_name)
|
| 258 |
print("MESSAGE", message)
|
| 259 |
|
| 260 |
+
if pass_:
|
| 261 |
+
visible = True
|
| 262 |
+
else:
|
| 263 |
+
visible = False
|
| 264 |
|
| 265 |
+
|
| 266 |
+
return message, pdf, certificate, df, output_row.update(visible=visible)
|
| 267 |
|
| 268 |
"""
|
| 269 |
Verify that the user pass.
|
|
|
|
| 279 |
# Check that we pass
|
| 280 |
model_pass_nb = 0
|
| 281 |
pass_percentage = 0
|
| 282 |
+
pass_ = False
|
| 283 |
+
|
| 284 |
for unit in df:
|
| 285 |
if unit["passed_"] is True:
|
| 286 |
model_pass_nb += 1
|
|
|
|
| 289 |
print("pass_percentage", pass_percentage)
|
| 290 |
|
| 291 |
if pass_percentage == 100:
|
| 292 |
+
pass_ = True
|
| 293 |
# Generate a certificate of excellence
|
| 294 |
certificate, pdf = generate_certificate("./certificate_models/certificate-excellence.png", first_name, last_name)
|
| 295 |
|
|
|
|
| 305 |
"""
|
| 306 |
|
| 307 |
elif pass_percentage < 100 and pass_percentage >= 80:
|
| 308 |
+
pass_ = True
|
| 309 |
# Certificate of completion
|
| 310 |
certificate, pdf = generate_certificate("./certificate_models/certificate-completion.png", first_name, last_name)
|
| 311 |
|
|
|
|
| 324 |
else:
|
| 325 |
# Not pass yet
|
| 326 |
certificate = Image.new("RGB", (100, 100), (255, 255, 255))
|
| 327 |
+
certificate, pdf = generate_certificate(certificate.filename, first_name, last_name)
|
| 328 |
|
| 329 |
# Add a message
|
| 330 |
message = """
|
|
|
|
| 332 |
Check below which units you need to do again to get your certificate 💪
|
| 333 |
"""
|
| 334 |
print("return certificate")
|
| 335 |
+
return certificate, message, pdf, pass_
|
| 336 |
|
| 337 |
|
| 338 |
def generate_certificate(certificate_model, first_name, last_name):
|
|
|
|
| 404 |
last_name = gr.Textbox(placeholder="Doe", label="Your Last Name")
|
| 405 |
#email = gr.Textbox(placeholder="[email protected]", label="Your Email (to receive your certificate)")
|
| 406 |
check_progress_button = gr.Button(value="Check if I pass")
|
|
|
|
| 407 |
output_text = gr.components.Textbox()
|
| 408 |
+
with gr.Row(visible=True) as output_row:
|
| 409 |
+
output_pdf = gr.File()
|
| 410 |
+
output_img = gr.components.Image(type="pil")
|
| 411 |
output_dataframe = gr.components.Dataframe(headers=["Pass?", "Unit", "Environment", "Baseline", "Your best result", "Your best model id"], datatype=["markdown", "markdown", "markdown", "number", "number", "markdown", "bool"]) #value= certification(hf_username, first_name, last_name),
|
| 412 |
+
check_progress_button.click(fn=certification, inputs=[hf_username, first_name, last_name], outputs=[output_text, output_pdf, output_img, output_dataframe, output_row])#[output1, output2])
|
| 413 |
|
| 414 |
|
| 415 |
demo.launch(debug=True)
|