davidberenstein1957 commited on
Commit
14b802d
·
1 Parent(s): 1c9c07a

refactor: improve JSON data loading in app.py and enhance code readability by restructuring DataFrame column selection and formatting

Browse files
Files changed (2) hide show
  1. app.py +13 -4
  2. data.csv +0 -9
app.py CHANGED
@@ -13,7 +13,8 @@ abs_path = Path(__file__).parent
13
  # Load the JSONL file into a pandas DataFrame using the json library
14
  with open(abs_path / "results.jsonl", "r") as file:
15
  json_data = file.read()
16
- fixed_json_data = f"[{json_data.replace('}\n{', '},\n{')}]"
 
17
  json_data = json.loads(fixed_json_data)
18
  df = pd.DataFrame(json_data)
19
 
@@ -23,7 +24,11 @@ df["Model"] = df.apply(
23
  )
24
  df = df[
25
  ["Model", "Median Inference Time", "Price per Image"]
26
- + [col for col in df.columns.tolist() if col not in ["URL", "Model", "Median Inference Time", "Price per Image"]]
 
 
 
 
27
  ]
28
  df = df.sort_values(by="GenEval", ascending=False)
29
 
@@ -40,8 +45,12 @@ with gr.Blocks("ParityError/Interstellar", css=custom_css) as demo:
40
 
41
  with gr.Tabs():
42
  with gr.TabItem("FLUX.1 [dev] Leaderboard"):
43
- median_inference_time_min = math.floor(float(df["Median Inference Time"].min()))
44
- median_inference_time_max = math.ceil(float(df["Median Inference Time"].max()))
 
 
 
 
45
  price_per_image_min = math.floor(float(df["Price per Image"].min()))
46
  price_per_image_max = math.ceil(float(df["Price per Image"].max()))
47
  Leaderboard(
 
13
  # Load the JSONL file into a pandas DataFrame using the json library
14
  with open(abs_path / "results.jsonl", "r") as file:
15
  json_data = file.read()
16
+ partially_fixed_json_data = json_data.replace("}\n{", "},\n{")
17
+ fixed_json_data = f"[{partially_fixed_json_data}]"
18
  json_data = json.loads(fixed_json_data)
19
  df = pd.DataFrame(json_data)
20
 
 
24
  )
25
  df = df[
26
  ["Model", "Median Inference Time", "Price per Image"]
27
+ + [
28
+ col
29
+ for col in df.columns.tolist()
30
+ if col not in ["URL", "Model", "Median Inference Time", "Price per Image"]
31
+ ]
32
  ]
33
  df = df.sort_values(by="GenEval", ascending=False)
34
 
 
45
 
46
  with gr.Tabs():
47
  with gr.TabItem("FLUX.1 [dev] Leaderboard"):
48
+ median_inference_time_min = math.floor(
49
+ float(df["Median Inference Time"].min())
50
+ )
51
+ median_inference_time_max = math.ceil(
52
+ float(df["Median Inference Time"].max())
53
+ )
54
  price_per_image_min = math.floor(float(df["Price per Image"].min()))
55
  price_per_image_max = math.ceil(float(df["Price per Image"].max()))
56
  Leaderboard(
data.csv DELETED
@@ -1,9 +0,0 @@
1
- Provider,URL,GenEval,HPS (v2.1),GenAI-Bench (VQA),DrawBench (Image Reward),PartiPromts (ARNIQA),PartiPromts (ClipIQA),PartiPromts (ClipScore),PartiPromts (CMMD to Baseline),PartiPromts (Sharpness - Laplacian Variance),Median Inference Time (in s),Price per Image
2
- Baseline [Nvidia H100],https://huggingface.co/black-forest-labs/FLUX.1-dev?library=diffusers,67.98,30.36,0.74,1.0072,0.6758,0.8968,27.4,0,6833,6.88,0.025
3
- fal,https://fal.ai/models/fal-ai/flux/dev,68.72,29.97,0.7441,1.0084,0.6702,0.8967,27.61,0.008,7295,4.06,0.025
4
- Fireworks [fp8],https://fireworks.ai/models/fireworks/flux-1-dev-fp8,65.55,30.26,0.7455,0.9467,0.6639,0.8478,27.24,0.021,5625,4.66,0.014
5
- Pruna [extra juiced],https://replicate.com/prunaai/flux.1-juiced,69.9,29.86,0.7466,0.9458,0.6591,0.8887,27.6,0.029,7997,2.6,40
6
- Pruna [juiced],https://replicate.com/prunaai/flux.1-juiced,68.64,30.38,0.7408,0.9657,0.6762,0.9014,27.55,0.014,7627,3.14,48
7
- Pruna [lightly juiced],https://replicate.com/prunaai/flux.1-juiced,69.12,30.36,0.7405,0.9972,0.6789,0.9031,27.56,0.012,7849,3.57,54
8
- Replicate [go_fast],https://replicate.com/black-forest-labs/flux-dev,67.41,29.25,0.7547,0.9282,0.6356,0.8609,27.56,0.019,4872,3.38,0.025
9
- Together AI,https://www.together.ai/models/flux-1-dev,64.61,30.22,0.7339,0.9463,0.5752,0.8709,27.31,0.2,4501,3.38,0.025