()
| 298 | |
| 299 | |
| 300 | def main_train(): |
| 301 | poster_dataset_path = 'assets/poster_data/Train' |
| 302 | # loop through all folders in the dataset |
| 303 | xml_files = [] |
| 304 | for folder in os.listdir(poster_dataset_path): |
| 305 | folder_path = os.path.join(poster_dataset_path, folder) |
| 306 | if os.path.isdir(folder_path): |
| 307 | # find all XML files in this folder |
| 308 | xml_files.extend(glob.glob(os.path.join(folder_path, "*.txt"))) |
| 309 | |
| 310 | all_panel_records = [] |
| 311 | for xml_file in xml_files: |
| 312 | poster_data = parse_poster_xml(xml_file) |
| 313 | # compute tp, gp, sp, rp |
| 314 | panel_attrs = compute_panel_attributes(poster_data) |
| 315 | # each panel_attrs entry is {tp, gp, sp, rp} |
| 316 | all_panel_records.extend(panel_attrs) |
| 317 | |
| 318 | all_figure_records = [] |
| 319 | for xml_path in xml_files: |
| 320 | recs = parse_poster_xml_for_figures(xml_path) |
| 321 | all_figure_records.extend(recs) |
| 322 | |
| 323 | panel_model_params = train_panel_attribute_inference(all_panel_records) |
| 324 | figure_model_params = train_figure_model(all_figure_records) |
| 325 | |
| 326 | return panel_model_params, figure_model_params |
| 327 | |
| 328 | def place_text_and_figures_exact(panel_dict, figure_model_params, section_title_height=32): |
| 329 | """ |
no test coverage detected