How to use prepare_folder method in localstack

Best Python code snippet using localstack_python

parse.py

Source:parse.py Github

copy

Full Screen

...6import numpy as np7import torch8import torchvision9import torchvision.transforms as transforms10def prepare_folder(category):11 os.system("rm -rf %s" % category)12 os.system("mkdir %s" % category)13def create_images_handwriting(category):14 big_image = plt.imread('%s.jpg' % category)15 16 nx = 36 #rows17 ny = 41 #columns18 19 count = 020 for i in range(nx):21 for j in range(ny):22 small_image = big_image[32*i:32*(i+1), 32*j:32*(j+1), :]23 file_path = '%s/%06d' % (category, count)24 plt.imsave(file_path + '.png', small_image)25 os.system('convert %s.png %s.jpg' % (file_path, file_path))26 os.system('rm %s.png' % file_path)27 count += 128def transform_tensor_to_numpy(image):29 image = image / 2 + 0.530 np_image = image.numpy()31 return np.transpose(np_image, (1, 2, 0))32def create_images_torchvision(category, idx):33 transform = transforms.Compose(34 [transforms.ToTensor(),35 transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])36 images_set = torchvision.datasets.CIFAR10(root='./data', train=True, download=True, transform=transform)37 images_loader = torch.utils.data.DataLoader(images_set, batch_size=1, shuffle=False, num_workers=2)38 39 count = 040 for data in images_loader:41 image, label = data42 43 if label != idx:44 continue45 46 file_path = '%s/%06d' % (category, count)47 plt.imsave(file_path + '.png', transform_tensor_to_numpy(image[0]))48 os.system('convert %s.png %s.jpg' % (file_path, file_path))49 os.system('rm %s.png' % file_path)50 51 count += 152 if count == 1476:53 break54if __name__ == '__main__':55 category = sys.argv[1]56 if category in ('franz', 'nina', 'robert_scan', 'franz_scan'):57 prepare_folder(category)58 create_images_handwriting(category)59 60 classes = ('plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck')61 if category in classes:62 prepare_folder(category)63 create_images_torchvision(category, classes.index(category))...

Full Screen

Full Screen

config.py

Source:config.py Github

copy

Full Screen

...15 return os.path.join(self.path_output, self.dataset_key, key, '{}.{}'.format(mode, dtype))16 def model_path(self, key):17 return os.path.join(self.path_model, self.dataset_key, key)18 @classmethod19 def prepare_folder(cls, paths):20 for path in paths:21 if not os.path.exists(path):22 os.mkdir(path)23 def prepare_data_folder(self):24 path = os.path.join(self.path_data, self.dataset_key)25 self.prepare_folder([path, ])26 def prepare_output_folder(self, output_key=None):27 paths = [self.path_output, os.path.join(self.path_output, self.dataset_key), ]28 if output_key is not None:29 path = os.path.join(paths[-1], output_key)30 paths.append(path)31 self.prepare_folder(paths)32 def prepare_model_folder(self, output_key=None):33 paths = [self.path_model, os.path.join(self.path_model, self.dataset_key), ]34 if output_key is not None:35 path = os.path.join(paths[-1], output_key)36 paths.append(path)37 self.prepare_folder(paths)38 def output_folder(self, output_key):39 return os.path.join(self.path_output, self.dataset_key, output_key)40 def model_folder(self, output_key):...

Full Screen

Full Screen

prepare.py

Source:prepare.py Github

copy

Full Screen

1import os2from Reptiles.Reptiles.data_manager import MongoManager3def prepare_folder():4 folder_list = ['./Reptiles/PDF', './Reptiles/PDF/ACM', './Reptiles/PDF/ScienceDirect', './Reptiles/PDF/Springer']5 for folder in folder_list:6 if not os.path.exists(folder):7 os.makedirs(folder)8def prepare_mongodb():9 db = MongoManager()10 db.mongodb_insert("Process", {11 'title': 'ACM',12 'year': 2000,13 'month': 1,14 'day': 1,15 'startPage': 0,16 'PageSize': 2017 })18 db.mongodb_insert("Process", {19 'title': 'Springer',20 'type': 'Journal',21 'page': 122 })23 db.mongodb_insert("Process", {24 'title': 'ScienceDirect',25 'year': '2021',26 'venue_id': 027 })28if __name__ == '__main__':29 prepare_mongodb()30 prepare_folder()...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful