This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 该函数用于统计 TFRecord 文件中的样本数量(总数) | |
| def total_sample(file_name): | |
| sample_nums = 0 | |
| for record in tf.python_io.tf_record_iterator(file_name): | |
| # for record in tf.data.TFRecordDataset(path) | |
| sample_nums += 1 | |
| return sample_nums |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def resize_img_720p(img): | |
| h,w = img.shape[:2] | |
| new_h = max(h,w) | |
| fx = 1280/new_h | |
| resize_img = cv2.resize(img,(0, 0), fx = fx, fy = fx, interpolation = cv2.INTER_LINEAR) | |
| img_encode = cv2.imencode('.jpg', resize_img) | |
| str_encode = img_encode[1].tostring() | |
| return resize_img, str_encode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import ruamel.yaml | |
| yaml = ruamel.yaml.YAML() | |
| # yaml.preserve_quotes = True | |
| def up_yml(model_name): | |
| with open('version.yaml') as fp: | |
| data = yaml.load(fp) | |
| data[1]["model_path"] = "test_model/" + model_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| fig = plt.figure() | |
| ax = fig.add_subplot(111) | |
| ax.set_xlim([1, 10]) | |
| ax.set_ylim([1, 10]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AlignCollate(object): | |
| def __init__(self, img_height=32, img_width=100): | |
| self.img_height = img_height | |
| self.img_width = img_width | |
| self.transform = ResizeNormalize(img_width=self.img_width, img_height=self.img_height) | |
| def __call__(self, batch): | |
| images, labels = zip(*batch) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import glob | |
| import os | |
| file_list = glob.glob('/data/data/huansuan/image/*') | |
| for file in file_list: | |
| new_name = file.replace('-','_') | |
| os.rename(file,new_name) | |
| print(file,new_name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def resize_img_720p(img): | |
| h,w = img.shape[:2] | |
| new_h = max(h,w) | |
| fx = 1280/new_h | |
| resize_img = cv2.resize(img,(0, 0), fx = fx, fy = fx, interpolation = cv2.INTER_LINEAR) | |
| return resize_img |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import absolute_import | |
| from __future__ import division | |
| from __future__ import print_function | |
| import os | |
| import time | |
| import json | |
| import time as time | |
| import tensorflow as tf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Author: Awni Hannun | |
| This is an example CTC decoder written in Python. The code is | |
| intended to be a simple example and is not designed to be | |
| especially efficient. | |
| The algorithm is a prefix beam search for a model trained | |
| with the CTC loss function. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import os | |
| with open(r'D:\liujun\20-31.txt','r',encoding='utf-8') as f: | |
| file_list=f.readlines() | |
| for file in file_list: | |
| file=file.replace('\n','') | |
| base_name=os.path.basename(file) | |
| try: | |
| url =file |
NewerOlder