Skip to content

Commit

Permalink
fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
lisadunlap committed Sep 6, 2024
1 parent 5063c01 commit 3a908ab
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
17 changes: 14 additions & 3 deletions fastchat/serve/monitor/classify/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
14 changes: 10 additions & 4 deletions fastchat/serve/monitor/elo_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
}
Expand Down Expand Up @@ -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")
4 changes: 3 additions & 1 deletion fastchat/serve/monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3a908ab

Please sign in to comment.