def get_data(z, filename): import generate output = generate.story( z, '/Users/xinzhang/Document/courses/671project/flask/app/static/img/' + filename) return output
def get_story(file_path): #return 'test' return generate.story(z, file_path)
def tell_a_story(image): passage = generate.story(z, image.to_stream(), bw=1) return {'passage': passage}
import generate z = generate.load_all() generate.story(z, './images/ex1.jpg')
# -*- coding: utf-8 -*- # # AIWriter.py # # Copyright 2016 Franz Habison <*****@*****.**> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. # # # Info from # https://www.youtube.com/watch?v=x24VEUEph0Q&feature=youtu.be import generate z = generate.load_all() generate.story(z, "myImage.jpg")
#generates stories for a folfer of images --useful when evaluating #sj2842 import glob import generate z = generate.load_all() # from IPython.core.display import Image, display # from PIL import Image as Img for filename in glob.iglob('/Users/shreyajain/storyteller/neural-storyteller/images2/*'): print('%s' % filename) # display(Image(filename)) generate.story(z, filename) print("########## Parameters set k = 200 and bw=50 ###############") print(generate.story(z, filename,k=200, bw=50)) # print("########## Parameters set k = 300 and bw=100 ###############") # print(generate.story(z, filename, k=300, bw=50)) # print("########## Parameters set k = 400 and bw=100 ###############") # print(generate.story(z, filename, k=400, bw=50))
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
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
import keras import numpy import imagenet_utils import generate from keras.preprocessing import image def load_image(file_name): img = image.load_img(file_name, target_size=(224, 224)) im = image.img_to_array(img) im = numpy.expand_dims(im, axis=0) im = imagenet_utils.preprocess_input(im) return im image = load_image('./images/ex1.jpg') z = generate.load_all() generate.story(z, image)
#as5446 #making files for langauge check import glob import generate z = generate.load_all() import generate2 y = generate2.load_all() import generate3 w = generate3.load_all() fil = open('/Users/shreyajain/Downloads/grammar.txt', 'w') for filename in glob.iglob('/Users/shreyajain/Downloads/eval/*.jpg'): story = generate.story(z, filename, k=100, bw=50) story2 = generate2.story(y, filename, k=20, bw=5) story3 = generate3.story(w, filename, k=20, bw=5) print(story, story2, story3) fil.write(story + '\t' + story2 + '\t' + story3) fil.write('\n')
def get(filename): z = generate.load_all() output = generate.story(z, filename) return output