admin commited on
Commit
0acb356
·
1 Parent(s): 72ad8e8

add special type func & models filter

Browse files
Files changed (1) hide show
  1. vi_backbones.py +17 -2
vi_backbones.py CHANGED
@@ -4,6 +4,7 @@ import hashlib
4
  import requests
5
  import datasets
6
  from bs4 import BeautifulSoup
 
7
 
8
 
9
  _DBNAME = os.path.basename(__file__).split('.')[0]
@@ -58,11 +59,22 @@ class vi_backbones(datasets.GeneratorBasedBuilder):
58
  html = response.text
59
  return BeautifulSoup(html, 'html.parser')
60
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  def _info_on_dataset(self, m_ver, m_type, in1k_span):
62
  url_span = in1k_span.find_next_sibling('span', {'class': 's2'})
63
  size_span = url_span.find_next_sibling('span', {'class': 'mi'})
64
- if m_type == 'wide' or m_type == 'resnext':
65
- m_type = 'resnet'
66
  m_url = str(url_span.text[1:-1])
67
  input_size = int(size_span.text)
68
  m_dict = {
@@ -93,6 +105,9 @@ class vi_backbones(datasets.GeneratorBasedBuilder):
93
  div_id = str(div['id'])
94
  if div_id.__contains__('_Weights'):
95
  m_ver = div_id.split('_Weight')[0].lower()
 
 
 
96
  m_type = re.search('[a-zA-Z]+', m_ver).group(0)
97
  in1k_v1_span = div.find(
98
  'span', {'class': 'n'}, string='IMAGENET1K_V1')
 
4
  import requests
5
  import datasets
6
  from bs4 import BeautifulSoup
7
+ import torchvision.models as models
8
 
9
 
10
  _DBNAME = os.path.basename(__file__).split('.')[0]
 
59
  html = response.text
60
  return BeautifulSoup(html, 'html.parser')
61
 
62
+ def _special_type(self, m_type):
63
+ if m_type == 'wide' or m_type == 'resnext':
64
+ return 'resnet'
65
+
66
+ if m_type == 'swin':
67
+ return 'swin_transformer'
68
+
69
+ if m_type == 'inception':
70
+ return 'googlenet'
71
+
72
+ return m_type
73
+
74
  def _info_on_dataset(self, m_ver, m_type, in1k_span):
75
  url_span = in1k_span.find_next_sibling('span', {'class': 's2'})
76
  size_span = url_span.find_next_sibling('span', {'class': 'mi'})
77
+ m_type = self._special_type(m_type)
 
78
  m_url = str(url_span.text[1:-1])
79
  input_size = int(size_span.text)
80
  m_dict = {
 
105
  div_id = str(div['id'])
106
  if div_id.__contains__('_Weights'):
107
  m_ver = div_id.split('_Weight')[0].lower()
108
+ if not hasattr(models, m_ver):
109
+ continue
110
+
111
  m_type = re.search('[a-zA-Z]+', m_ver).group(0)
112
  in1k_v1_span = div.find(
113
  'span', {'class': 'n'}, string='IMAGENET1K_V1')