AlexNijjar
commited on
Commit
•
6b0d74c
1
Parent(s):
934f7cd
Expend area and clean up
Browse files
app.py
CHANGED
@@ -39,7 +39,7 @@ GRAPH_HISTORY_DAYS = 30
|
|
39 |
MAX_GRAPH_ENTRIES = 10
|
40 |
|
41 |
wandb_api = wandb.Api()
|
42 |
-
demo = gr.Blocks(css=".typewriter {font-family: 'JMH Typewriter', sans-serif;}")
|
43 |
runs: dict[int, list[Run]] = {}
|
44 |
|
45 |
|
@@ -47,7 +47,7 @@ runs: dict[int, list[Run]] = {}
|
|
47 |
class LeaderboardEntry:
|
48 |
uid: int
|
49 |
winner: bool
|
50 |
-
|
51 |
score: float
|
52 |
similarity: float
|
53 |
hotkey: str
|
@@ -194,7 +194,7 @@ def create_leaderboard(runs: list[Run]) -> list[tuple]:
|
|
194 |
entries[uid] = LeaderboardEntry(
|
195 |
uid=uid,
|
196 |
winner="winner" in value,
|
197 |
-
|
198 |
score=calculate_score(baseline_generation_time, generation_time, similarity),
|
199 |
similarity=similarity,
|
200 |
baseline_generation_time=baseline_generation_time,
|
@@ -211,7 +211,7 @@ def create_leaderboard(runs: list[Run]) -> list[tuple]:
|
|
211 |
return [(
|
212 |
entry.uid,
|
213 |
f"<span style='color: {'springgreen' if entry.winner else 'red'}'>{entry.winner}</span>",
|
214 |
-
entry.
|
215 |
round(entry.score, 3),
|
216 |
f"{entry.generation_time:.3f}s",
|
217 |
f"{entry.similarity:.3f}",
|
@@ -251,25 +251,20 @@ def fetch_wandb_data():
|
|
251 |
runs = dict(sorted(runs.items(), key=lambda item: item[0]))
|
252 |
|
253 |
|
254 |
-
def get_choices() -> list[str]:
|
255 |
-
choices = []
|
256 |
for uid, run in runs.items():
|
257 |
hotkey = run[0].config["hotkey"]
|
|
|
|
|
|
|
258 |
if hotkey in HOTKEYS_TO_KNOWN_VALIDATORS:
|
259 |
-
choices.append(f"{uid} - {HOTKEYS_TO_KNOWN_VALIDATORS[hotkey]}")
|
260 |
else:
|
261 |
-
choices.append(str(f"{uid} - {hotkey}"))
|
262 |
return choices
|
263 |
|
264 |
|
265 |
-
def get_default_choice() -> str:
|
266 |
-
return f"{SOURCE_VALIDATOR_UID} - {HOTKEYS_TO_KNOWN_VALIDATORS[runs[SOURCE_VALIDATOR_UID][0].config['hotkey']]}"
|
267 |
-
|
268 |
-
|
269 |
-
def parse_uid(choice: str) -> int:
|
270 |
-
return int(choice[:choice.index(" ")])
|
271 |
-
|
272 |
-
|
273 |
def refresh():
|
274 |
fetch_wandb_data()
|
275 |
demo.clear()
|
@@ -283,6 +278,7 @@ def refresh():
|
|
283 |
interactive=False,
|
284 |
show_fullscreen_button=False,
|
285 |
show_share_button=False,
|
|
|
286 |
)
|
287 |
|
288 |
gr.Markdown(
|
@@ -297,24 +293,24 @@ def refresh():
|
|
297 |
with gr.Accordion(f"Contest #1 Submission Leader: New Dream SDXL on NVIDIA RTX 4090s (Last updated: {now.strftime('%Y-%m-%d %I:%M:%S %p')} EST)"):
|
298 |
dropdown = gr.Dropdown(
|
299 |
get_choices(),
|
300 |
-
value=
|
301 |
interactive=True,
|
302 |
label="Source Validator"
|
303 |
)
|
304 |
|
305 |
-
graph = gr.Plot()
|
306 |
|
307 |
leaderboard = gr.components.Dataframe(
|
308 |
-
create_leaderboard(runs[
|
309 |
headers=["Uid", "Winner", "Model", "Score", "Gen Time", "Similarity", "Size", "VRAM Usage", "Power Usage", "Hotkey"],
|
310 |
datatype=["number", "markdown", "markdown", "number", "markdown", "number", "markdown", "markdown", "markdown", "markdown"],
|
311 |
elem_id="leaderboard-table",
|
312 |
)
|
313 |
|
314 |
-
|
|
|
315 |
|
316 |
-
dropdown.change(lambda uid: create_graph(runs[
|
317 |
-
dropdown.change(lambda uid: create_leaderboard(runs[
|
318 |
|
319 |
|
320 |
if __name__ == "__main__":
|
|
|
39 |
MAX_GRAPH_ENTRIES = 10
|
40 |
|
41 |
wandb_api = wandb.Api()
|
42 |
+
demo = gr.Blocks(css=".typewriter {font-family: 'JMH Typewriter', sans-serif;}", fill_height=True, fill_width=True)
|
43 |
runs: dict[int, list[Run]] = {}
|
44 |
|
45 |
|
|
|
47 |
class LeaderboardEntry:
|
48 |
uid: int
|
49 |
winner: bool
|
50 |
+
repository: str
|
51 |
score: float
|
52 |
similarity: float
|
53 |
hotkey: str
|
|
|
194 |
entries[uid] = LeaderboardEntry(
|
195 |
uid=uid,
|
196 |
winner="winner" in value,
|
197 |
+
repository=run.summary["submissions"][str(uid)]["repository"],
|
198 |
score=calculate_score(baseline_generation_time, generation_time, similarity),
|
199 |
similarity=similarity,
|
200 |
baseline_generation_time=baseline_generation_time,
|
|
|
211 |
return [(
|
212 |
entry.uid,
|
213 |
f"<span style='color: {'springgreen' if entry.winner else 'red'}'>{entry.winner}</span>",
|
214 |
+
entry.repository,
|
215 |
round(entry.score, 3),
|
216 |
f"{entry.generation_time:.3f}s",
|
217 |
f"{entry.similarity:.3f}",
|
|
|
251 |
runs = dict(sorted(runs.items(), key=lambda item: item[0]))
|
252 |
|
253 |
|
254 |
+
def get_choices() -> list[tuple[str, int]]:
|
255 |
+
choices: list[tuple[str, int]] = []
|
256 |
for uid, run in runs.items():
|
257 |
hotkey = run[0].config["hotkey"]
|
258 |
+
benchmarks = dict(run[0].summary.get("benchmarks", {}))
|
259 |
+
finished = any("winner" in value for value in benchmarks.values())
|
260 |
+
progress_text = "Finished" if finished else "In Progress"
|
261 |
if hotkey in HOTKEYS_TO_KNOWN_VALIDATORS:
|
262 |
+
choices.append((f"{uid} - {HOTKEYS_TO_KNOWN_VALIDATORS[hotkey]} ({progress_text})", uid))
|
263 |
else:
|
264 |
+
choices.append((str(f"{uid} - {hotkey}"), uid))
|
265 |
return choices
|
266 |
|
267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
def refresh():
|
269 |
fetch_wandb_data()
|
270 |
demo.clear()
|
|
|
278 |
interactive=False,
|
279 |
show_fullscreen_button=False,
|
280 |
show_share_button=False,
|
281 |
+
container=False,
|
282 |
)
|
283 |
|
284 |
gr.Markdown(
|
|
|
293 |
with gr.Accordion(f"Contest #1 Submission Leader: New Dream SDXL on NVIDIA RTX 4090s (Last updated: {now.strftime('%Y-%m-%d %I:%M:%S %p')} EST)"):
|
294 |
dropdown = gr.Dropdown(
|
295 |
get_choices(),
|
296 |
+
value=SOURCE_VALIDATOR_UID,
|
297 |
interactive=True,
|
298 |
label="Source Validator"
|
299 |
)
|
300 |
|
|
|
301 |
|
302 |
leaderboard = gr.components.Dataframe(
|
303 |
+
create_leaderboard(runs[dropdown.value]),
|
304 |
headers=["Uid", "Winner", "Model", "Score", "Gen Time", "Similarity", "Size", "VRAM Usage", "Power Usage", "Hotkey"],
|
305 |
datatype=["number", "markdown", "markdown", "number", "markdown", "number", "markdown", "markdown", "markdown", "markdown"],
|
306 |
elem_id="leaderboard-table",
|
307 |
)
|
308 |
|
309 |
+
graph = gr.Plot()
|
310 |
+
demo.load(lambda uid: create_graph(runs[uid]), [dropdown], [graph])
|
311 |
|
312 |
+
dropdown.change(lambda uid: create_graph(runs[uid]), [dropdown], [graph])
|
313 |
+
dropdown.change(lambda uid: create_leaderboard(runs[uid]), [dropdown], [leaderboard])
|
314 |
|
315 |
|
316 |
if __name__ == "__main__":
|