Best Python code snippet using localstack_python
parse.py
Source: parse.py
...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))...
config.py
Source: config.py
...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):...
prepare.py
Source: prepare.py
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()...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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!!