try: complx = sys.argv[4].lower() in ("yes", "true", "t", "1") except IndexError: complx = True try: variable_len = sys.argv[5].lower() in ("yes", "true", "t", "1") except IndexError: variable_len = True scribe = RowScribe(nChars, avg_seq_len, buffer_len=avg_seq_len // 10) xs = [] ys = [] for i in range(1000): x, y = scribe.get_data(complx, variable_len) xs.append(x) ys.append(y) print(y) slab_print(x) print('Output: {}\n' 'Char set size: {}\n' '(Avg.) Len: {}\n' 'Varying Length: {}\n' 'Complex Scribe: {}\n'.format( out_file_name, nChars, avg_seq_len, variable_len, complx, )) chars = [str(x) for x in range(nChars)] with open(out_file_name, 'wb') as f: pickle.dump({'x': xs, 'y': ys, 'chars': chars}, f, -1)
try: variable_len = sys.argv[5].lower() in ("yes", "true", "t", "1") except IndexError: variable_len = True scribe = RowScribe(nChars, avg_seq_len, buffer_len=avg_seq_len // 10) xs = [] ys = [] for i in range(1000): x, y = scribe.get_data(complx, variable_len) xs.append(x) ys.append(y) print(y) slab_print(x) print('Output: {}\n' 'Char set size: {}\n' '(Avg.) Len: {}\n' 'Varying Length: {}\n' 'Complex Scribe: {}\n'.format( out_file_name, nChars, avg_seq_len, variable_len, complx, )) chars = [str(x) for x in range(nChars)] with open(out_file_name, 'wb') as f:
xs, ys = [], [] for line in text.split('\n'): print('\n', line) for fontname in sorted(language.font_properties): [sz, gho, rep, ppu, spc, abbr, hasbold] = language.font_properties[fontname] for style in range(4 if hasbold else 2): x = scribe_wrapper(line, fontname, style, 32, 200, 5, 5, 0) y = language.get_labels(line) xs.append(x) ys.append(y) if printall or fontname is "Mallanna": print(fontname, style, ys[-1]) print(xs[-1].shape) slab_print(xs[-1]) if in_file_name.startswith('/dev'): out_file_name = "tmp.pkl" else: out_file_name = in_file_name.replace(".txt", ".pkl") with open(out_file_name, 'wb') as f: pickle.dump({'x': xs, 'y': ys, 'nChars': len(language.symbols)}, f, -1) print('nChars:', len(language.symbols)) print(out_file_name)
if len(sys.argv) < 2: print('Usage:' '\n python3 {} <output_file_name> [configurations]' 'Generates data based on the configuration files.'.format( sys.argv[0])) sys.exit(-1) out_file_name = sys.argv[1] if not out_file_name.endswith('.pkl'): out_file_name += '.pkl' args = utils.read_args(sys.argv[2:]) scriber = Scribe(**args['scribe_args']) alphabet_chars = scriber.alphabet.chars xs = [] ys = [] for i in range(args['num_samples']): x, y = scriber.get_sample() xs.append(x) ys.append(y) print(y, ''.join(alphabet_chars[i] for i in y)) utils.slab_print(x) with open(out_file_name, 'wb') as f: pickle.dump({'x': xs, 'y': ys, 'chars': alphabet_chars}, f, -1) print(scriber) print('Generated dataset:', out_file_name)
import sys from scribe import scribe_wrapper from trimmers import trim from utils import slab_print import telugu as language import telugu.fonts as fonts if len(sys.argv) < 2: print("Usage:\n" "{0} text_file" "\n or \n" "{0} <(echo 'text')".format(sys.argv[0])) sys.exit() corpus_file = sys.argv[1] with open(corpus_file) as fin: print("Opening ", corpus_file) txt = fin.read() try: tenn = int(sys.argv[2]) except IndexError: tenn = 10 for font in sorted(language.font_properties): x = scribe_wrapper(txt, font, 0, 32, 200, 5, 5, 0) print(language.font_properties[font][fonts.ABBR]) slab_print(trim(x))
printall = True if len(sys.argv) > 2 else False xs, ys = [], [] for line in text.split('\n'): print('\n', line) for fontname in sorted(language.font_properties): [sz, gho, rep, ppu, spc, abbr, hasbold] = language.font_properties[fontname] for style in range(4 if hasbold else 2): x = scribe_wrapper(line, fontname, style, 32, 200, 5, 5, 0) y = language.get_labels(line) xs.append(x) ys.append(y) if printall or fontname is "Mallanna": print(fontname, style, ys[-1]) print(xs[-1].shape) slab_print(xs[-1]) if in_file_name.startswith('/dev'): out_file_name = "tmp.pkl" else: out_file_name = in_file_name.replace(".txt", ".pkl") with open(out_file_name, 'wb') as f: pickle.dump({'x': xs, 'y': ys, 'nChars': len(language.symbols)}, f, -1) print('nChars:', len(language.symbols)) print(out_file_name)
import sys sys.path.append("..") from utils import slab_print, read_args import telugu as language import scribe args = read_args(sys.argv[1:], default='../configs/default.ast') scriber = scribe.Scribe(language, **args['scribe_args']) try: while True: image, text, labels = scriber.get_text_image() slab_print(image) print(image.shape) print(labels) # print("Twist: {:.3f}".format(angle), fp) # print(text) print(scriber) print("Press Enter to continue and Ctrl-D to quit.") input() except (KeyboardInterrupt, EOFError): pass