forked from chunfengd/neural-storyteller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
30 lines (26 loc) · 1.1 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sys,time
import argparse
import config
import generate
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--model_cache_path', help = 'model cache path')
parser.add_argument('--type', help = 'train or inference',default='inference')
parser.add_argument('--input', help = 'input file')
parser.add_argument('--style', help = 'use style')
parser.add_argument('--condition_count', type=int,default=100)
parser.add_argument('--beamwidth', type=int,default=50)
args = parser.parse_args()
print args
if args.type == 'inference':
config.init(args.model_cache_path)
z = generate.load_all()
if args.style:
s = generate.story(z, args.input,args.condition_count,args.beamwidth,lyric=True)
else:
s = generate.story(z, args.input,args.condition_count,args.beamwidth)
#s = generate.story(z, args.input)
output_file = '/data/output/{}.txt'.format(str(int(time.time())));
with open(output_file, "w") as f:
f.write('{}'.format(s))
print output_file