| 1018 | img.save(output_path, "PDF", resolution=200.0) |
| 1019 | |
| 1020 | def extract_images_and_sections(md): |
| 1021 | parts = re.split(r'(## [^\n]+)', md) |
| 1022 | records = [] |
| 1023 | for i in range(1, len(parts), 2): |
| 1024 | header = parts[i].strip() |
| 1025 | content = parts[i+1] |
| 1026 | # Find all image paths |
| 1027 | images = re.findall(r'!\[.*?\]\((.*?)\)', content) |
| 1028 | if images: |
| 1029 | # Remove lines that are image markdown |
| 1030 | lines = content.splitlines() |
| 1031 | cleaned = [ |
| 1032 | line for line in lines |
| 1033 | if not re.match(r'!\[.*?\]\(.*?\)', line.strip()) |
| 1034 | ] |
| 1035 | section_text = "\n".join(cleaned).strip() |
| 1036 | for img in images: |
| 1037 | records.append({ |
| 1038 | 'section': header, |
| 1039 | 'image_path': unquote(img), |
| 1040 | 'section_text': section_text |
| 1041 | }) |
| 1042 | |
| 1043 | return records |
| 1044 | |
| 1045 | def gen_eval_markdown(paper_name, poster_method, poster_path, figure_count_only=False): |
| 1046 | model_name="openai/clip-vit-base-patch32" |