-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.py
96 lines (78 loc) · 3.12 KB
/
generate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import re
import os
import csv
from tqdm import tqdm
import functools
DIR_ROOT= os.path.dirname(os.path.abspath(__file__))
COLLECTION_CSV = os.path.join(DIR_ROOT, 'awesome-list.csv')
MD_FILE= os.path.join(DIR_ROOT, 'README.md')
HEAD = f"""# Awesome-Instruction-Prompted-Vision
[](https://github.com/sindresorhus/awesome) 
A curated list of instruction-prompted visual translation papers and resources, inspired by [awesome-image-inpainting](https://github.com/zengyh1900/Awesome-Image-Inpainting).

<table>
<tr>
<td>
<img src="assets/origin.gif" width="100%" />
<br>
<p>Original NeRF</p>
</td>
<td>
<img src="assets/desert.gif" width="100%" />
<br>
<p>"Make it look like the Namibian desert"</p>
</td>
<td>
<img src="assets/sunset.gif" width="100%" />
<br>
<p>"Make it sunset"</p>
</td>
</tr>
</table>
This `README.md` is automatically generated from [`awesome-list.csv`](awesome-list.csv).
We provide [scripts](generate.py) to automatically generate `README.md` from CSV file or vice versa.
Welcome to pull request to update or correct this collection.
"""
def csv_to_readme():
# save all data to csv file
csvfile = open(COLLECTION_CSV)
csv_reader = csv.reader(csvfile, delimiter=',')
papers = {}
# parse data from csv file
for idx, row in enumerate(csv_reader):
if idx == 0:
continue
try:
year, conf, type, title, url, code, project, _ = row
except:
print(row)
p = dict(title=title, url=url, conf=conf, year=year, project=project, code=code, type=type)
if str(type) not in papers:
papers[str(type)] = [p]
else:
papers[str(type)].append(p)
for k, v in papers.items():
papers[k].sort(key=lambda x: (x['year'], x['conf'], x['type']), reverse=True)
message = {}
# generate msg from parsed dict data
modal = ['Image', '3D', 'Video', 'Multiple']
for k,v in papers.items():
msg = f"## {k}\n"
for p in v:
msg += f"- **{p['conf']}** ({p['year']}) [{p['title']}]({p['url']})."
if p['code']:
git_user = p['code'].split('/')[-2]
git_repo = p['code'].split('/')[-1]
msg += f" []({p['code']})"
if p['project']:
msg += f" []({p['project']}) "
msg += "\n"
message[k] = msg
# write to readme
readme_content = HEAD
for y in modal:
readme_content += message[y]
with open(MD_FILE, 'w') as f:
f.write(readme_content)
if __name__ == '__main__':
csv_to_readme()