1use crate::request;
5use std::path::Path;
6
7pub enum BenchmarkDatasets {
14 Amgad2022,
15 Cnmc2019,
16 Fracatlas2023,
17 Isic2019,
18 Kermany2018,
19 Kromp2023,
20 Matek2021,
21 Murphy2001,
22 Opencell2024,
23 Phillip2021,
24 Recursion2019,
25 Verma2021,
26 Runtime,
27}
28
29impl BenchmarkDatasets {
30 pub fn select(name: &str) -> Self {
32 match name {
33 "amgad_2022" => BenchmarkDatasets::Amgad2022,
34 "cnmc_2019" => BenchmarkDatasets::Cnmc2019,
35 "fracatlas_2023" => BenchmarkDatasets::Fracatlas2023,
36 "isic_2019" => BenchmarkDatasets::Isic2019,
37 "kermany_2018" => BenchmarkDatasets::Kermany2018,
38 "kromp_2023" => BenchmarkDatasets::Kromp2023,
39 "matek_2021" => BenchmarkDatasets::Matek2021,
40 "murphy_2001" => BenchmarkDatasets::Murphy2001,
41 "opencell_2024" => BenchmarkDatasets::Opencell2024,
42 "phillip_2021" => BenchmarkDatasets::Phillip2021,
43 "recursion_2019" => BenchmarkDatasets::Recursion2019,
44 "verma_2021" => BenchmarkDatasets::Verma2021,
45 "runtime" => BenchmarkDatasets::Runtime,
46 _ => {
47 let msg = format!(
48 "[pineapple::data::benchmark] Dataset {} not found. Avalaible benchmark datasets include: {}",
49 name,
50 "amgad_2022, cnmc_2019, fracatlas_2023, isic_2019, kermany_2018, kromp_2023, matek_2021, murphy_2001, opencell_2024, phillip_2021, recursion_2019, verma_2021, runtime."
51 );
52 eprintln!("{}", msg);
53 std::process::exit(1);
54 }
55 }
56 }
57
58 pub fn iter() -> impl Iterator<Item = &'static BenchmarkDatasets> {
60 static BENCHMARKS: [BenchmarkDatasets; 13] = [
61 BenchmarkDatasets::Amgad2022,
62 BenchmarkDatasets::Cnmc2019,
63 BenchmarkDatasets::Fracatlas2023,
64 BenchmarkDatasets::Isic2019,
65 BenchmarkDatasets::Kermany2018,
66 BenchmarkDatasets::Kromp2023,
67 BenchmarkDatasets::Matek2021,
68 BenchmarkDatasets::Murphy2001,
69 BenchmarkDatasets::Opencell2024,
70 BenchmarkDatasets::Phillip2021,
71 BenchmarkDatasets::Recursion2019,
72 BenchmarkDatasets::Verma2021,
73 BenchmarkDatasets::Runtime,
74 ];
75
76 BENCHMARKS.iter()
77 }
78
79 pub fn name(&self) -> &str {
81 match self {
82 BenchmarkDatasets::Amgad2022 => "amgad_2022",
83 BenchmarkDatasets::Cnmc2019 => "cnmc_2019",
84 BenchmarkDatasets::Fracatlas2023 => "fracatlas_2023",
85 BenchmarkDatasets::Isic2019 => "isic_2019",
86 BenchmarkDatasets::Kermany2018 => "kermany_2018",
87 BenchmarkDatasets::Kromp2023 => "kromp_2023",
88 BenchmarkDatasets::Matek2021 => "matek_2021",
89 BenchmarkDatasets::Murphy2001 => "murphy_2001",
90 BenchmarkDatasets::Opencell2024 => "opencell_2024",
91 BenchmarkDatasets::Phillip2021 => "phillip_2021",
92 BenchmarkDatasets::Recursion2019 => "recursion_2019",
93 BenchmarkDatasets::Verma2021 => "verma_2021",
94 BenchmarkDatasets::Runtime => "runtime",
95 }
96 }
97
98 pub fn file_id(&self) -> &str {
100 match self {
101 BenchmarkDatasets::Amgad2022 => "1JHlGon82bYPhpeOwbRYxz4uRxhcxasr3",
102 BenchmarkDatasets::Cnmc2019 => "1a7Wt0kwt3Uq1NKMtBsWmesMH4tCwqkgi",
103 BenchmarkDatasets::Fracatlas2023 => "1vyXNA4bxMFk-7Hw59TPiWIfX-BzTSmCd",
104 BenchmarkDatasets::Isic2019 => "1CDGbcBxs7SUemGwpBtoVYJblqCNgw469",
105 BenchmarkDatasets::Kermany2018 => "1Xk7LWa7HWzTN7Nxsa8MuefBmzNsz4VuM",
106 BenchmarkDatasets::Kromp2023 => "16RXNWQXlw_scJ75DwowngxJHYB2rZsW7",
107 BenchmarkDatasets::Matek2021 => "1BDYtZoqSUUZQmWgcEBtopaJTWgwrAXGz",
108 BenchmarkDatasets::Murphy2001 => "1fl4dwbjX11SpDRhwbIi2-lbcswvyr1F_",
109 BenchmarkDatasets::Opencell2024 => "1nlqt7ujUPciEoAKriIu_bqE5fUJZX4nx",
110 BenchmarkDatasets::Phillip2021 => "1yE4BblXBAPJDT1AnK3gghHAS3cZUFCd6",
111 BenchmarkDatasets::Recursion2019 => "1209hlaKcOqKdEGOwvlRhJakX8ciN-SX8",
112 BenchmarkDatasets::Verma2021 => "1AyU-4-doJY2GX3dmf7ryPDCvDA_x4PPD",
113 BenchmarkDatasets::Runtime => "1BlXIv49oxj2dsiiEASbTEiyh7QpIjYb_",
114 }
115 }
116
117 pub fn license(&self) -> &str {
119 match self {
120 BenchmarkDatasets::Amgad2022 => "CC0 1.0",
121 BenchmarkDatasets::Cnmc2019 => "CC BY 3.0",
122 BenchmarkDatasets::Fracatlas2023 => "CC BY 4.0",
123 BenchmarkDatasets::Isic2019 => "CC BY-NC 4.0",
124 BenchmarkDatasets::Kermany2018 => "CC BY 4.0",
125 BenchmarkDatasets::Kromp2023 => "CC BY 4.0",
126 BenchmarkDatasets::Matek2021 => "CC BY 4.0",
127 BenchmarkDatasets::Murphy2001 => "MIT",
128 BenchmarkDatasets::Opencell2024 => "MIT",
129 BenchmarkDatasets::Phillip2021 => "MIT",
130 BenchmarkDatasets::Recursion2019 => "CC BY-NC-SA 4.0",
131 BenchmarkDatasets::Verma2021 => "CC BY-NC-SA 4.0",
132 BenchmarkDatasets::Runtime => "MIT",
133 }
134 }
135
136 pub fn data_authors(&self) -> &str {
138 match self {
139 BenchmarkDatasets::Amgad2022 => "Amgad et al. 2022",
140 BenchmarkDatasets::Cnmc2019 => "C-NMC Challenge",
141 BenchmarkDatasets::Fracatlas2023 => "Abedeen et al. 2023",
142 BenchmarkDatasets::Isic2019 => "ISIC",
143 BenchmarkDatasets::Kermany2018 => "Kermany et al. 2018",
144 BenchmarkDatasets::Kromp2023 => "Kromp et al. 2023",
145 BenchmarkDatasets::Matek2021 => "Matek et al. 2021",
146 BenchmarkDatasets::Murphy2001 => "Murphy et al. 2001",
147 BenchmarkDatasets::Opencell2024 => "OpenCell",
148 BenchmarkDatasets::Phillip2021 => "Phillip et al. 2021",
149 BenchmarkDatasets::Recursion2019 => "Recursion",
150 BenchmarkDatasets::Verma2021 => "Verma et al. 2021",
151 BenchmarkDatasets::Runtime => "MIT",
152 }
153 }
154
155 pub fn data_size(&self) -> &str {
157 match self {
158 BenchmarkDatasets::Amgad2022 => "0.062",
159 BenchmarkDatasets::Cnmc2019 => "0.182",
160 BenchmarkDatasets::Fracatlas2023 => "0.247",
161 BenchmarkDatasets::Isic2019 => "1.140",
162 BenchmarkDatasets::Kermany2018 => "0.638",
163 BenchmarkDatasets::Kromp2023 => "0.025",
164 BenchmarkDatasets::Matek2021 => "0.508",
165 BenchmarkDatasets::Murphy2001 => "0.033",
166 BenchmarkDatasets::Opencell2024 => "1.030",
167 BenchmarkDatasets::Phillip2021 => "0.032",
168 BenchmarkDatasets::Recursion2019 => "0.037",
169 BenchmarkDatasets::Verma2021 => "0.021",
170 BenchmarkDatasets::Runtime => "0.017",
171 }
172 }
173
174 pub fn download(&self, output: &Path, verbose: bool) {
176 let filename = format!("{}.tar.gz", self.name().replace("_", "-"));
177
178 if !output.join(&filename).exists() {
179 request::download_file(self.file_id(), output, &filename, !verbose).unwrap();
180
181 if !output.join(&filename).exists() {
182 eprintln!("[pineapple::data::benchmark] Failed to download benchmark dataset.");
183 std::process::exit(1);
184 }
185 }
186 }
187}