(output, error, retz) = shellcmd(comm) if retz: print "\n\nBLAS: cannot create table of contents for blas library" print "stderr:\n", "*" * 50, "\n", comm, '\n', error, "\n", "*" * 50 sys.exit() print "done" # write the log on a file log = log + output + error fulllog = os.path.join(savecwd, 'log/log.blas') writefile(fulllog, log) print 'Installation of netlib BLAS successful.' print '(log is in ', fulllog, ')' # move librefblas.a to the lib directory shutil.copy('librefblas.a', os.path.join(self.config.prefix, 'lib/librefblas.a')) # set framework variables to point to the freshly installed BLAS library self.config.blaslib = '-L' + os.path.join(self.config.prefix, 'lib') + ' -lrefblas ' os.chdir(savecwd) if __name__ == '__main__': sys.path.insert(0, '../') import configure from dmft_install import Dmft_install config = configure.Config((1, 0, 0)) dmft_install = Dmft_install([], config) blas = Blas(config, dmft_install)
freq = float(line.split()[1]) count_ratio = word_counts[name] / max(1, float(capitalized_counts[name])) if name in remove and freq < 0.002: print name if name not in remove and freq > 0.002: name_stats.append((name, word_counts[name], capitalized_counts[name], count_ratio)) if count_ratio < 0.75: names.add(name) if count_ratio > 0.2: wordlike_names.add(name) for w, wc, cc, cr in sorted(name_stats, key=itemgetter(-1), reverse=True): if cc > 500: print w, wc, cc, cr utils.write_pickle(names, config.names) utils.write_pickle(wordlike_names, config.wordlike_names) def main(config): count_words(config, False) preprocess_names(config) count_words(config, True) vocabulary.Vocabulary(config, load=False).write() prep_data(config) if __name__ == '__main__': main(configure.Config())
def main(argv): ### History of executed commands will be stored in log.config logdir = 'log' if(not os.path.isdir(logdir)): print"Creating directory", logdir os.mkdir(logdir) # os.chdir(logdir) cmd = "" for arg in argv: cmd += arg+" " cmd += "\n" fp = open("log/log.config",'a') fp.write(cmd) fp.close() try: py_ver = sys.version_info print("\nDetected Python version %s" % ".".join(["%s" % i for i in py_ver])) if py_ver < (2, 7) or py_ver >= (2, 8): print("Python version 2.7+ required. Download and install the necessary " "python version from http://www.python.org/download/.") sys.exit(-1) except: print("\n Python version 2.7+ required. Download and install the necessary " "python version from http://www.python.org/download/.") sys.exit(-1) # try: # import setuptools # print("Detected setuptools version {}".format(setuptools.__version__)) # except ImportError: # print("setuptools not detected. Get it from https://pypi.python" # ".org/pypi/setuptools and follow the instructions to install first.") # sys.exit(-1) # try: # gcc_ver = subprocess.Popen(["gcc", "--version"], stdout=subprocess.PIPE)\ # .communicate()[0] # except: # print("gcc not found in PATH. gcc is needed for installation of numpy " # "and C extensions. For Mac users, please install Xcode and its " # "corresponding command-line tools first.") # sys.exit(-1) # try: # import pip # print("Detected pip version {}".format(pip.__version__)) # except ImportError: # print("pip not detected. Installing...") # subprocess.call(["easy_install", "pip"]) # try: import numpy #from numpy.distutils.misc_util import get_numpy_include_dirs print("Detected numpy version {}".format(numpy.__version__)) except ImportError: print("numpy.distutils.misc_util cannot be imported. Please install ...") #subprocess.call(["pip", "install", "-q", "numpy>=1.8.0"]) #from numpy.distutils.misc_util import get_numpy_include_dirs try: import scipy #from numpy.distutils.misc_util import get_numpy_include_dirs print("Detected scipy version {}".format(scipy.__version__)) except ImportError: print("scipy module cannot be imported. Please install ...") subprocess.call(["pip", "install", "-q", "scipy>=0.14.0"]) #from numpy.distutils.misc_util import get_numpy_include_dirs print "\n" config = configure.Config((VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO)) dmft_install = Dmft_install(argv, config) # if dmft_install.downblas : Blas(config, dmft_install) # if dmft_install.downlapack : Lapack(config, dmft_install) # if dmft_install.downfftw : Fftw(config, dmft_install) # if dmft_install.downgsl : Gsl(config, dmft_install) dmft_install.resume() return 0
y_pts /= y_max e_pts /= y_max lines.append( plt.plot(x_pts, y_pts, linestyle='dashed', marker='x', markersize=3, label='loss %d, max: %3.0f' % (idx, y_max))[0]) plt.errorbar(x_pts, y_pts, e_pts, linestyle='None') plt.legend(lines, loc='upper right') plt.show() C = configure.Config() T = Tools() def mat2img(mats): mats = np.clip(mats, 0.0, 1.0) out = [] for mat in mats: aerial = mat[:, :, 0:3] cloud1I = mat[:, :, 3, np.newaxis].repeat(3, axis=2) cloud1T = mat[:, :, 4, np.newaxis].repeat(3, axis=2) groundI = mat[:, :, 5:8] groundT = mat[:, :, 8:11] groundO = mat[:, :, 11:14] img_show = (aerial, cloud1I, cloud1T, groundI, groundT, groundO)
mat = mat.transpose((2, 0, 1, 3)) mat = np.concatenate(mat, axis=0) mat = (mat * 255.0).astype(np.uint8) out.append(mat) img = np.concatenate(out, axis=1) img = np.rot90(img) cv2.imwrite(img_path, img) out = [] for mat in mats: mat = mat.reshape((C.size, C.size, -1, 3)) mat = mat.transpose((2, 0, 1, 3)) C = configure.Config('mod_WGAN') T = Tools() def model_save_npy(sess, print_info): tf_vars = tf.global_variables() '''save as singal npy''' npy_dict = dict() for var in tf_vars: npy_dict[var.name] = var.eval(session=sess) print("| FETCH: %s" % var.name) if print_info else None np.savez(C.model_npz, npy_dict) with open(C.model_npz + '.txt', 'w') as f: f.writelines(["%s\n" % key for key in npy_dict.keys()])
mat = mat.transpose((2, 0, 1, 3)) mat = np.concatenate(mat, axis=0) mat = (mat * 255.0).astype(np.uint8) out.append(mat) img = np.concatenate(out, axis=1) img = np.rot90(img) cv2.imwrite(img_path, img) out = [] for mat in mats: mat = mat.reshape((C.size, C.size, -1, 3)) mat = mat.transpose((2, 0, 1, 3)) C = configure.Config('mod_mend') T = Tools() def model_save_npy(sess, print_info): tf_vars = tf.global_variables() '''save as singal npy''' npy_dict = dict() for var in tf_vars: npy_dict[var.name] = var.eval(session=sess) print("| FETCH: %s" % var.name) if print_info else None np.savez(C.model_npz, npy_dict) with open(C.model_npz + '.txt', 'w') as f: f.writelines(["%s\n" % key for key in npy_dict.keys()]) '''save as several npy''' # shutil.rmtree(C.model_npy, ignore_errors=True)
from tensorflow.python.framework.graph_util import convert_variables_to_constants from yolov3.utils.utils import get_yolo_boxes, get_yolo_boxes_by_tf, crop_boxes, freeze_session import configure as config_obj def image_reader(img_path): input_image = misc.imread(img_path) if input_image.shape[2] > 3: input_image = input_image[:, :, :3] return input_image if __name__ == "__main__": config = config_obj.Config( root_path=os.path.abspath(os.path.join(os.getcwd(), ".."))) yolo_weights_path = config.weights_path yolo_model = load_model(yolo_weights_path) yolo_config_path = config.config_path with open(yolo_config_path, 'r') as config_buffer: yolo_config = json.load(config_buffer) filepath = "../testing/demo_car_org.png" filename = filepath.split('.')[-2].split('/')[-1] input_image = image_reader(filepath) input_image_list = list() input_image_list.append(input_image)