Example #1
0
def create_chain(type, id):
    chain = Chain(c, type)
    if not os.path.exists('static/images/{}/chain_{}'.format(type, id)):
        os.makedirs('static/images/{}/chain_{}'.format(type, id))

    if not os.path.exists('chain_data/{}/chain_{}'.format(type, id)):
        os.makedirs('chain_data/{}/chain_{}'.format(type, id))

    z = markov.noise()
    img = markov.generate(z)
    img_name = '{}/chain_{}/0.jpg'.format(type, id)
    markov.save_image(img, 'static/images/' + img_name)
    z = z.detach().numpy()
    chain.add_link(z, img_name)
    print(chain.type, chain.id)
    generate_proposal(chain)
    print('Created chain:', '{}/chain_{}'.format(type, id))
    return chain