Python glob.glob1() Examples
The following are 30
code examples of glob.glob1().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
glob
, or try the search function
.
Example #1
Source File: script_preprocess_annoations_S3DIS.py From DOTA_models with Apache License 2.0 | 6 votes |
def collect_room(building_name, room_name): room_dir = os.path.join(DATA_DIR, 'Stanford3dDataset_v1.2', building_name, room_name, 'Annotations') files = glob.glob1(room_dir, '*.txt') files = sorted(files, key=lambda s: s.lower()) vertexs = []; colors = []; for f in files: file_name = os.path.join(room_dir, f) logging.info(' %s', file_name) a = np.loadtxt(file_name) vertex = a[:,:3]*1. color = a[:,3:]*1 color = color.astype(np.uint8) vertexs.append(vertex) colors.append(color) files = [f.split('.')[0] for f in files] out = {'vertexs': vertexs, 'colors': colors, 'names': files} return out
Example #2
Source File: script_preprocess_annoations_S3DIS.py From multilabel-image-classification-tensorflow with MIT License | 6 votes |
def collect_room(building_name, room_name): room_dir = os.path.join(DATA_DIR, 'Stanford3dDataset_v1.2', building_name, room_name, 'Annotations') files = glob.glob1(room_dir, '*.txt') files = sorted(files, key=lambda s: s.lower()) vertexs = []; colors = []; for f in files: file_name = os.path.join(room_dir, f) logging.info(' %s', file_name) a = np.loadtxt(file_name) vertex = a[:,:3]*1. color = a[:,3:]*1 color = color.astype(np.uint8) vertexs.append(vertex) colors.append(color) files = [f.split('.')[0] for f in files] out = {'vertexs': vertexs, 'colors': colors, 'names': files} return out
Example #3
Source File: script_preprocess_annoations_S3DIS.py From models with Apache License 2.0 | 6 votes |
def collect_room(building_name, room_name): room_dir = os.path.join(DATA_DIR, 'Stanford3dDataset_v1.2', building_name, room_name, 'Annotations') files = glob.glob1(room_dir, '*.txt') files = sorted(files, key=lambda s: s.lower()) vertexs = []; colors = []; for f in files: file_name = os.path.join(room_dir, f) logging.info(' %s', file_name) a = np.loadtxt(file_name) vertex = a[:,:3]*1. color = a[:,3:]*1 color = color.astype(np.uint8) vertexs.append(vertex) colors.append(color) files = [f.split('.')[0] for f in files] out = {'vertexs': vertexs, 'colors': colors, 'names': files} return out
Example #4
Source File: script_preprocess_annoations_S3DIS.py From g-tensorflow-models with Apache License 2.0 | 6 votes |
def collect_room(building_name, room_name): room_dir = os.path.join(DATA_DIR, 'Stanford3dDataset_v1.2', building_name, room_name, 'Annotations') files = glob.glob1(room_dir, '*.txt') files = sorted(files, key=lambda s: s.lower()) vertexs = []; colors = []; for f in files: file_name = os.path.join(room_dir, f) logging.info(' %s', file_name) a = np.loadtxt(file_name) vertex = a[:,:3]*1. color = a[:,3:]*1 color = color.astype(np.uint8) vertexs.append(vertex) colors.append(color) files = [f.split('.')[0] for f in files] out = {'vertexs': vertexs, 'colors': colors, 'names': files} return out
Example #5
Source File: script_preprocess_annoations_S3DIS.py From object_detection_with_tensorflow with MIT License | 6 votes |
def collect_room(building_name, room_name): room_dir = os.path.join(DATA_DIR, 'Stanford3dDataset_v1.2', building_name, room_name, 'Annotations') files = glob.glob1(room_dir, '*.txt') files = sorted(files, key=lambda s: s.lower()) vertexs = []; colors = []; for f in files: file_name = os.path.join(room_dir, f) logging.info(' %s', file_name) a = np.loadtxt(file_name) vertex = a[:,:3]*1. color = a[:,3:]*1 color = color.astype(np.uint8) vertexs.append(vertex) colors.append(color) files = [f.split('.')[0] for f in files] out = {'vertexs': vertexs, 'colors': colors, 'names': files} return out
Example #6
Source File: script_preprocess_annoations_S3DIS.py From object_detection_kitti with Apache License 2.0 | 6 votes |
def collect_room(building_name, room_name): room_dir = os.path.join(DATA_DIR, 'Stanford3dDataset_v1.2', building_name, room_name, 'Annotations') files = glob.glob1(room_dir, '*.txt') files = sorted(files, key=lambda s: s.lower()) vertexs = []; colors = []; for f in files: file_name = os.path.join(room_dir, f) logging.info(' %s', file_name) a = np.loadtxt(file_name) vertex = a[:,:3]*1. color = a[:,3:]*1 color = color.astype(np.uint8) vertexs.append(vertex) colors.append(color) files = [f.split('.')[0] for f in files] out = {'vertexs': vertexs, 'colors': colors, 'names': files} return out
Example #7
Source File: script_preprocess_annoations_S3DIS.py From hands-detection with MIT License | 6 votes |
def collect_room(building_name, room_name): room_dir = os.path.join(DATA_DIR, 'Stanford3dDataset_v1.2', building_name, room_name, 'Annotations') files = glob.glob1(room_dir, '*.txt') files = sorted(files, key=lambda s: s.lower()) vertexs = []; colors = []; for f in files: file_name = os.path.join(room_dir, f) logging.info(' %s', file_name) a = np.loadtxt(file_name) vertex = a[:,:3]*1. color = a[:,3:]*1 color = color.astype(np.uint8) vertexs.append(vertex) colors.append(color) files = [f.split('.')[0] for f in files] out = {'vertexs': vertexs, 'colors': colors, 'names': files} return out
Example #8
Source File: diffcheck.py From porder with Apache License 2.0 | 6 votes |
def checker(folder, typ, infile, item, asset, start, end, cmin, cmax,outfile): print('Now Searching....') allasset = idl(infile = infile, item = item, asset = asset, start = start, end = end, cmin = cmin, cmax = cmax) sprefix = {'PSScene4Band': '_3B', 'REOrthoTile': '_R', 'PSScene3Band': '_3B', 'PSOrthoTile': '_BGRN'} sval = sprefix.get(item) if typ == 'image': filenames = glob.glob1(folder,"*.tif") l = [] for items in filenames: l.append(items.split(sval)[0]) print('Number of items not found locally: '+str(len(set(allasset)-set(l)))) print('IDlist written to '+str(outfile)+' with '+str(len(set(allasset)-set(l)))) with open(outfile, "w") as f: for s in list(set(allasset)-set(l)): f.write(str(s) +"\n") if typ=='metadata': filenames=glob.glob1(folder,"*.xml") l=[] for items in filenames: l.append(items.split(sval)[0]) print('Number of items not found locally: '+str(len(set(allasset).difference(set(l))))) print('IDlist written to '+str(outfile)+' with '+str(len(set(allasset)-set(l)))+' ids') with open(outfile, "w") as f: for s in list(set(allasset)-set(l)): f.write(str(s) +"\n")
Example #9
Source File: plot_water_levelui.py From CrisisMappingToolkit with Apache License 2.0 | 6 votes |
def plot_water_level(lake, startdate, enddate, result_dir): # Grabs lake names from .txt files in the results folder. lakes = [i.split('.')[0] for i in glob.glob1(result_dir,'*txt')] # Compares lake names found from .txt files with the chosen lake. If a match is found, the parser is run. if lake in lakes: lake = result_dir + os.sep + lake + '.txt' (features, dates, water, clouds) = parse_lake_results(lake, startdate, enddate) # Error-catcher for situation where a date range is selected and no good points are available for plotting. if water == False: print "No good data points found in selected date range. Please try a larger date range." # plot_results(features, dates, water, clouds, None, 'results/mono_lake_elevation.txt') else: plot_results(features, dates, water, clouds) plt.show() # Notifies user if the data file for the selected lake has not been generated yet. else: print "Specified lake data file not found. Please retrieve data and try again."
Example #10
Source File: plot_water_levelui.py From CrisisMappingToolkit with Apache License 2.0 | 6 votes |
def table_water_level(lake, startdate, enddate, result_dir, output_file=None): # Grabs lake names from .txt files in the results folder. lakes = [i.split('.')[0] for i in glob.glob1(result_dir,'*txt')] # Compares lake names found from .txt files with the chosen lake. If a match is found, the parser is run. if lake in lakes: lake_dir = result_dir + os.sep + lake + '.txt' (features, dates, water, clouds) = parse_lake_results(lake_dir, startdate, enddate) # Error-catcher for situation where a date range is selected and no good points are available for plotting. if water == False: print "No good data points found in selected date range. Please try a larger date range and retry." # Table creating and saving block: else: # Error catching for invalid directories. if output_file == None: output_file = result_dir + '/' + lake + '.csv' with open(output_file, 'wb') as f: writer = csv.writer(f) writer.writerow(["Date", "Area (km^2)"]) writer.writerows(izip(dates, water))
Example #11
Source File: cambridgema.py From cornerwise with MIT License | 6 votes |
def import_shapers(logger): (_, zip_path) = tempfile.mkstemp() (_, http_message) = request.urlretrieve(url, zip_path) zip_file = ZipFile(zip_path) ex_dir = tempfile.mkdtemp() zip_file.extractall(ex_dir) shapefiles = glob.glob1(ex_dir, "*.shp") lm = LayerMapping(Parcel, "/data/shapefiles/M274TaxPar.shp", { "shape_leng": "SHAPE_Leng", "shape_area": "SHAPE_Area", "map_par_id": "MAP_PAR_ID", "loc_id": "LOC_ID", "poly_type": "POLY_TYPE", "map_no": "MAP_NO", "source": "SOURCE", "plan_id": "PLAN_ID", "last_edit": "LAST_EDIT", "town_id": "TOWN_ID", "shape": "POLYGON" })
Example #12
Source File: ppm_utils.py From avocado-vt with GNU General Public License v2.0 | 6 votes |
def have_similar_img(base_img, comp_img_path, threshold=10): """ Check whether comp_img_path have a image looks like base_img. """ support_img_format = ['jpg', 'jpeg', 'gif', 'png', 'pmp'] comp_images = [] if os.path.isdir(comp_img_path): for ext in support_img_format: comp_images.extend([os.path.join(comp_img_path, x) for x in glob.glob1(comp_img_path, '*.%s' % ext)]) else: comp_images.append(comp_img_path) for img in comp_images: if img_similar(base_img, img, threshold): return True return False
Example #13
Source File: script_preprocess_annoations_S3DIS.py From yolo_v2 with Apache License 2.0 | 6 votes |
def collect_room(building_name, room_name): room_dir = os.path.join(DATA_DIR, 'Stanford3dDataset_v1.2', building_name, room_name, 'Annotations') files = glob.glob1(room_dir, '*.txt') files = sorted(files, key=lambda s: s.lower()) vertexs = []; colors = []; for f in files: file_name = os.path.join(room_dir, f) logging.info(' %s', file_name) a = np.loadtxt(file_name) vertex = a[:,:3]*1. color = a[:,3:]*1 color = color.astype(np.uint8) vertexs.append(vertex) colors.append(color) files = [f.split('.')[0] for f in files] out = {'vertexs': vertexs, 'colors': colors, 'names': files} return out
Example #14
Source File: create_bbox_dataset.py From dlupi-heteroscedastic-dropout with MIT License | 5 votes |
def get_split_xml_dict(self, split): if split == 'train': xml_dict = self.train_xml_dict split_annotation_path = self.train_annotation_path elif split == 'val': xml_dict = self.val_xml_dict split_annotation_path = self.val_annotation_path for i, synset in enumerate(self.train_annotation_synsets): print i synset_xml_files = glob.glob1(os.path.join(split_annotation_path, synset), '*.xml') xml_dict[synset] = synset_xml_files print split, 'annotation run-through complete.' print len(xml_dict.keys() )
Example #15
Source File: compute_gt_poses.py From ObjectDatasetTools with MIT License | 5 votes |
def load_pcds(path, downsample = True, interval = 1): """ load pointcloud by path and down samle (if True) based on voxel_size """ global voxel_size, camera_intrinsics pcds= [] for Filename in xrange(len(glob.glob1(path+"JPEGImages","*.jpg"))/interval): img_file = path + 'JPEGImages/%s.jpg' % (Filename*interval) cad = cv2.imread(img_file) cad = cv2.cvtColor(cad, cv2.COLOR_BGR2RGB) depth_file = path + 'depth/%s.png' % (Filename*interval) reader = png.Reader(depth_file) pngdata = reader.read() # depth = np.vstack(map(np.uint16, pngdata[2])) depth = np.array(tuple(map(np.uint16, pngdata[2]))) mask = depth.copy() depth = convert_depth_frame_to_pointcloud(depth, camera_intrinsics) source = geometry.PointCloud() source.points = utility.Vector3dVector(depth[mask>0]) source.colors = utility.Vector3dVector(cad[mask>0]) if downsample == True: pcd_down = source.voxel_down_sample(voxel_size = voxel_size) pcd_down.estimate_normals(geometry.KDTreeSearchParamHybrid(radius = 0.002 * 2, max_nn = 30)) pcds.append(pcd_down) else: pcds.append(source) return pcds
Example #16
Source File: sysinfo.py From cyborg with Apache License 2.0 | 5 votes |
def all_fpgas(): # glob.glob1("/sys/class/fpga", "*") return set(get_link_targets(find_fpgas_by_know_list())) | set( map(lambda p: p.rsplit("/", 2)[0], get_link_targets(glob.glob(os.path.join(SYS_FPGA, "*")))))
Example #17
Source File: sysinfo.py From cyborg with Apache License 2.0 | 5 votes |
def fpga_tree(): def gen_fpga_infos(path, vf=True): bdf = get_bdf_by_path(path) names = glob.glob1(os.path.join(path, "fpga"), "*") # name = os.path.basename(path) fpga = {"type": constants.DEVICE_FPGA, "devices": bdf, "stub": True, "name": "_".join((INTEL_FPGA_DEV_PREFIX, bdf))} d_info = fpga_device(path) fpga.update(d_info) if names: name = names[0] fpga["stub"] = False traits = get_traits(name, fpga["product_id"], vf) fpga.update(traits) fpga["rc"] = constants.RESOURCES["FPGA"] return fpga devs = [] pf_has_vf = all_pfs_have_vf() for pf in all_pf_fpgas(): fpga = gen_fpga_infos(pf, False) if pf in pf_has_vf: # Currently only one region supported. fpga["regions"] = [] # All VFs here belong to one same region. vfs = all_vfs_in_pf_fpgas(pf) for vf in vfs: vf_fpga = gen_fpga_infos(vf, True) fpga["regions"].append(vf_fpga) devs.append(_generate_driver_device(fpga, pf in pf_has_vf)) return devs
Example #18
Source File: utils.py From cyborg with Apache License 2.0 | 5 votes |
def discover_vendors(): vendors = set() for p in glob.glob1(SYS_FPGA_PATH, "*"): m = VENDORS_PATTERN.match(p) if m: vendors.add(m.group()) return list(vendors)
Example #19
Source File: common_fun.py From cyborg with Apache License 2.0 | 5 votes |
def discover_servers(): """Discover backend servers according to the CONF :returns: server list. """ servers = set() for p in glob.glob1(SPDK_SERVER_APP_DIR, "*"): m = SERVERS_PATTERN.match(p) if m: servers.add(m.group()) return list(servers)
Example #20
Source File: prepare_test_data.py From cyborg with Apache License 2.0 | 5 votes |
def create_devices_soft_link(class_fpga_path): devs = glob.glob1(class_fpga_path, "*") for dev in devs: path = os.path.realpath("%s/%s/device" % (class_fpga_path, dev)) softlinks = copy.copy(PGFA_DEVICE_COMMON_SOFT_LINK) softlinks.update( PGFA_DEVICES_SPECIAL_SOFT_LINK[dev.rsplit("-", 1)[-1]]) for k, v in softlinks.items(): source = os.path.normpath(os.path.join(path, v)) if not os.path.exists(source): os.makedirs(source) os.symlink(v, os.path.join(path, k))
Example #21
Source File: factory.py From object_detection_with_tensorflow with MIT License | 5 votes |
def load_building_meshes(self, building): dir_name = os.path.join(building['data_dir'], 'mesh', building['name']) mesh_file_name = glob.glob1(dir_name, '*.obj')[0] mesh_file_name_full = os.path.join(dir_name, mesh_file_name) logging.error('Loading building from obj file: %s', mesh_file_name_full) shape = renderer.Shape(mesh_file_name_full, load_materials=True, name_prefix=building['name']+'_') return [shape]
Example #22
Source File: bitmap.py From ironpython2 with Apache License 2.0 | 5 votes |
def demo(): import glob winDir=win32api.GetWindowsDirectory() for fileName in glob.glob1(winDir, '*.bmp')[:2]: bitmapTemplate.OpenDocumentFile(os.path.join(winDir, fileName))
Example #23
Source File: register_scene.py From ObjectDatasetTools with MIT License | 5 votes |
def load_pcds(path, downsample = True, interval = 1): """ load pointcloud by path and down samle (if True) based on voxel_size """ global voxel_size, camera_intrinsics pcds= [] for Filename in trange(int(len(glob.glob1(path+"JPEGImages","*.jpg"))/interval)): img_file = path + 'JPEGImages/%s.jpg' % (Filename*interval) # mask = cv2.imread(img_file, 0) cad = cv2.imread(img_file) cad = cv2.cvtColor(cad, cv2.COLOR_BGR2RGB) depth_file = path + 'depth/%s.png' % (Filename*interval) reader = png.Reader(depth_file) pngdata = reader.read() depth = np.array(tuple(map(np.uint16, pngdata[2]))) mask = depth.copy() depth = convert_depth_frame_to_pointcloud(depth, camera_intrinsics) source = geometry.PointCloud() source.points = utility.Vector3dVector(depth[mask>0]) source.colors = utility.Vector3dVector(cad[mask>0]) if downsample == True: pcd_down = source.voxel_down_sample(voxel_size = voxel_size) pcd_down.estimate_normals(geometry.KDTreeSearchParamHybrid(radius = 0.002 * 2, max_nn = 30)) pcds.append(pcd_down) else: pcds.append(source) return pcds
Example #24
Source File: create_bbox_dataset.py From dlupi-heteroscedastic-dropout with MIT License | 5 votes |
def get_split_im_dict(self, split): if split == 'train': split_path = self.train_set_path split_dict = self.train_im_dict elif split == 'val': split_path = self.val_set_path split_dict = self.val_im_dict for i, synset in enumerate(self.train_synsets): # val and train have same synsets! print i synset_im_files = glob.glob1(os.path.join(split_path, synset), '*.JPEG') split_dict[synset] = synset_im_files print split, ' set run-through complete.' print len(split_dict.keys() )
Example #25
Source File: factory.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def load_building_meshes(self, building): dir_name = os.path.join(building['data_dir'], 'mesh', building['name']) mesh_file_name = glob.glob1(dir_name, '*.obj')[0] mesh_file_name_full = os.path.join(dir_name, mesh_file_name) logging.error('Loading building from obj file: %s', mesh_file_name_full) shape = renderer.Shape(mesh_file_name_full, load_materials=True, name_prefix=building['name']+'_') return [shape]
Example #26
Source File: filebased.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def _list_cache_files(self): """ Get a list of paths to all the cache files. These are all the files in the root cache dir that end on the cache_suffix. """ if not os.path.exists(self._dir): return [] filelist = [os.path.join(self._dir, fname) for fname in glob.glob1(self._dir, '*%s' % self.cache_suffix)] return filelist
Example #27
Source File: factory.py From models with Apache License 2.0 | 5 votes |
def load_building_meshes(self, building): dir_name = os.path.join(building['data_dir'], 'mesh', building['name']) mesh_file_name = glob.glob1(dir_name, '*.obj')[0] mesh_file_name_full = os.path.join(dir_name, mesh_file_name) logging.error('Loading building from obj file: %s', mesh_file_name_full) shape = renderer.Shape(mesh_file_name_full, load_materials=True, name_prefix=building['name']+'_') return [shape]
Example #28
Source File: core.py From swmmio with MIT License | 5 votes |
def __init__(self, in_file_path, crs=None, include_rpt=True): self.crs = None inp_path = None if os.path.isdir(in_file_path): # a directory was passed in inps_in_dir = glob.glob1(in_file_path, "*.inp") if len(inps_in_dir) == 1: # there is only one INP in this directory -> good. inp_path = os.path.join(in_file_path, inps_in_dir[0]) elif os.path.splitext(in_file_path)[1] == '.inp': # an inp was passed in inp_path = in_file_path if inp_path: wd = os.path.dirname(inp_path) # working dir name = os.path.splitext(os.path.basename(inp_path))[0] self.name = name self.inp = inp(inp_path) # inp object self.rpt = None # until we can confirm it initializes properly self.bbox = None # to remember how the model data was clipped self.scenario = '' # self._get_scenario() self.crs = crs # coordinate reference system # try to initialize a companion RPT object rpt_path = os.path.join(wd, name + '.rpt') if os.path.exists(rpt_path) and include_rpt: try: self.rpt = rpt(rpt_path) except Exception as e: print('{}.rpt failed to initialize\n{}'.format(name, e)) self._nodes_df = None self._conduits_df = None self._orifices_df = None self._weirs_df = None self._pumps_df = None self._links_df = None self._subcatchments_df = None self._network = None
Example #29
Source File: __init__.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def glob(self, pattern, exclude = None): """Add a list of files to the current component as specified in the glob pattern. Individual files can be excluded in the exclude list.""" files = glob.glob1(self.absolute, pattern) for f in files: if exclude and f in exclude: continue self.add_file(f) return files
Example #30
Source File: factory.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def load_building_meshes(self, building): dir_name = os.path.join(building['data_dir'], 'mesh', building['name']) mesh_file_name = glob.glob1(dir_name, '*.obj')[0] mesh_file_name_full = os.path.join(dir_name, mesh_file_name) logging.error('Loading building from obj file: %s', mesh_file_name_full) shape = renderer.Shape(mesh_file_name_full, load_materials=True, name_prefix=building['name']+'_') return [shape]