def build_dataset(imgFiles): cfgFront = '/home/udit/d2-net/lib/ipm/cameraFront.json' cfgRear = '/home/udit/d2-net/lib/ipm/cameraRear.json' for i in range(len(imgFiles[0][:])): front_top = ipm(imgFiles[0][i], cfgFront) rear_top = ipm(imgFiles[1][i], cfgRear) front_top = Image.fromarray(front_top).convert('LA').convert('RGB') rear_top = Image.fromarray(rear_top).convert('LA').convert('RGB') front_top.save('/scratch/udit/robotcar/overcast/ipm/front/' + str(i) + '.png') rear_top.save('/scratch/udit/robotcar/overcast/ipm/rear/' + str(i) + '.png') print(i)
def ipm_select(img_dir, out_dir, distance_file, num, dataset_map, exclude): data = pd.read_csv(distance_file) img_ids = data.iloc[:, 0] rows, cols = data.shape if type(data.iloc[0, cols - 1]) == str: # remove last column, if it is a string column distances = np.array(data.iloc[:, 1:cols - 1]) else: distances = np.array(data.iloc[:, 1:]) if exclude is None: selected_data = None else: selected_idxs = get_excluded_idxs(img_ids, exclude) selected_data = list(distances[selected_idxs]) idxs = ipm(list(distances), n=num, selected_data=selected_data) if dataset_map is not None: id_map = load_dataset_map(dataset_map) for idx in idxs: img_id = img_ids[idx].split('.')[0] if dataset_map is not None: img_id = id_map[img_id] label, img = img_id.split('_') src = os.path.join(img_dir, label, '{}.png'.format(img)) dest = os.path.join(out_dir, '{}.png'.format(img_id)) shutil.copy2(src, dest)
{ PM_RAISE(retval, PM_RET_EX_TYPE); return retval; } /* If arg is not an int, raise TypeError */ pn = NATIVE_GET_LOCAL(0); if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT) { PM_RAISE(retval, PM_RET_EX_TYPE); return retval; } /* Get int value from the arg */ n = ((pPmInt_t)pn)->val; /* Clear all and set the desired LEDs (active low) */ AT91F_PIO_SetOutput(AT91C_BASE_PIOA, LED_MASK); AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, n); NATIVE_SET_TOS(PM_NONE); return PM_RET_OK; """ pass import ipm ipm.ipm(globals()) # :mode=c:
# # PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers. # Copyright 2002 Dean Hall. All rights reserved. # PyMite is offered through one of two licenses: commercial or open-source. # See the LICENSE file at the root of this package for licensing details. # # # Runs the interactive interpreter # print "Hello" import ipm ipm.ipm(globals()) print "Good-bye"
# This file is Copyright 2007, 2009 Dean Hall. # # This file is part of the Python-on-a-Chip program. # Python-on-a-Chip is free software: you can redistribute it and/or modify # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. # # Python-on-a-Chip is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 # is seen in the file COPYING up one directory from this. ## @file # @brief PIC24/dsPIC33 main code to run ipm. # import ipm print "Welcome to PIC24/dsPIC33 Python! Starting interactive mode." ipm.ipm()
# This file is Copyright 2007 Dean Hall. # # This file is part of the Python-on-a-Chip program. # Python-on-a-Chip is free software: you can redistribute it and/or modify # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. # # Python-on-a-Chip is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 # is seen in the file COPYING up one directory from this. ## @file # @brief PIC24/dsPIC33 main code to run ipm. # from ipm import ipm print "Welcome to PIC24/dsPIC33 Python! Starting interactive mode." ipm()
# # PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers. # Copyright 2002 Dean Hall. All rights reserved. # PyMite is offered through one of two licenses: commercial or open-source. # See the LICENSE file at the root of this package for licensing details. # #import sys #import maple import ipm ipm.ipm() #maple.init_gpio() #maple.toggle_led()
print sys.time(); # will return zero... not implemented yet X-D #sys.wait(150); ## waiting 150ms ... looping :-< #print sys.time(); print "=== check: string module-atoi"; print string.atoi("-123"); print string.atoi(" -123",8); print string.atoi("-123",16); ##print string.atoi("-123 "); ## error trailing junk chars. print "=== check: string module-find"; print string.find("-123",'-'); print string.find("-123",'3'); print string.find("-123",'a'); print string.find("-123",''); print "=== check: string module-count"; print string.count("abc-123+xyzab",'a'); print string.count("abc-123+xyzab",'b'); print string.count("abc-123+xyzab",' '); print string.count("abc-123+xyzab",'123'); print string.count("abc-123+xyzab",'+123'); print "=== check: ipm module-ipm()"; ipm.ipm(); sys.exit(); # :mode=c:
def launch_ipm(): """ """ print "launching ipm" ipm.ipm()
from ipm import ipm import numpy as np from sklearn.datasets import fetch_openml import matplotlib.pyplot as plt if __name__ == '__main__': # load data X, y = fetch_openml('mnist_784', version=1, cache=True, return_X_y=True) X = X / 255. # select a random subset of data (for faster execution) # idx = np.random.permutation(range(len(y)))[:10000] # X = X[idx] # y = y[idx] # select samples using ipm selected_idx = ipm(list(X), n=10) # plot selected samples plt.figure() for i in range(10): plt.subplot(2, 5, i + 1) plt.axis('off') image = X[selected_idx[i]].reshape(28, 28) plt.imshow(image, cmap=plt.cm.gray_r) plt.title('Label: ' + y[selected_idx[i]]) plt.show()