Commit
·
8c0874a
1
Parent(s):
792907f
Update app.py
Browse files
app.py
CHANGED
|
@@ -103,9 +103,9 @@ def check_if_passed(model):
|
|
| 103 |
:param model: user model
|
| 104 |
"""
|
| 105 |
if model["best_result"] >= model["min_result"]:
|
| 106 |
-
model["
|
| 107 |
|
| 108 |
-
def
|
| 109 |
results_certification = [
|
| 110 |
{
|
| 111 |
"unit": "Unit 1",
|
|
@@ -114,17 +114,8 @@ def test_(hf_username):
|
|
| 114 |
"min_result": 200,
|
| 115 |
"best_result": 0,
|
| 116 |
"best_model_id": "",
|
| 117 |
-
"
|
| 118 |
},
|
| 119 |
-
{
|
| 120 |
-
"unit": "Bonus Unit 1",
|
| 121 |
-
"env": "ML-Agents-Huggy",
|
| 122 |
-
"library": "ml-agents",
|
| 123 |
-
"min_result": -100,
|
| 124 |
-
"best_result": 0,
|
| 125 |
-
"best_model_id": "",
|
| 126 |
-
"passed": False
|
| 127 |
-
},
|
| 128 |
{
|
| 129 |
"unit": "Unit 2",
|
| 130 |
"env": "Taxi-v3",
|
|
@@ -132,7 +123,7 @@ def test_(hf_username):
|
|
| 132 |
"min_result": 4,
|
| 133 |
"best_result": 0,
|
| 134 |
"best_model_id": "",
|
| 135 |
-
"
|
| 136 |
},
|
| 137 |
{
|
| 138 |
"unit": "Unit 3",
|
|
@@ -141,7 +132,7 @@ def test_(hf_username):
|
|
| 141 |
"min_result": 200,
|
| 142 |
"best_result": 0,
|
| 143 |
"best_model_id": "",
|
| 144 |
-
"
|
| 145 |
},
|
| 146 |
{
|
| 147 |
"unit": "Unit 4",
|
|
@@ -150,7 +141,7 @@ def test_(hf_username):
|
|
| 150 |
"min_result": 350,
|
| 151 |
"best_result": 0,
|
| 152 |
"best_model_id": "",
|
| 153 |
-
"
|
| 154 |
},
|
| 155 |
{
|
| 156 |
"unit": "Unit 4",
|
|
@@ -159,7 +150,7 @@ def test_(hf_username):
|
|
| 159 |
"min_result": 5,
|
| 160 |
"best_result": 0,
|
| 161 |
"best_model_id": "",
|
| 162 |
-
"
|
| 163 |
},
|
| 164 |
{
|
| 165 |
"unit": "Unit 5",
|
|
@@ -168,7 +159,7 @@ def test_(hf_username):
|
|
| 168 |
"min_result": -100,
|
| 169 |
"best_result": 0,
|
| 170 |
"best_model_id": "",
|
| 171 |
-
"
|
| 172 |
},
|
| 173 |
{
|
| 174 |
"unit": "Unit 5",
|
|
@@ -177,7 +168,7 @@ def test_(hf_username):
|
|
| 177 |
"min_result": -100,
|
| 178 |
"best_result": 0,
|
| 179 |
"best_model_id": "",
|
| 180 |
-
"
|
| 181 |
},
|
| 182 |
{
|
| 183 |
"unit": "Unit 6",
|
|
@@ -186,7 +177,7 @@ def test_(hf_username):
|
|
| 186 |
"min_result": 650,
|
| 187 |
"best_result": 0,
|
| 188 |
"best_model_id": "",
|
| 189 |
-
"
|
| 190 |
},
|
| 191 |
{
|
| 192 |
"unit": "Unit 6",
|
|
@@ -195,7 +186,7 @@ def test_(hf_username):
|
|
| 195 |
"min_result": -3.5,
|
| 196 |
"best_result": 0,
|
| 197 |
"best_model_id": "",
|
| 198 |
-
"
|
| 199 |
},
|
| 200 |
{
|
| 201 |
"unit": "Unit 7",
|
|
@@ -204,13 +195,31 @@ def test_(hf_username):
|
|
| 204 |
"min_result": -100,
|
| 205 |
"best_result": 0,
|
| 206 |
"best_model_id": "",
|
| 207 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
},
|
| 209 |
]
|
| 210 |
for unit in results_certification:
|
| 211 |
# Get user model
|
| 212 |
user_models = get_user_models(hf_username, unit['env'], unit['library'])
|
| 213 |
-
|
| 214 |
# Calculate the best result and get the best_model_id
|
| 215 |
best_result, best_model_id = calculate_best_result(user_models)
|
| 216 |
|
|
@@ -220,12 +229,12 @@ def test_(hf_username):
|
|
| 220 |
|
| 221 |
# Based on best_result do we pass the unit?
|
| 222 |
check_if_passed(unit)
|
| 223 |
-
|
| 224 |
|
| 225 |
print(results_certification)
|
| 226 |
|
| 227 |
-
df = pd.DataFrame
|
| 228 |
-
|
| 229 |
return df
|
| 230 |
|
| 231 |
|
|
@@ -247,7 +256,7 @@ with gr.Blocks() as demo:
|
|
| 247 |
hf_username = gr.Textbox(placeholder="ThomasSimonini", label="Your Hugging Face Username")
|
| 248 |
#email = gr.Textbox(placeholder="[email protected]", label="Your Email (to receive your certificate)")
|
| 249 |
check_progress_button = gr.Button(value="Check my progress")
|
| 250 |
-
output = gr.components.Dataframe(value=
|
| 251 |
-
check_progress_button.click(fn=
|
| 252 |
|
| 253 |
demo.launch()
|
|
|
|
| 103 |
:param model: user model
|
| 104 |
"""
|
| 105 |
if model["best_result"] >= model["min_result"]:
|
| 106 |
+
model["passed_"] = True
|
| 107 |
|
| 108 |
+
def certification(hf_username):
|
| 109 |
results_certification = [
|
| 110 |
{
|
| 111 |
"unit": "Unit 1",
|
|
|
|
| 114 |
"min_result": 200,
|
| 115 |
"best_result": 0,
|
| 116 |
"best_model_id": "",
|
| 117 |
+
"passed_": False
|
| 118 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
{
|
| 120 |
"unit": "Unit 2",
|
| 121 |
"env": "Taxi-v3",
|
|
|
|
| 123 |
"min_result": 4,
|
| 124 |
"best_result": 0,
|
| 125 |
"best_model_id": "",
|
| 126 |
+
"passed_": False
|
| 127 |
},
|
| 128 |
{
|
| 129 |
"unit": "Unit 3",
|
|
|
|
| 132 |
"min_result": 200,
|
| 133 |
"best_result": 0,
|
| 134 |
"best_model_id": "",
|
| 135 |
+
"passed_": False
|
| 136 |
},
|
| 137 |
{
|
| 138 |
"unit": "Unit 4",
|
|
|
|
| 141 |
"min_result": 350,
|
| 142 |
"best_result": 0,
|
| 143 |
"best_model_id": "",
|
| 144 |
+
"passed_": False
|
| 145 |
},
|
| 146 |
{
|
| 147 |
"unit": "Unit 4",
|
|
|
|
| 150 |
"min_result": 5,
|
| 151 |
"best_result": 0,
|
| 152 |
"best_model_id": "",
|
| 153 |
+
"passed_": False
|
| 154 |
},
|
| 155 |
{
|
| 156 |
"unit": "Unit 5",
|
|
|
|
| 159 |
"min_result": -100,
|
| 160 |
"best_result": 0,
|
| 161 |
"best_model_id": "",
|
| 162 |
+
"passed_": False
|
| 163 |
},
|
| 164 |
{
|
| 165 |
"unit": "Unit 5",
|
|
|
|
| 168 |
"min_result": -100,
|
| 169 |
"best_result": 0,
|
| 170 |
"best_model_id": "",
|
| 171 |
+
"passed_": False
|
| 172 |
},
|
| 173 |
{
|
| 174 |
"unit": "Unit 6",
|
|
|
|
| 177 |
"min_result": 650,
|
| 178 |
"best_result": 0,
|
| 179 |
"best_model_id": "",
|
| 180 |
+
"passed_": False
|
| 181 |
},
|
| 182 |
{
|
| 183 |
"unit": "Unit 6",
|
|
|
|
| 186 |
"min_result": -3.5,
|
| 187 |
"best_result": 0,
|
| 188 |
"best_model_id": "",
|
| 189 |
+
"passed_": False
|
| 190 |
},
|
| 191 |
{
|
| 192 |
"unit": "Unit 7",
|
|
|
|
| 195 |
"min_result": -100,
|
| 196 |
"best_result": 0,
|
| 197 |
"best_model_id": "",
|
| 198 |
+
"passed_": False
|
| 199 |
+
},
|
| 200 |
+
{
|
| 201 |
+
"unit": "Unit 8 PI",
|
| 202 |
+
"env": "GodotRL-JumperHard",
|
| 203 |
+
"library": "cleanrl",
|
| 204 |
+
"min_result": 100,
|
| 205 |
+
"best_result": 0,
|
| 206 |
+
"best_model_id": "",
|
| 207 |
+
"passed_": False
|
| 208 |
+
},
|
| 209 |
+
{
|
| 210 |
+
"unit": "Unit 8 PII",
|
| 211 |
+
"env": "Vizdoom-Battle",
|
| 212 |
+
"library": "cleanrl",
|
| 213 |
+
"min_result": 100,
|
| 214 |
+
"best_result": 0,
|
| 215 |
+
"best_model_id": "",
|
| 216 |
+
"passed_": False
|
| 217 |
},
|
| 218 |
]
|
| 219 |
for unit in results_certification:
|
| 220 |
# Get user model
|
| 221 |
user_models = get_user_models(hf_username, unit['env'], unit['library'])
|
| 222 |
+
|
| 223 |
# Calculate the best result and get the best_model_id
|
| 224 |
best_result, best_model_id = calculate_best_result(user_models)
|
| 225 |
|
|
|
|
| 229 |
|
| 230 |
# Based on best_result do we pass the unit?
|
| 231 |
check_if_passed(unit)
|
| 232 |
+
unit["passed"] = pass_emoji(unit["passed_"])
|
| 233 |
|
| 234 |
print(results_certification)
|
| 235 |
|
| 236 |
+
df = pd.DataFrame(results_certification)
|
| 237 |
+
df = df[['passed', 'unit', 'env', 'min_result', 'best_result', 'best_model_id']]
|
| 238 |
return df
|
| 239 |
|
| 240 |
|
|
|
|
| 256 |
hf_username = gr.Textbox(placeholder="ThomasSimonini", label="Your Hugging Face Username")
|
| 257 |
#email = gr.Textbox(placeholder="[email protected]", label="Your Email (to receive your certificate)")
|
| 258 |
check_progress_button = gr.Button(value="Check my progress")
|
| 259 |
+
output = gr.components.Dataframe(value= certification(hf_username), headers=["Pass?", "Unit", "Environment", "Baseline", "Your best result", "Your best model id"], datatype=["markdown", "markdown", "markdown", "number", "number", "markdown", "bool"])
|
| 260 |
+
check_progress_button.click(fn=certification, inputs=hf_username, outputs=output)
|
| 261 |
|
| 262 |
demo.launch()
|