From 3a908abec538956424dce5178720e269c23aa2ec Mon Sep 17 00:00:00 2001 From: lisadunlap Date: Fri, 6 Sep 2024 18:59:45 +0000 Subject: [PATCH] fixed formatting --- fastchat/serve/monitor/classify/label.py | 17 ++++++++++++++--- fastchat/serve/monitor/elo_analysis.py | 14 ++++++++++---- fastchat/serve/monitor/monitor.py | 4 +++- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/fastchat/serve/monitor/classify/label.py b/fastchat/serve/monitor/classify/label.py index e2cad489df..ac876b173c 100644 --- a/fastchat/serve/monitor/classify/label.py +++ b/fastchat/serve/monitor/classify/label.py @@ -195,7 +195,6 @@ def find_required_tasks(row): if args.wandb: wandb.init( project="arena", - entity="clipinvariance", name=config["input_file"].split("/")[-1].split(".")[0], ) @@ -356,7 +355,14 @@ def process_category_tag(df): columns = ( ["prompt", "response_a", "response_b", "tstamp", "category_tag"] if not args.vision - else ["prompt", "image", "response_a", "response_b", "tstamp", "category_tag"] + else [ + "prompt", + "image", + "response_a", + "response_b", + "tstamp", + "category_tag", + ] ) if args.vision: # # read image_path into wandb Image @@ -368,8 +374,13 @@ def is_valid_image(filepath): except Exception: print(f"Invalid image: {filepath}") return False + if args.testing: - output["image"] = output.image_path.map(lambda x: wandb.Image(x) if os.path.exists(x) and is_valid_image(x) else None) + output["image"] = output.image_path.map( + lambda x: wandb.Image(x) + if os.path.exists(x) and is_valid_image(x) + else None + ) else: output["image"] = output.image_path diff --git a/fastchat/serve/monitor/elo_analysis.py b/fastchat/serve/monitor/elo_analysis.py index c2a6ac55cf..d9564bd2fa 100644 --- a/fastchat/serve/monitor/elo_analysis.py +++ b/fastchat/serve/monitor/elo_analysis.py @@ -722,11 +722,17 @@ def pretty_print_elo_rating(rating): "exclude_preset": lambda x: not x["preset"], "no_refusal": lambda x: not x["is_refusal"], "is_captioning": lambda x: x["category_tag"]["vision_v0.1"]["is_captioning"], - "is_entity_recognition": lambda x: x["category_tag"]["vision_v0.1"]["is_entity_recognition"], + "is_entity_recognition": lambda x: x["category_tag"]["vision_v0.1"][ + "is_entity_recognition" + ], "is_ocr": lambda x: x["category_tag"]["vision_v0.1"]["is_ocr"], "is_counting": lambda x: x["category_tag"]["vision_v0.1"]["is_counting"], - "is_creative_composition": lambda x: x["category_tag"]["vision_v0.1"]["is_creative_composition"], - "is_spatial_reasoning": lambda x: x["category_tag"]["vision_v0.1"]["is_spatial_reasoning"], + "is_creative_composition": lambda x: x["category_tag"]["vision_v0.1"][ + "is_creative_composition" + ], + "is_spatial_reasoning": lambda x: x["category_tag"]["vision_v0.1"][ + "is_spatial_reasoning" + ], "if": lambda x: x["category_tag"]["if_v0.1"]["if"], "math": lambda x: x["category_tag"]["math_v0.1"]["math"], } @@ -775,5 +781,5 @@ def pretty_print_elo_rating(rating): with open(f"elo_results_{cutoff_date}.pkl", "wb") as fout: pickle.dump(results, fout) - + print(f"saved elo_results_{cutoff_date}.pkl") diff --git a/fastchat/serve/monitor/monitor.py b/fastchat/serve/monitor/monitor.py index 3f3d20beb3..75990ad7a5 100644 --- a/fastchat/serve/monitor/monitor.py +++ b/fastchat/serve/monitor/monitor.py @@ -851,7 +851,9 @@ def build_leaderboard_tab( language_categories_width, ) if elo_results_vision is not None: - vision_combined_table = get_combined_table(elo_results_vision, model_table_df) + vision_combined_table = get_combined_table( + elo_results_vision, model_table_df + ) build_category_leaderboard_tab( vision_combined_table, "Vision",