Commit
β’
b783df7
1
Parent(s):
622fe78
Update app.py
Browse files
app.py
CHANGED
@@ -256,7 +256,7 @@ def certification(hf_username, first_name, last_name):
|
|
256 |
|
257 |
certificate, message = verify_certification(results_certification, hf_username, first_name, last_name)
|
258 |
print("MESSAGE", message)
|
259 |
-
return message, df, certificate
|
260 |
|
261 |
"""
|
262 |
Verify that the user pass.
|
@@ -281,7 +281,7 @@ def verify_certification(df, hf_username, first_name, last_name):
|
|
281 |
|
282 |
if pass_percentage == 100:
|
283 |
# Generate a certificate of excellence
|
284 |
-
certificate = generate_certificate("./certificate_models/certificate-excellence.png", first_name, last_name)
|
285 |
|
286 |
# Add this user to our database
|
287 |
add_certified_user(hf_username, first_name, last_name, pass_percentage)
|
@@ -294,7 +294,7 @@ def verify_certification(df, hf_username, first_name, last_name):
|
|
294 |
|
295 |
elif pass_percentage < 100 and pass_percentage >= 80:
|
296 |
# Certificate of completion
|
297 |
-
certificate = generate_certificate("./certificate_models/certificate-completion.png", first_name, last_name)
|
298 |
|
299 |
# Add this user to our database
|
300 |
add_certified_user(hf_username, first_name, last_name, pass_percentage)
|
@@ -309,6 +309,7 @@ def verify_certification(df, hf_username, first_name, last_name):
|
|
309 |
else:
|
310 |
# Not pass yet
|
311 |
certificate = Image.new("RGB", (100, 100), (255, 255, 255))
|
|
|
312 |
|
313 |
# Add a message
|
314 |
message = """
|
@@ -316,7 +317,7 @@ def verify_certification(df, hf_username, first_name, last_name):
|
|
316 |
Check below which units you need to do again to get your certificate πͺ
|
317 |
"""
|
318 |
print("return certificate")
|
319 |
-
return certificate, message
|
320 |
|
321 |
|
322 |
def generate_certificate(certificate_model, first_name, last_name):
|
@@ -342,9 +343,9 @@ def generate_certificate(certificate_model, first_name, last_name):
|
|
342 |
# Date of certification
|
343 |
d.text((1480, 1170), str(date.today()), fill="black", anchor="mm", font=date_font)
|
344 |
|
345 |
-
im.save("certificate_"+".png")
|
346 |
|
347 |
-
return im
|
348 |
|
349 |
|
350 |
def add_certified_user(hf_username, first_name, last_name, pass_percentage):
|
@@ -383,8 +384,9 @@ with gr.Blocks() as demo:
|
|
383 |
#email = gr.Textbox(placeholder="jane.doe@gmail.com", label="Your Email (to receive your certificate)")
|
384 |
check_progress_button = gr.Button(value="Check if I pass")
|
385 |
output_text = gr.components.Textbox()
|
386 |
-
output_pdf = gr.
|
|
|
387 |
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),
|
388 |
-
check_progress_button.click(fn=certification, inputs=[hf_username, first_name, last_name], outputs=[output_text, output_dataframe, output_pdf])#[output1, output2])
|
389 |
|
390 |
demo.launch(debug=True)
|
|
|
256 |
|
257 |
certificate, message = verify_certification(results_certification, hf_username, first_name, last_name)
|
258 |
print("MESSAGE", message)
|
259 |
+
return message, pdf, df, certificate
|
260 |
|
261 |
"""
|
262 |
Verify that the user pass.
|
|
|
281 |
|
282 |
if pass_percentage == 100:
|
283 |
# Generate a certificate of excellence
|
284 |
+
certificate, pdf = generate_certificate("./certificate_models/certificate-excellence.png", first_name, last_name)
|
285 |
|
286 |
# Add this user to our database
|
287 |
add_certified_user(hf_username, first_name, last_name, pass_percentage)
|
|
|
294 |
|
295 |
elif pass_percentage < 100 and pass_percentage >= 80:
|
296 |
# Certificate of completion
|
297 |
+
certificate, pdf = generate_certificate("./certificate_models/certificate-completion.png", first_name, last_name)
|
298 |
|
299 |
# Add this user to our database
|
300 |
add_certified_user(hf_username, first_name, last_name, pass_percentage)
|
|
|
309 |
else:
|
310 |
# Not pass yet
|
311 |
certificate = Image.new("RGB", (100, 100), (255, 255, 255))
|
312 |
+
pdf = ""
|
313 |
|
314 |
# Add a message
|
315 |
message = """
|
|
|
317 |
Check below which units you need to do again to get your certificate πͺ
|
318 |
"""
|
319 |
print("return certificate")
|
320 |
+
return certificate, message, pdf
|
321 |
|
322 |
|
323 |
def generate_certificate(certificate_model, first_name, last_name):
|
|
|
343 |
# Date of certification
|
344 |
d.text((1480, 1170), str(date.today()), fill="black", anchor="mm", font=date_font)
|
345 |
|
346 |
+
pdf = im.save("certificate_"+".png")
|
347 |
|
348 |
+
return im, pdf
|
349 |
|
350 |
|
351 |
def add_certified_user(hf_username, first_name, last_name, pass_percentage):
|
|
|
384 |
#email = gr.Textbox(placeholder="jane.doe@gmail.com", label="Your Email (to receive your certificate)")
|
385 |
check_progress_button = gr.Button(value="Check if I pass")
|
386 |
output_text = gr.components.Textbox()
|
387 |
+
output_pdf = gr.File()
|
388 |
+
output_img = gr.components.Image(type="pil")
|
389 |
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),
|
390 |
+
check_progress_button.click(fn=certification, inputs=[hf_username, first_name, last_name], outputs=[output_text, output_dataframe, output_pdf, output_img])#[output1, output2])
|
391 |
|
392 |
demo.launch(debug=True)
|