예제 #1
0
파일: i2v.py 프로젝트: pradeeps/pycadl
def i2v_tag_download():
    """Download a pretrained i2v network.

    Returns
    -------
    TYPE
        Description
    """
    model = download('https://s3.amazonaws.com/cadl/models/illust2vec_tag.tfmodel')
    tags = download('https://s3.amazonaws.com/cadl/models/tag_list.json')
    return model, tags
예제 #2
0
def test_melody_rnn_generation():
    primer_midi = download('https://s3.amazonaws.com/cadl/share/21150_Harry-Potter-and-the-Philosophers-Stone.mid')
    download('https://s3.amazonaws.com/cadl/models/basic_rnn.mag')

    magenta_utils.synthesize(primer_midi)
    fname = 'primer.mid'
    assert(os.path.exists('primer.mid'))
    generated_primer = midi_io.midi_file_to_sequence_proto(fname)
    assert(len(generated_primer.notes) == 14)

    fname = 'synthesis.mid'
    assert(os.path.exists('synthesis.mid'))
    generated_synthesis = midi_io.midi_file_to_sequence_proto(fname)
    assert(len(generated_synthesis.notes) == 243)
예제 #3
0
def celeb_vaegan_download():
    """Download a pretrained celeb vae/gan network.

    Returns
    -------
    TYPE
        Description
    """

    # Load the model and labels
    model = download(
        'https://s3.amazonaws.com/cadl/models/celeb.vaegan.tfmodel')
    labels = download(
        'https://s3.amazonaws.com/cadl/celeb-align/list_attr_celeba.txt')
    return model, labels
예제 #4
0
def test_alice(max_iter=5):
    """Summary

    Parameters
    ----------
    max_iter : int, optional
        Description

    Returns
    -------
    TYPE
        Description
    """
    utils.download('https://s3.amazonaws.com/cadl/models/alice.txt.gz')
    with gzip.open('alice.txt.gz', 'rb') as fp:
        txt = fp.read().decode('utf-8')
    return train(txt, n_layers=2, n_cells=20, max_iter=max_iter)
예제 #5
0
파일: charrnn.py 프로젝트: pradeeps/pycadl
def test_alice(max_iter=5):
    """Summary

    Parameters
    ----------
    max_iter : int, optional
        Description

    Returns
    -------
    TYPE
        Description
    """
    utils.download('https://s3.amazonaws.com/cadl/models/alice.txt.gz')
    with gzip.open('alice.txt.gz', 'rb') as fp:
        txt = fp.read().decode('utf-8')
    return train(txt, n_layers=2, n_cells=20, max_iter=max_iter)
예제 #6
0
파일: i2v.py 프로젝트: zhf459/pycadl
def i2v_download():
    """Download a pretrained i2v network.

    Returns
    -------
    TYPE
        Description
    """
    model = download('https://s3.amazonaws.com/cadl/models/illust2vec.tfmodel')
    return model
예제 #7
0
def test_generation():
    download('https://s3.amazonaws.com/cadl/models/model.ckpt-200000.data-00000-of-00001')
    download('https://s3.amazonaws.com/cadl/models/model.ckpt-200000.index')
    download('https://s3.amazonaws.com/cadl/models/model.ckpt-200000.meta')
    wav_file = download('https://s3.amazonaws.com/cadl/share/trumpet.wav')
    res = nsynth.synthesize(wav_file, synth_length=100)
    max_idx = np.max(np.where(res))
    assert(max_idx > 90 and max_idx < 100)
    assert(np.max(res) > 0.0)
예제 #8
0
def test_generation():
    download(
        'https://s3.amazonaws.com/cadl/models/model.ckpt-200000.data-00000-of-00001'
    )
    download('https://s3.amazonaws.com/cadl/models/model.ckpt-200000.index')
    download('https://s3.amazonaws.com/cadl/models/model.ckpt-200000.meta')
    wav_file = download('https://s3.amazonaws.com/cadl/share/trumpet.wav')
    res = nsynth.synthesize(wav_file, synth_length=100)
    max_idx = np.max(np.where(res))
    assert (max_idx > 90 and max_idx < 100)
    assert (np.max(res) > 0.0)
