Best Python code snippet using avocado_python
extra_img.py
Source: extra_img.py
...14from scipy.misc import imresize15WIDTH, HEIGHT = 224, 22416def load_image(path):17 return imresize(imread(path), (HEIGHT, WIDTH))18def load_test(base):19 paths = glob.glob('{}*.png'.format(base))20 print('Reading images...')21 for i, path in tqdm(enumerate(paths), total=len(paths)):22 datagen = ImageDataGenerator(23 rotation_range=20,24 width_shift_range=0.2,25 height_shift_range=0.2,26 shear_range=0.1,27 zoom_range=0.1,28 horizontal_flip=False,29 fill_mode='nearest')30 id = os.path.basename(path)31 img = load_image(path)32 x = img_to_array(img) # this is a Numpy array with shape (3, 150, 150)33 x = x.reshape((1,) + x.shape) # this is a Numpy array with shape (1, 3, 150, 150)34 # the .flow() command below generates batches of randomly transformed images35 # and saves the results to the `preview/` directory36 i = 037 if (base == 'database/0/'):38 dir = 'train/0'39 elif(base == 'database/1/'):40 dir = 'train/1'41 elif(base == 'database/2/'):42 dir = 'train/2'43 elif(base == 'database/3/'):44 dir = 'train/3'45 elif(base == 'database/4/'):46 dir = 'train/4'47 elif(base == 'database/5/'):48 dir = 'train/5'49 elif(base == 'database/6/'):50 dir = 'train/6'51 elif(base == 'database/7/'):52 dir = 'train/7'53 elif(base == 'database/8/'):54 dir = 'train/8'55 elif(base == 'database/9/'):56 dir = 'train/9'57 elif(base == 'database/a/'):58 dir = 'train/10'59 elif(base == 'database/b/'):60 dir = 'train/11'61 elif(base == 'database/c/'):62 dir = 'train/12'63 elif(base == 'database/d/'):64 dir = 'train/13'65 elif(base == 'database/e/'):66 dir = 'train/14'67 elif(base == 'database/f/'):68 dir = 'train/15'69 elif(base == 'database/g/'):70 dir = 'train/16'71 elif(base == 'database/h/'):72 dir = 'train/17'73 elif(base == 'database/i/'):74 dir = 'train/18'75 elif(base == 'database/j/'):76 dir = 'train/19'77 elif(base == 'database/k/'):78 dir = 'train/20'79 elif(base == 'database/l/'):80 dir = 'train/21'81 elif(base == 'database/m/'):82 dir = 'train/22'83 elif(base == 'database/n/'):84 dir = 'train/23'85 elif(base == 'database/o/'):86 dir = 'train/24'87 elif(base == 'database/p/'):88 dir = 'train/25'89 elif(base == 'database/q/'):90 dir = 'train/26'91 elif(base == 'database/r/'):92 dir = 'train/27'93 elif(base == 'database/s/'):94 dir = 'train/28'95 elif(base == 'database/t/'):96 dir = 'train/29'97 elif(base == 'database/u/'):98 dir = 'train/30'99 elif(base == 'database/v/'):100 dir = 'train/31'101 elif(base == 'database/w/'):102 dir = 'train/32'103 elif(base == 'database/x/'):104 dir = 'train/33'105 elif(base == 'database/y/'):106 dir = 'train/34'107 elif(base == 'database/z/'):108 dir = 'train/35'109 # print (dir)110 for batch in datagen.flow(x, batch_size=1,111 save_to_dir=dir, save_prefix='gesture', save_format='jpg'):112 i += 1113 if i > 5:114 break # otherwise the generator would loop indefinitely115load_test('database/0/')116load_test('database/1/')117load_test('database/2/')118load_test('database/3/')119load_test('database/4/')120load_test('database/5/')121load_test('database/6/')122load_test('database/7/')123load_test('database/8/')124load_test('database/9/')125load_test('database/a/')126load_test('database/b/')127load_test('database/c/')128load_test('database/d/')129load_test('database/e/')130load_test('database/f/')131load_test('database/g/')132load_test('database/h/')133load_test('database/i/')134load_test('database/j/')135load_test('database/k/')136load_test('database/l/')137load_test('database/m/')138load_test('database/n/')139load_test('database/o/')140load_test('database/p/')141load_test('database/q/')142load_test('database/r/')143load_test('database/s/')144load_test('database/t/')145load_test('database/u/')146load_test('database/v/')147load_test('database/w/')148load_test('database/x/')149load_test('database/y/')...
split_data.py
Source: split_data.py
1import json2import shutil34path = "E:/Dataset/manipulated_sequences/FaceShifter/c40/videos/"5path_dict = []67# with open("D:/PycharmProjects/Make_dataset/test.json",'r') as load_test:8# load_dict = json.load(load_test)9# print(load_dict)10# print(len(load_dict))11# for i in range(len(load_dict)):12# # print(load_dict[i])13# path_temp = path + str(load_dict[i][0]) + "_" + str(load_dict[i][1]) + ".mp4"14# path_dict.append(path_temp)15# print(path_dict)1617# with open("D:/PycharmProjects/Make_dataset/train.json",'r') as load_test:18# load_dict = json.load(load_test)19# print(load_dict)20# print(len(load_dict))21# for i in range(len(load_dict)):22# # print(load_dict[i])23# path_temp = path + str(load_dict[i][0]) + "_" + str(load_dict[i][1]) + ".mp4"24# path_dict.append(path_temp)25# print(path_dict)262728with open("D:/PycharmProjects/Make_dataset/val.json",'r') as load_test:29 load_dict = json.load(load_test)30 print(load_dict)31 print(len(load_dict))32 for i in range(len(load_dict)):33 # print(load_dict[i])34 path_temp = path + str(load_dict[i][1]) + "_" + str(load_dict[i][0]) + ".mp4"35 path_dict.append(path_temp)36 print(path_dict)37383940filepath = "E:/Dataset/manipulated_sequences/FaceShifter/c40/val"41for files in path_dict:
...
SpikeForecast.py
Source: SpikeForecast.py
1from xgboost import XGBClassifier2import matplotlib.pyplot as plt3from sklearn.preprocessing import StandardScaler4from sklearn.model_selection import GridSearchCV5import numpy6def spike_forecast(load_train, spike_train, load_test):7 scaler1 = StandardScaler()8 load_train = numpy.reshape(load_train, [-1, 1])9 load_test = numpy.reshape(load_test, [-1, 1])10 spike_train = numpy.reshape(spike_train, [-1, 1])11 scaler1.fit(load_train)12 load_train = scaler1.transform(load_train)13 load_test = scaler1.transform(load_test)14 print(load_train[0:24])15 print(spike_train[0:24])16 clf = XGBClassifier()17 clf.fit(load_train, spike_train.ravel())18 spike_fore = clf.predict(load_test)...
Check out the latest blogs from LambdaTest on this topic:
Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.
There is just one area where each member of the software testing community has a distinct point of view! Metrics! This contentious issue sparks intense disputes, and most conversations finish with no definitive conclusion. It covers a wide range of topics: How can testing efforts be measured? What is the most effective technique to assess effectiveness? Which of the many components should be quantified? How can we measure the quality of our testing performance, among other things?
With the change in technology trends, there has been a drastic change in the way we build and develop applications. It is essential to simplify your programming requirements to achieve the desired outcomes in the long run. Visual Studio Code is regarded as one of the best IDEs for web development used by developers.
Unit and functional testing are the prime ways of verifying the JavaScript code quality. However, a host of tools are available that can also check code before or during its execution in order to test its quality and adherence to coding standards. With each tool having its unique features and advantages contributing to its testing capabilities, you can use the tool that best suits your need for performing JavaScript testing.
Hey everyone! We hope you had a great Hacktober. At LambdaTest, we thrive to bring you the best with each update. Our engineering and tech teams work at lightning speed to deliver you a seamless testing experience.
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!!