From 11471ad9bb5a6c4ae21b0e99a50011457127ab02 Mon Sep 17 00:00:00 2001
From: congee <35596075+congee524@users.noreply.github.com>
Date: Thu, 14 Jan 2021 14:20:02 +0800
Subject: [PATCH] update stat to classify papers (#348)

---
 configs/fp16/README.md |  2 +-
 docs/stat.py           | 27 ++++++++++++++++++++-------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/configs/fp16/README.md b/configs/fp16/README.md
index 12c7b86c..8d12e4d7 100644
--- a/configs/fp16/README.md
+++ b/configs/fp16/README.md
@@ -2,7 +2,7 @@
 
 ## Introduction
 
-[ALGORITHM]
+[OTHERS]
 
 ```latex
 @article{micikevicius2017mixed,
diff --git a/docs/stat.py b/docs/stat.py
index f123aad8..3aaf0607 100755
--- a/docs/stat.py
+++ b/docs/stat.py
@@ -1,10 +1,12 @@
 #!/usr/bin/env python
+import functools as func
 import glob
 import os.path as osp
 import re
 
+import numpy as np
+
 url_prefix = 'https://github.com/open-mmlab/mmsegmentation/blob/master/'
-titles_to_be_excluded = ['Mixed Precision Training']
 
 files = sorted(glob.glob('../configs/*/README.md'))
 
@@ -18,29 +20,40 @@ for f in files:
     with open(f, 'r') as content_file:
         content = content_file.read()
 
-    title = content.split('\n')[0].replace('#', '')
-    if title.strip() in titles_to_be_excluded:
-        continue
-
+    title = content.split('\n')[0].replace('#', '').strip()
     ckpts = set(x.lower().strip()
                 for x in re.findall(r'https?://download.*\.pth', content)
                 if 'mmsegmentation' in x)
     if len(ckpts) == 0:
         continue
 
+    _papertype = [x for x in re.findall(r'\[([A-Z]+)\]', content)]
+    assert len(_papertype) > 0
+    papertype = _papertype[0]
+
+    paper = set([(papertype, title)])
+
     titles.append(title)
     num_ckpts += len(ckpts)
     statsmsg = f"""
-\t* [{title}]({url}) ({len(ckpts)} ckpts)
+\t* [{papertype}] [{title}]({url}) ({len(ckpts)} ckpts)
 """
-    stats.append((title, ckpts, statsmsg))
+    stats.append((paper, ckpts, statsmsg))
 
+allpapers = func.reduce(lambda a, b: a.union(b), [p for p, _, _ in stats])
 msglist = '\n'.join(x for _, _, x in stats)
 
+papertypes, papercounts = np.unique([t for t, _ in allpapers],
+                                    return_counts=True)
+countstr = '\n'.join(
+    [f'   - {t}: {c}' for t, c in zip(papertypes, papercounts)])
+
 modelzoo = f"""
 # Model Zoo Statistics
 
 * Number of papers: {len(set(titles))}
+{countstr}
+
 * Number of checkpoints: {num_ckpts}
 {msglist}
 """
-- 
GitLab