예제 #9
0
def test_trump(max_iter=100):
    """Summary

    Parameters
    ----------
    max_iter : int, optional
        Description
    """
    utils.download(
        'https://s3.amazonaws.com/cadl/models/trump.data-00000-of-00001')
    utils.download('https://s3.amazonaws.com/cadl/models/trump.meta')
    utils.download('https://s3.amazonaws.com/cadl/models/trump.index')
    utils.download('https://s3.amazonaws.com/cadl/models/trump.txt')
    with open('trump.txt', 'r') as fp:
        txt = fp.read()
    #train(txt, ckpt_name='trump', max_iter=max_iter)
    print(infer(txt, ckpt_name='./trump', n_iterations=max_iter))
예제 #10
0
파일: charrnn.py 프로젝트: pradeeps/pycadl
def test_trump(max_iter=100):
    """Summary

    Parameters
    ----------
    max_iter : int, optional
        Description
    """
    utils.download(
        'https://s3.amazonaws.com/cadl/models/trump.data-00000-of-00001')
    utils.download('https://s3.amazonaws.com/cadl/models/trump.meta')
    utils.download('https://s3.amazonaws.com/cadl/models/trump.index')
    utils.download('https://s3.amazonaws.com/cadl/models/trump.txt')
    with open('trump.txt', 'r') as fp:
        txt = fp.read()
    #train(txt, ckpt_name='trump', max_iter=max_iter)
    print(infer(txt, ckpt_name='./trump', n_iterations=max_iter))
예제 #11
0
파일: glove.py 프로젝트: pradeeps/pycadl
def get_model():
    """Summary

    Returns
    -------
    TYPE
        Description
    """
    # Download the glove model and open a zip file
    file = utils.download('http://nlp.stanford.edu/data/wordvecs/glove.6B.zip')
    zf = zipfile.ZipFile(file)

    # Collect the words and their vectors
    words = []
    vectors = []
    for l in zf.open("glove.6B.300d.txt"):
        t = l.strip().split()
        words.append(t[0].decode())
        vectors.append(list(map(np.double, t[1:])))

    # Store as a lookup table
    wordvecs = np.asarray(vectors, dtype=np.double)
    word2id = {word: i for i, word in enumerate(words)}
    return wordvecs, word2id, words
예제 #12
0
파일: glove.py 프로젝트: zhf459/pycadl
def get_model():
    """Summary

    Returns
    -------
    TYPE
        Description
    """
    # Download the glove model and open a zip file
    file = utils.download('http://nlp.stanford.edu/data/wordvecs/glove.6B.zip')
    zf = zipfile.ZipFile(file)

    # Collect the words and their vectors
    words = []
    vectors = []
    for l in zf.open("glove.6B.300d.txt"):
        t = l.strip().split()
        words.append(t[0].decode())
        vectors.append(list(map(np.double, t[1:])))

    # Store as a lookup table
    wordvecs = np.asarray(vectors, dtype=np.double)
    word2id = {word: i for i, word in enumerate(words)}
    return wordvecs, word2id, words
예제 #13
0
def test_convert_to_monophonic():
    primer_midi = download('https://s3.amazonaws.com/cadl/share/21150_Harry-Potter-and-the-Philosophers-Stone.mid')
    primer_sequence = midi_io.midi_file_to_sequence_proto(primer_midi)
    magenta_utils.convert_to_monophonic(primer_sequence)
    assert(len(primer_sequence.notes) == 254)
예제 #14
0
def test_harry_potter():
    primer_midi = download('https://s3.amazonaws.com/cadl/share/21150_Harry-Potter-and-the-Philosophers-Stone.mid')
    primer_sequence = midi_io.midi_file_to_sequence_proto(primer_midi)
    assert(len(primer_sequence.notes) == 282)
    assert(len(primer_sequence.time_signatures) == 1)