gremlin97 commited on
Commit
4c99d55
Β·
1 Parent(s): bacd5ae

Refactor to use CSV files for data management

Browse files
Files changed (4) hide show
  1. app.py +22 -86
  2. data/classification.csv +16 -0
  3. data/detection.csv +16 -0
  4. data/segmentation.csv +16 -0
app.py CHANGED
@@ -1,89 +1,22 @@
1
  import gradio as gr
2
  import pandas as pd
 
3
 
4
- CLASSIFICATION_DATA = {
5
- "Model": [
6
- "ResNet-50", "ViT-Base", "Swin-T", "InceptionV3", "SqueezeNet",
7
- "ResNet-50", "ViT-Base", "Swin-T", "InceptionV3", "SqueezeNet",
8
- "ResNet-50", "ViT-Base", "Swin-T", "InceptionV3", "SqueezeNet",
9
- ],
10
- "Organization": [
11
- "Microsoft", "Google", "Microsoft", "Google", "DeepMind",
12
- "Microsoft", "Google", "Microsoft", "Google", "DeepMind",
13
- "Microsoft", "Google", "Microsoft", "Google", "DeepMind",
14
- ],
15
- "Dataset": [
16
- "DoMars16", "DoMars16", "DoMars16", "DoMars16", "DoMars16",
17
- "Atmospheric Dust", "Atmospheric Dust", "Atmospheric Dust", "Atmospheric Dust", "Atmospheric Dust",
18
- "Martian Frost", "Martian Frost", "Martian Frost", "Martian Frost", "Martian Frost",
19
- ],
20
- "Accuracy": [
21
- 92.5, 94.2, 95.8, 93.1, 89.7,
22
- 88.3, 90.1, 91.5, 89.8, 87.2,
23
- 85.6, 87.9, 88.4, 86.7, 84.3,
24
- ],
25
- "F1-Score": [
26
- 91.8, 93.5, 94.9, 92.4, 88.6,
27
- 87.5, 89.2, 90.7, 88.9, 86.3,
28
- 84.8, 86.9, 87.5, 85.8, 83.4,
29
- ],
30
- }
31
 
32
- DETECTION_DATA = {
33
- "Model": [
34
- "Faster R-CNN", "YOLOv5", "DETR", "RetinaNet", "SSD",
35
- "Faster R-CNN", "YOLOv5", "DETR", "RetinaNet", "SSD",
36
- "Faster R-CNN", "YOLOv5", "DETR", "RetinaNet", "SSD",
37
- ],
38
- "Organization": [
39
- "Meta", "Ultralytics", "Meta", "Meta", "Google",
40
- "Meta", "Ultralytics", "Meta", "Meta", "Google",
41
- "Meta", "Ultralytics", "Meta", "Meta", "Google",
42
- ],
43
- "Dataset": [
44
- "Mars Crater", "Mars Crater", "Mars Crater", "Mars Crater", "Mars Crater",
45
- "Rover Component", "Rover Component", "Rover Component", "Rover Component", "Rover Component",
46
- "Geological Feature", "Geological Feature", "Geological Feature", "Geological Feature", "Geological Feature",
47
- ],
48
- "mAP": [
49
- 78.5, 80.2, 82.1, 79.3, 77.8,
50
- 75.6, 77.3, 78.9, 76.7, 75.1,
51
- 73.4, 75.1, 76.7, 74.5, 73.0,
52
- ],
53
- "IoU": [
54
- 0.72, 0.74, 0.76, 0.73, 0.71,
55
- 0.69, 0.71, 0.73, 0.70, 0.68,
56
- 0.67, 0.69, 0.71, 0.68, 0.67,
57
- ],
58
- }
59
 
