|
| 1 | +#!/usr/bin/env python |
| 2 | +import os.path as osp |
| 3 | +import re |
| 4 | + |
| 5 | +# This script reads /projects/selected.txt and generate projectzoo.md |
| 6 | + |
| 7 | +files = [] |
| 8 | + |
| 9 | +project_zoo = """ |
| 10 | +# SOTA Models |
| 11 | +
|
| 12 | +Here are some selected project implementations that are not yet included in |
| 13 | +MMOCR package, but are ready to use. |
| 14 | +
|
| 15 | +""" |
| 16 | + |
| 17 | +files = open('../../projects/selected.txt').readlines() |
| 18 | + |
| 19 | +for file in files: |
| 20 | + file = file.strip() |
| 21 | + with open(osp.join('../../', file)) as f: |
| 22 | + content = f.read() |
| 23 | + |
| 24 | + # Extract title |
| 25 | + expr = '# (.*?)\n' |
| 26 | + title = re.search(expr, content).group(1) |
| 27 | + project_zoo += f'## {title}\n\n' |
| 28 | + |
| 29 | + # Locate the description |
| 30 | + expr = '## Description\n(.*?)##' |
| 31 | + description = re.search(expr, content, re.DOTALL).group(1) |
| 32 | + project_zoo += f'{description}\n' |
| 33 | + |
| 34 | + # check milestone 1 |
| 35 | + expr = r'- \[(.?)\] Milestone 1' |
| 36 | + state = re.search(expr, content, re.DOTALL).group(1) |
| 37 | + infer_state = '✔' if state == 'x' else '❌' |
| 38 | + |
| 39 | + # check milestone 2 |
| 40 | + expr = r'- \[(.?)\] Milestone 2' |
| 41 | + state = re.search(expr, content, re.DOTALL).group(1) |
| 42 | + training_state = '✔' if state == 'x' else '❌' |
| 43 | + |
| 44 | + # add table |
| 45 | + readme_link = f'https://github.com/open-mmlab/mmocr/blob/dev-1.x/{file}' |
| 46 | + project_zoo += '### Status \n' |
| 47 | + project_zoo += '| Inference | Train | README |\n' |
| 48 | + project_zoo += '| --------- | -------- | ------ |\n' |
| 49 | + project_zoo += f'|️{infer_state}|{training_state}|[link]({readme_link})|\n' |
| 50 | + |
| 51 | +with open('projectzoo.md', 'w') as f: |
| 52 | + f.write(project_zoo) |
0 commit comments