Commit
β’
e9b5b0a
1
Parent(s):
2cb378a
Update app.py
Browse files
app.py
CHANGED
@@ -218,7 +218,7 @@ def certification(hf_username, first_name, last_name):
|
|
218 |
"unit": "Unit 8 PI",
|
219 |
"env": "GodotRL-JumperHard",
|
220 |
"library": "cleanrl",
|
221 |
-
"min_result":
|
222 |
"best_result": 0,
|
223 |
"best_model_id": "",
|
224 |
"passed_": False
|
@@ -227,7 +227,7 @@ def certification(hf_username, first_name, last_name):
|
|
227 |
"unit": "Unit 8 PII",
|
228 |
"env": "Vizdoom-Battle",
|
229 |
"library": "cleanrl",
|
230 |
-
"min_result":
|
231 |
"best_result": 0,
|
232 |
"best_model_id": "",
|
233 |
"passed_": False
|
@@ -254,9 +254,9 @@ def certification(hf_username, first_name, last_name):
|
|
254 |
|
255 |
df = df1[['passed', 'unit', 'env', 'min_result', 'best_result', 'best_model_id']]
|
256 |
|
257 |
-
verify_certification(results_certification, hf_username, first_name, last_name)
|
258 |
|
259 |
-
return df
|
260 |
|
261 |
"""
|
262 |
Verify that the user pass.
|
@@ -281,27 +281,32 @@ def verify_certification(df, hf_username, first_name, last_name):
|
|
281 |
|
282 |
if pass_percentage == 100:
|
283 |
# Generate a certificate of excellence
|
284 |
-
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)
|
288 |
|
289 |
-
#
|
290 |
-
|
291 |
|
292 |
elif pass_percentage < 100 and pass_percentage >= 80:
|
293 |
# Certificate of completion
|
294 |
-
generate_certificate("./certificate_models/certificate-completion.png", first_name, last_name)
|
295 |
|
296 |
# Add this user to our database
|
297 |
add_certified_user(hf_username, first_name, last_name, pass_percentage)
|
298 |
|
299 |
-
#
|
300 |
-
|
301 |
|
302 |
else:
|
303 |
# Not pass yet
|
304 |
-
|
|
|
|
|
|
|
|
|
|
|
305 |
|
306 |
def generate_certificate(certificate_model, first_name, last_name):
|
307 |
im = Image.open(certificate_model)
|
@@ -328,6 +333,8 @@ def generate_certificate(certificate_model, first_name, last_name):
|
|
328 |
|
329 |
im.save("certificate_"+".png")
|
330 |
|
|
|
|
|
331 |
|
332 |
def add_certified_user(hf_username, first_name, last_name, pass_percentage):
|
333 |
print("ADD CERTIFIED USER")
|
@@ -337,10 +344,7 @@ def add_certified_user(hf_username, first_name, last_name, pass_percentage):
|
|
337 |
# Check if this hf_username is already in our dataset:
|
338 |
check = history.loc[history['hf_username'] == hf_username]
|
339 |
if not check.empty:
|
340 |
-
#print("CHECK", check)
|
341 |
-
#print("INDEX", check.index[0])
|
342 |
history = history.drop(labels=check.index[0], axis=0)
|
343 |
-
#history.iloc[[check.index[0]],['hf_username', 'first_name', 'last_name', 'pass_percentage', 'datetime']] = hf_username, first_name, last_name, pass_percentage, time.time()
|
344 |
|
345 |
new_row = pd.DataFrame({'hf_username': hf_username, 'first_name': first_name, 'last_name': last_name, 'pass_percentage': pass_percentage, 'datetime': time.time()}, index=[0])
|
346 |
history = pd.concat([new_row, history[:]]).reset_index(drop=True)
|
@@ -351,17 +355,15 @@ def add_certified_user(hf_username, first_name, last_name, pass_percentage):
|
|
351 |
|
352 |
with gr.Blocks() as demo:
|
353 |
gr.Markdown(f"""
|
354 |
-
#
|
355 |
-
|
356 |
-
|
357 |
-
- To get a certificate of completion, you must **pass 80% of the assignments before the end of April 2023**.
|
358 |
-
- To get an honors certificate, you must **pass 100% of the assignments before the end of April 2023**.
|
359 |
|
360 |
-
To
|
|
|
361 |
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
""")
|
366 |
|
367 |
hf_username = gr.Textbox(placeholder="ThomasSimonini", label="Your Hugging Face Username (case sensitive)")
|
@@ -369,8 +371,9 @@ with gr.Blocks() as demo:
|
|
369 |
last_name = gr.Textbox(placeholder="Doe", label="Your Last Name")
|
370 |
#email = gr.Textbox(placeholder="[email protected]", label="Your Email (to receive your certificate)")
|
371 |
check_progress_button = gr.Button(value="Check my progress")
|
372 |
-
|
373 |
-
|
374 |
-
|
|
|
375 |
|
376 |
demo.launch(debug=True)
|
|
|
218 |
"unit": "Unit 8 PI",
|
219 |
"env": "GodotRL-JumperHard",
|
220 |
"library": "cleanrl",
|
221 |
+
"min_result": 100,
|
222 |
"best_result": 0,
|
223 |
"best_model_id": "",
|
224 |
"passed_": False
|
|
|
227 |
"unit": "Unit 8 PII",
|
228 |
"env": "Vizdoom-Battle",
|
229 |
"library": "cleanrl",
|
230 |
+
"min_result": 100,
|
231 |
"best_result": 0,
|
232 |
"best_model_id": "",
|
233 |
"passed_": False
|
|
|
254 |
|
255 |
df = df1[['passed', 'unit', 'env', 'min_result', 'best_result', 'best_model_id']]
|
256 |
|
257 |
+
message, certification = verify_certification(results_certification, hf_username, first_name, last_name)
|
258 |
|
259 |
+
return message, df, certification
|
260 |
|
261 |
"""
|
262 |
Verify that the user pass.
|
|
|
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)
|
288 |
|
289 |
+
# Add a message
|
290 |
+
message = "Congratulations, you successfully completed the Hugging Face Deep Reinforcement Learning Course π \n Since you pass 100% of the hands-on you get a Certificate of Excellence π."
|
291 |
|
292 |
elif pass_percentage < 100 and pass_percentage >= 80:
|
293 |
# Certificate of completion
|
294 |
+
certificate = generate_certificate("./certificate_models/certificate-completion.png", first_name, last_name)
|
295 |
|
296 |
# Add this user to our database
|
297 |
add_certified_user(hf_username, first_name, last_name, pass_percentage)
|
298 |
|
299 |
+
# Add a message
|
300 |
+
message = "Congratulations, you successfully completed the Hugging Face Deep Reinforcement Learning Course π \n Since you pass 80% of the hands-on you get a Certificate of Completion π. You can try to get a Certificate of Excellence if you pass 100% of the hands-on, don't hesitate to check which unit you didn't pass and update these models."
|
301 |
|
302 |
else:
|
303 |
# Not pass yet
|
304 |
+
certificate = ""
|
305 |
+
# Add a message
|
306 |
+
message = "You didn't pass the minimum of 80% of the hands-on to get a certificate of completion. But don't be discouraged. Check below which units you need to do again to get your certificate πͺ"
|
307 |
+
|
308 |
+
return certificate, message
|
309 |
+
|
310 |
|
311 |
def generate_certificate(certificate_model, first_name, last_name):
|
312 |
im = Image.open(certificate_model)
|
|
|
333 |
|
334 |
im.save("certificate_"+".png")
|
335 |
|
336 |
+
return im
|
337 |
+
|
338 |
|
339 |
def add_certified_user(hf_username, first_name, last_name, pass_percentage):
|
340 |
print("ADD CERTIFIED USER")
|
|
|
344 |
# Check if this hf_username is already in our dataset:
|
345 |
check = history.loc[history['hf_username'] == hf_username]
|
346 |
if not check.empty:
|
|
|
|
|
347 |
history = history.drop(labels=check.index[0], axis=0)
|
|
|
348 |
|
349 |
new_row = pd.DataFrame({'hf_username': hf_username, 'first_name': first_name, 'last_name': last_name, 'pass_percentage': pass_percentage, 'datetime': time.time()}, index=[0])
|
350 |
history = pd.concat([new_row, history[:]]).reset_index(drop=True)
|
|
|
355 |
|
356 |
with gr.Blocks() as demo:
|
357 |
gr.Markdown(f"""
|
358 |
+
# Get your certificate π
|
359 |
+
The certification process is completely free:
|
|
|
|
|
|
|
360 |
|
361 |
+
- To get a *certificate of completion*: you need to **pass 80% of the assignments before the end of April 2023**.
|
362 |
+
- To get a *certificate of honors*: you need to **pass 100% of the assignments before the end of April 2023**.
|
363 |
|
364 |
+
For more information about the certification process [check this](https://huggingface.co/deep-rl-course/communication/certification)
|
365 |
+
|
366 |
+
Donβt hesitate to share your certificate on Twitter (tag me @ThomasSimonini and @huggingface) and on Linkedin.
|
367 |
""")
|
368 |
|
369 |
hf_username = gr.Textbox(placeholder="ThomasSimonini", label="Your Hugging Face Username (case sensitive)")
|
|
|
371 |
last_name = gr.Textbox(placeholder="Doe", label="Your Last Name")
|
372 |
#email = gr.Textbox(placeholder="[email protected]", label="Your Email (to receive your certificate)")
|
373 |
check_progress_button = gr.Button(value="Check my progress")
|
374 |
+
output_text = gr.components.Text()
|
375 |
+
output_pdf = gr.components.Image(type="pil")
|
376 |
+
output_dataframe = gr.components.Dataframe(value= certification(hf_username, first_name, last_name), headers=["Pass?", "Unit", "Environment", "Baseline", "Your best result", "Your best model id"], datatype=["markdown", "markdown", "markdown", "number", "number", "markdown", "bool"])
|
377 |
+
check_progress_button.click(fn=certification, inputs=[hf_username, first_name, last_name], outputs=[output_text, output_pdf, output_dataframe])#[output1, output2])
|
378 |
|
379 |
demo.launch(debug=True)
|