60
- SEGMENTATION_DATA = {
61
- "Model": [
62
- "U-Net", "DeepLabV3+", "Mask R-CNN", "SegFormer", "HRNet",
63
- "U-Net", "DeepLabV3+", "Mask R-CNN", "SegFormer", "HRNet",
64
- "U-Net", "DeepLabV3+", "Mask R-CNN", "SegFormer", "HRNet",
65
- ],
66
- "Organization": [
67
- "OpenAI", "Google", "Meta", "NVIDIA", "Microsoft",
68
- "OpenAI", "Google", "Meta", "NVIDIA", "Microsoft",
69
- "OpenAI", "Google", "Meta", "NVIDIA", "Microsoft",
70
- ],
71
- "Dataset": [
72
- "Mars Terrain", "Mars Terrain", "Mars Terrain", "Mars Terrain", "Mars Terrain",
73
- "Dust Storm", "Dust Storm", "Dust Storm", "Dust Storm", "Dust Storm",
74
- "Geological Feature", "Geological Feature", "Geological Feature", "Geological Feature", "Geological Feature",
75
- ],
76
- "Dice Score": [
77
- 0.85, 0.87, 0.88, 0.86, 0.84,
78
- 0.82, 0.84, 0.85, 0.83, 0.82,
79
- 0.81, 0.83, 0.84, 0.82, 0.81,
80
- ],
81
- "IoU": [
82
- 0.74, 0.76, 0.78, 0.75, 0.73,
83
- 0.70, 0.72, 0.74, 0.71, 0.70,
84
- 0.68, 0.70, 0.72, 0.69, 0.68,
85
- ],
86
- }
87
 
88
 
89
  def filter_and_search(df, search, datasets, models, organizations, columns):
@@ -107,8 +40,11 @@ def filter_and_search(df, search, datasets, models, organizations, columns):
107
  return filtered
108
 
109
 
110
- def build_tab(data, name):
111
- df = pd.DataFrame(data)
 
 
 
112
  datasets = sorted(df["Dataset"].unique().tolist())
113
  models = sorted(df["Model"].unique().tolist())
114
  organizations = sorted(df["Organization"].unique().tolist())
@@ -240,9 +176,9 @@ with demo:
240
  gr.Markdown(INTRO, elem_classes="markdown-text")
241
 
242
  with gr.Tabs(elem_classes="tab-buttons"):
243
- build_tab(CLASSIFICATION_DATA, "πŸ… Classification")
244
- build_tab(SEGMENTATION_DATA, "πŸ… Segmentation")
245
- build_tab(DETECTION_DATA, "πŸ… Object Detection")
246
 
247
  with gr.TabItem("πŸ“ Submit", elem_id="submit-tab"):
