Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -84,6 +84,10 @@ def create_gif(image_list, gif_path, duration):
|
|
84 |
# Convert numpy arrays back to PIL images
|
85 |
pil_images = [PILImage.fromarray(image) for image in image_list]
|
86 |
|
|
|
|
|
|
|
|
|
87 |
|
88 |
def save_result_file(
|
89 |
pgn_id, model_id_white, model_id_black, termination, result, auth_token, gist_id
|
@@ -238,6 +242,7 @@ def update(model_id_white, model_id_black):
|
|
238 |
pgn_moves += move_str
|
239 |
|
240 |
# Render the board to an image
|
|
|
241 |
last_move = board.peek()
|
242 |
svg = chess.svg.board(board=board, arrows=[(last_move.from_square, last_move.to_square)]).encode("utf-8")
|
243 |
png = cairosvg.svg2png(bytestring=svg)
|
@@ -354,7 +359,7 @@ def update(model_id_white, model_id_black):
|
|
354 |
gist_api = gistyc.GISTyc(auth_token=GITHUB_TOKEN)
|
355 |
response_update_data = gist_api.update_gist(file_name='chessllm_leaderboard.csv', gist_id={LEAD_GIST_ID})
|
356 |
|
357 |
-
|
358 |
|
359 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
360 |
GITHUB_TOKEN = os.environ["GITHUB_TOKEN"]
|
|
|
84 |
# Convert numpy arrays back to PIL images
|
85 |
pil_images = [PILImage.fromarray(image) for image in image_list]
|
86 |
|
87 |
+
# Save the images as a GIF
|
88 |
+
pil_images[0].save(
|
89 |
+
gif_path, save_all=True, append_images=pil_images[1:], duration=duration, loop=0
|
90 |
+
)
|
91 |
|
92 |
def save_result_file(
|
93 |
pgn_id, model_id_white, model_id_black, termination, result, auth_token, gist_id
|
|
|
242 |
pgn_moves += move_str
|
243 |
|
244 |
# Render the board to an image
|
245 |
+
|
246 |
last_move = board.peek()
|
247 |
svg = chess.svg.board(board=board, arrows=[(last_move.from_square, last_move.to_square)]).encode("utf-8")
|
248 |
png = cairosvg.svg2png(bytestring=svg)
|
|
|
359 |
gist_api = gistyc.GISTyc(auth_token=GITHUB_TOKEN)
|
360 |
response_update_data = gist_api.update_gist(file_name='chessllm_leaderboard.csv', gist_id={LEAD_GIST_ID})
|
361 |
|
362 |
+
yield file_name + ".gif"
|
363 |
|
364 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
365 |
GITHUB_TOKEN = os.environ["GITHUB_TOKEN"]
|