Best Python code snippet using slash
road_signs_old_with_many_class.py
Source:road_signs_old_with_many_class.py
...72 dataset_dir: Root directory of the dataset.73 subset: Subset to load: train or val74 """75 # Add classes. We have only one class to add.76 # self.add_class("road_signs", 1, "road_sign")77 # self.add_class("road_signs", 2, "error")78 # self.add_class("road_signs", 3, "3")79 # self.add_class("road_signs", 4, "4")80 self.add_class("road_signs", 1, "1.1")81 self.add_class("road_signs", 2, "1.11")82 self.add_class("road_signs", 3, "1.12")83 self.add_class("road_signs", 4, "1.13")84 self.add_class("road_signs", 5, "1.19")85 self.add_class("road_signs", 6, "1.2")86 self.add_class("road_signs", 7, "1.20")87 self.add_class("road_signs", 8, "1.22")88 self.add_class("road_signs", 9, "1.23.1")89 self.add_class("road_signs", 10, "1.24")90 self.add_class("road_signs", 11, "1.25")91 self.add_class("road_signs", 12, "1.26")92 self.add_class("road_signs", 13, "1.27")93 self.add_class("road_signs", 14, "1.28")94 self.add_class("road_signs", 15, "1.29")95 self.add_class("road_signs", 16, "1.30")96 self.add_class("road_signs", 17, "1.3.1")97 self.add_class("road_signs", 18, "1.32")98 self.add_class("road_signs", 19, "1.33")99 self.add_class("road_signs", 20, "1.34")100 self.add_class("road_signs", 21, "1.37")101 self.add_class("road_signs", 22, "1.39")102 self.add_class("road_signs", 23, "1.4.1")103 self.add_class("road_signs", 24, "1.4.2")104 self.add_class("road_signs", 25, "1.4.3")105 self.add_class("road_signs", 26, "1.5.2")106 self.add_class("road_signs", 27, "1.5.3")107 self.add_class("road_signs", 28, "1.6")108 self.add_class("road_signs", 29, "1.7")109 self.add_class("road_signs", 30, "2.1")110 self.add_class("road_signs", 31, "2.2")111 self.add_class("road_signs", 32, "2.3")112 self.add_class("road_signs", 33, "2.4")113 self.add_class("road_signs", 34, "2.5")114 self.add_class("road_signs", 35, "2.6")115 self.add_class("road_signs", 36, "3.1")116 self.add_class("road_signs", 37, "3.12")117 self.add_class("road_signs", 38, "3.14")118 self.add_class("road_signs", 39, "3.15")119 self.add_class("road_signs", 40, "3.18")120 self.add_class("road_signs", 41, "3.2")121 self.add_class("road_signs", 42, "3.21")122 self.add_class("road_signs", 43, "3.22")123 self.add_class("road_signs", 44, "3.23")124 self.add_class("road_signs", 45, "3.24")125 self.add_class("road_signs", 46, "3.27")126 self.add_class("road_signs", 47, "3.29")127 self.add_class("road_signs", 48, "3.3")128 self.add_class("road_signs", 49, "3.30")129 self.add_class("road_signs", 50, "3.31")130 self.add_class("road_signs", 51, "3.32")131 self.add_class("road_signs", 52, "3.33")132 self.add_class("road_signs", 53, "3.34")133 self.add_class("road_signs", 54, "3.35")134 self.add_class("road_signs", 55, "3.36")135 self.add_class("road_signs", 56, "3.37")136 self.add_class("road_signs", 57, "3.38")137 self.add_class("road_signs", 58, "3.39")138 self.add_class("road_signs", 59, "3.4")139 self.add_class("road_signs", 60, "3.41")140 self.add_class("road_signs", 61, "3.42")141 self.add_class("road_signs", 62, "3.9")142 self.add_class("road_signs", 63, "4.1")143 self.add_class("road_signs", 64, "4.10")144 self.add_class("road_signs", 65, "4.11")145 self.add_class("road_signs", 66, "4.12")146 self.add_class("road_signs", 67, "4.13")147 self.add_class("road_signs", 68, "4.14")148 self.add_class("road_signs", 69, "4.2")149 self.add_class("road_signs", 70, "4.21")150 self.add_class("road_signs", 71, "4.22")151 self.add_class("road_signs", 72, "4.3")152 self.add_class("road_signs", 73, "4.4")153 self.add_class("road_signs", 74, "4.5")154 self.add_class("road_signs", 75, "4.6")155 self.add_class("road_signs", 76, "4.7")156 self.add_class("road_signs", 77, "4.8")157 self.add_class("road_signs", 78, "4.9")158 self.add_class("road_signs", 79, "5.10.1")159 self.add_class("road_signs", 80, "5.10.2")160 self.add_class("road_signs", 81, "5.10.3")161 self.add_class("road_signs", 82, "5.11")162 self.add_class("road_signs", 83, "5.12")163 self.add_class("road_signs", 84, "5.16")164 self.add_class("road_signs", 85, "5.17.1")165 self.add_class("road_signs", 86, "5.17.2")166 self.add_class("road_signs", 87, "5.18")167 self.add_class("road_signs", 88, "5.19")168 self.add_class("road_signs", 89, "5.20.1")169 self.add_class("road_signs", 90, "5.20.3")170 self.add_class("road_signs", 91, "5.21.1")171 self.add_class("road_signs", 92, "5.21.2")172 self.add_class("road_signs", 93, "5.26")173 self.add_class("road_signs", 94, "5.27")174 self.add_class("road_signs", 95, "5.29.1")175 self.add_class("road_signs", 96, "5.29.2")176 self.add_class("road_signs", 97, "5.29.3")177 self.add_class("road_signs", 98, "5.30")178 self.add_class("road_signs", 99, "5.31")179 self.add_class("road_signs", 100, "5.32")180 self.add_class("road_signs", 101, "5.33")181 self.add_class("road_signs", 102, "5.35.1")182 self.add_class("road_signs", 103, "5.35.2")183 self.add_class("road_signs", 104, "5.36.1")184 self.add_class("road_signs", 105, "5.36.2")185 self.add_class("road_signs", 106, "5.37.1")186 self.add_class("road_signs", 107, "5.37.2")187 self.add_class("road_signs", 108, "5.38")188 self.add_class("road_signs", 109, "5.39")189 self.add_class("road_signs", 110, "5.40")190 self.add_class("road_signs", 111, "5.41.1")191 self.add_class("road_signs", 112, "5.41.2")192 self.add_class("road_signs", 113, "5.42.1")193 self.add_class("road_signs", 114, "5.42.2")194 self.add_class("road_signs", 115, "5.43.1")195 self.add_class("road_signs", 116, "5.43.2")196 self.add_class("road_signs", 117, "5.5")197 self.add_class("road_signs", 118, "5.54")198 self.add_class("road_signs", 119, "5.6")199 self.add_class("road_signs", 120, "5.60")200 self.add_class("road_signs", 121, "5.62")201 self.add_class("road_signs", 122, "5.64")202 self.add_class("road_signs", 123, "5.70")203 self.add_class("road_signs", 124, "5.7.1")204 self.add_class("road_signs", 125, "5.7.2")205 self.add_class("road_signs", 126, "6.1")206 self.add_class("road_signs", 127, "6.11")207 self.add_class("road_signs", 128, "6.16")208 self.add_class("road_signs", 129, "6.5")209 self.add_class("road_signs", 130, "6.6")210 self.add_class("road_signs", 131, "6.7.1")211 self.add_class("road_signs", 132, "6.7.2")212 self.add_class("road_signs", 133, "6.8")213 self.add_class("road_signs", 134, "7.1.1")214 self.add_class("road_signs", 135, "7.12")215 self.add_class("road_signs", 136, "7.13")216 self.add_class("road_signs", 137, "7.1.3")217 self.add_class("road_signs", 138, "7.14")218 self.add_class("road_signs", 139, "7.1.4")219 self.add_class("road_signs", 140, "7.16")220 self.add_class("road_signs", 141, "7.17")221 self.add_class("road_signs", 142, "7.18")222 self.add_class("road_signs", 143, "7.2.1")223 self.add_class("road_signs", 144, "7.2.2")224 self.add_class("road_signs", 145, "7.2.3")225 self.add_class("road_signs", 146, "7.2.4")226 self.add_class("road_signs", 147, "7.2.5")227 self.add_class("road_signs", 148, "7.2.6")228 self.add_class("road_signs", 149, "7.3.1")229 self.add_class("road_signs", 150, "7.3.2")230 self.add_class("road_signs", 151, "7.3.3")231 self.add_class("road_signs", 152, "7.4.1")232 self.add_class("road_signs", 153, "7.4.4")233 self.add_class("road_signs", 154, "7.4.6")234 self.add_class("road_signs", 155, "7.4.7")235 self.add_class("road_signs", 156, "7.5.1")236 self.add_class("road_signs", 157, "7.5.4")237 self.add_class("road_signs", 158, "7.5.6")238 self.add_class("road_signs", 159, "7.5.7")239 self.add_class("road_signs", 160, "7.6.1")240 self.add_class("road_signs", 161, "7.6.2")241 self.add_class("road_signs", 162, "7.6.3")242 self.add_class("road_signs", 163, "7.6.4")243 self.add_class("road_signs", 164, "7.6.5")244 self.add_class("road_signs", 165, "7.6.6")245 self.add_class("road_signs", 166, "7.8")246 self.add_class("road_signs", 167, "7.9")247 self.add_class("road_signs", 168, "TIP")248 # Train or validation dataset?249 assert subset in ["train", "val"]250 dataset_dir = os.path.join(dataset_dir, subset)251 # Load annotations252 # VGG Image Annotator saves each image in the form:253 # { 'filename': '28503151_5b5b7ec140_b.jpg',254 # 'regions': {255 # '0': {256 # 'region_attributes': {},257 # 'shape_attributes': {258 # 'all_points_x': [...],259 # 'all_points_y': [...],260 # 'name': 'polygon'}},261 # ... more regions ......
restricted_imagenet_madry.py
Source:restricted_imagenet_madry.py
...19 # convert the label id into folder name20 for i in definition:21 folder_list.append(classes[i])22 return folder_list23def add_class(name, definition):24 definition = id_2_foldername(definition)25 # if the class folder didn't exist, create one26 dest_dir = args.rst_root+'/train/'+name27 if not os.path.exists(dest_dir):28 os.makedirs(dest_dir)29 for i in definition:30 src_dir = args.ori_train+'/'+i31 copy_tree(src_dir, dest_dir)32 dest_dir = args.rst_root+'/val/'+name33 if not os.path.exists(dest_dir):34 os.makedirs(dest_dir)35 for i in definition:36 src_dir = args.ori_val+'/'+i37 copy_tree(src_dir, dest_dir)38# restricted imagenet based on Madry balance restricted imagenet (14 classes)39def main():40 if not os.path.exists(args.rst_root):41 os.makedirs(args.rst_root)42 if args.n_class != 10 and args.n_class != 14 and args.n_class != 20:43 print('config not supported')44 return45 if args.n_class >= 10:46 add_class('birds', list(range(10,14+1)))47 add_class('turtles', list(range(33,37+1)))48 add_class('lizards', list(range(42,46+1)))49 add_class('spiders', list(range(72,76+1)))50 add_class('crabs', list(range(118,122+1)))51 add_class('dogs', list(range(205,209+1)))52 add_class('beetles', list(range(302,306+1)))53 add_class('butterflies', list(range(322,326+1)))54 add_class('fish', list(range(393,397+1)))55 add_class('fungus', list(range(992,996+1)))56 if args.n_class >= 14:57 add_class('monkeys', list(range(371,374+1)))58 add_class('snake', list(range(60,64+1)))59 add_class('cats', list(range(281,285+1)))60 add_class('bigcats', list(range(289,293+1)))61 if args.n_class >= 20:62 add_class('musical-instrument', [402,420,486,546,594])63 add_class('sportsball', [429,430,768,805,890])64 add_class('cars-trucks', [609,656,717,734,817])65 add_class('train', [466,547,565,820,829])66 add_class('clothing', [617,834,869,841,474])67 add_class('boat', [403,510,554,625,628])68if __name__ == "__main__":...
wsgi_application.py
Source:wsgi_application.py
...18from slog.dispatcher import Id, Doc, Static, Attachment19logging.basicConfig(level=logging.INFO)20application = WsgiApplication(human_debug_output=True)21# Linear search: put most used at beginning of list!22application.add_class(r'^/?$', Home)23application.add_class(r'^/search$', Search)24application.add_class(r'^/static/(?P<filename>[^/]+)$', Static)25application.add_class(r'^/attachment/(?P<id>[a-f0-9]{32,32})/(?P<filename>[^/]+)$', Attachment)26application.add_class(r'^/accounts$', Accounts)27application.add_class(r'^/account/(?P<name>[^/]+)$', Account)28application.add_class(r'^/account/?$', AccountCreate)29application.add_class(r'^/protocols$', Protocols)30application.add_class(r'^/protocol/(?P<name>[^/]+)$', Protocol)31application.add_class(r'^/protocol/?$', ProtocolCreate)32application.add_class(r'^/projects$', Projects)33application.add_class(r'^/project/(?P<name>[^/]+)$', Project)34application.add_class(r'^/project/?$', ProjectCreate)35application.add_class(r'^/sample/(?P<name>[^/]+)$', Sample)36application.add_class(r'^/sample/?$', SampleCreate)37application.add_class(r'^/samples$', Samples)38application.add_class(r'^/workset/(?P<name>[^/]+)$', Workset)39application.add_class(r'^/workset/?$', WorksetCreate)40application.add_class(r'^/worksets$', Worksets)41application.add_class(r'^/instruments$', Instruments)42application.add_class(r'^/instrument/(?P<name>[^/]+)$', Instrument)43application.add_class(r'^/instrument/?$', InstrumentCreate)44application.add_class(r'^/tasks$', Tasks)45application.add_class(r'^/task/(?P<name>[^/]+)$', Task)46application.add_class(r'^/task/?$', TaskCreate)47application.add_class(r'^/tool/(?P<name>[^/]+)$', ToolDispatcher)48application.add_class(r'^/id/(?P<id>[a-f0-9]{32,32})$', Id)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!