248
  gr.Markdown("""
 
1
  import gradio as gr
2
  import pandas as pd
3
+ import os
4
 
5
+ # Load data from CSV files
6
+ DATA_DIR = "data"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
+ def load_csv_data(filename):
9
+ """Load data from CSV file"""
10
+ filepath = os.path.join(DATA_DIR, filename)
11
+ if os.path.exists(filepath):
12
+ return pd.read_csv(filepath)
13
+ else:
14
+ return pd.DataFrame()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ # Load datasets
17
+ CLASSIFICATION_DF = load_csv_data("classification.csv")
18
+ DETECTION_DF = load_csv_data("detection.csv")
19
+ SEGMENTATION_DF = load_csv_data("segmentation.csv")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
 
22
  def filter_and_search(df, search, datasets, models, organizations, columns):
 
40
  return filtered
41
 
42
 
43
+ def build_tab(df, name):
44
+ """Build a leaderboard tab from a DataFrame"""
45
+ if df.empty:
46
+ return gr.TabItem(name)
47
+
48
  datasets = sorted(df["Dataset"].unique().tolist())
49
  models = sorted(df["Model"].unique().tolist())
50
  organizations = sorted(df["Organization"].unique().tolist())
 
176
  gr.Markdown(INTRO, elem_classes="markdown-text")
177
 
178
  with gr.Tabs(elem_classes="tab-buttons"):
179
+ build_tab(CLASSIFICATION_DF, "πŸ… Classification")
180
+ build_tab(SEGMENTATION_DF, "πŸ… Segmentation")
181
+ build_tab(DETECTION_DF, "πŸ… Object Detection")
182
 
183
  with gr.TabItem("πŸ“ Submit", elem_id="submit-tab"):
184
  gr.Markdown("""
data/classification.csv ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Model,Organization,Dataset,Accuracy,F1-Score
2
+ ResNet-50,Microsoft,DoMars16,92.5,91.8
3
+ ViT-Base,Google,DoMars16,94.2,93.5
4
+ Swin-T,Microsoft,DoMars16,95.8,94.9
5
+ InceptionV3,Google,DoMars16,93.1,92.4
6
+ SqueezeNet,DeepMind,DoMars16,89.7,88.6
7
+ ResNet-50,Microsoft,Atmospheric Dust,88.3,87.5
8
+ ViT-Base,Google,Atmospheric Dust,90.1,89.2
9
+ Swin-T,Microsoft,Atmospheric Dust,91.5,90.7
10
+ InceptionV3,Google,Atmospheric Dust,89.8,88.9
11
+ SqueezeNet,DeepMind,Atmospheric Dust,87.2,86.3
12
+ ResNet-50,Microsoft,Martian Frost,85.6,84.8
13
+ ViT-Base,Google,Martian Frost,87.9,86.9
14
+ Swin-T,Microsoft,Martian Frost,88.4,87.5
15
+ InceptionV3,Google,Martian Frost,86.7,85.8
16
+ SqueezeNet,DeepMind,Martian Frost,84.3,83.4
data/detection.csv ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Model,Organization,Dataset,mAP,IoU
2
+ Faster R-CNN,Meta,Mars Crater,78.5,0.72
3
+ YOLOv5,Ultralytics,Mars Crater,80.2,0.74
4
+ DETR,Meta,Mars Crater,82.1,0.76
5
+ RetinaNet,Meta,Mars Crater,79.3,0.73
6
+ SSD,Google,Mars Crater,77.8,0.71
7
+ Faster R-CNN,Meta,Rover Component,75.6,0.69
8
+ YOLOv5,Ultralytics,Rover Component,77.3,0.71
9
+ DETR,Meta,Rover Component,78.9,0.73
10
+ RetinaNet,Meta,Rover Component,76.7,0.70
11
+ SSD,Google,Rover Component,75.1,0.68
12
+ Faster R-CNN,Meta,Geological Feature,73.4,0.67
13
+ YOLOv5,Ultralytics,Geological Feature,75.1,0.69
14
+ DETR,Meta,Geological Feature,76.7,0.71
15
+ RetinaNet,Meta,Geological Feature,74.5,0.68
16
+ SSD,Google,Geological Feature,73.0,0.67
data/segmentation.csv ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Model,Organization,Dataset,Dice Score,IoU
2
+ U-Net,OpenAI,Mars Terrain,0.85,0.74
3
+ DeepLabV3+,Google,Mars Terrain,0.87,0.76
4
+ Mask R-CNN,Meta,Mars Terrain,0.88,0.78
5
+ SegFormer,NVIDIA,Mars Terrain,0.86,0.75
6
+ HRNet,Microsoft,Mars Terrain,0.84,0.73
7
+ U-Net,OpenAI,Dust Storm,0.82,0.70
8
+ DeepLabV3+,Google,Dust Storm,0.84,0.72
9
+ Mask R-CNN,Meta,Dust Storm,0.85,0.74
10
+ SegFormer,NVIDIA,Dust Storm,0.83,0.71
11
+ HRNet,Microsoft,Dust Storm,0.82,0.70
12
+ U-Net,OpenAI,Geological Feature,0.81,0.68
13
+ DeepLabV3+,Google,Geological Feature,0.83,0.70
14
+ Mask R-CNN,Meta,Geological Feature,0.84,0.72
15
+ SegFormer,NVIDIA,Geological Feature,0.82,0.69
16
+ HRNet,Microsoft,Geological Feature,0.81,0.68