def predict(seq_model,
            core_input_shape=5,
            withOffset=False,
            fromFile='testData',
            files=[0]):
    musList, recList, matchesMapList, songNames, matchValue, potentialMatchesMapList = util.parseMatchedInput(
        fromFile, files)
    musList, recList = util.normalizeTimes(musList, recList)
    recList, matchesMapList = util.trim(recList, matchesMapList)
    if withOffset:
        recList = util.addOffsets(musList, recList, matchesMapList)
    songPredictions = []
    for i in range(len(musList)):
        x, y = util.dataAsWindow([musList[i]], [recList[i]],
                                 [matchesMapList[i]])
        x_test = x.astype('float32')
        mus_x_test, rec_x_test, core_test_features = util.splitData(x_test)
        mus_x_test, rec_x_test, core_test_features = mus_x_test.astype(
            'float32'), rec_x_test.astype(
                'float32'), core_test_features.astype('float32')
        songPredictions.append(
            predict_on_song(seq_model, core_input_shape, mus_x_test,
                            rec_x_test, core_test_features, [musList[i]],
                            [recList[i]], [matchesMapList[i]], i))
    return songPredictions
 def render(self, screen):
     screen.blit(self.pages[self.current], (0, 0))
     y = 20
     x = 10
     for line in self.text[self.current]:
         img = get_text(util.trim(line), (0, 0, 0), 18)
         screen.blit(img, (x, y))
         y += img.get_height() + 4
	def render(self, screen):
		screen.blit(self.pages[self.current], (0, 0))
		y = 20
		x = 10
		for line in self.text[self.current]:
			img = get_text(util.trim(line), (0, 0, 0), 18)
			screen.blit(img, (x, y))
			y += img.get_height() + 4
Пример #4
0
    def login_pressed(self):
        raw_users = util.read_file("users.txt")
        if raw_users == None:
            users = []
            raw_users = ""
        else:
            users = util.trim(raw_users).split("\n")
        user_lookup = {}
        for user in users:
            name = util.alphanums(util.trim(user[32:]))
            password = user[:32].lower()
            user_lookup[name] = password

        user = util.alphanums(self.username.text)
        password = user_lookup.get(user, None)
        if password == None:
            password = util.md5(str(time.time()) + "leprechauns")
            raw_users += "\n" + password + user
            util.write_file("users.txt", raw_users)
        self.auth_request = network.send_authenticate(user, password)
        self.password = password
Пример #5
0
    def login_pressed(self):
        raw_users = util.read_file('users.txt')
        if raw_users == None:
            users = []
            raw_users = ''
        else:
            users = util.trim(raw_users).split('\n')
        user_lookup = {}
        for user in users:
            name = util.alphanums(util.trim(user[32:]))
            password = user[:32].lower()
            user_lookup[name] = password

        user = util.alphanums(self.username.text)
        password = user_lookup.get(user, None)
        if password == None:
            password = util.md5(str(time.time()) + "leprechauns")
            raw_users += "\n" + password + user
            util.write_file('users.txt', raw_users)
        self.auth_request = network.send_authenticate(user, password)
        self.password = password
Пример #6
0
def predict(model):
    musList, recList, matchesMapList, songNames = util.parseMatchedInput(
        'testData', [0])
    musList, recList = util.normalizeTimes(musList, recList)
    recList, matchesMapList = util.trim(recList, matchesMapList)
    recList = util.addOffsets(musList, recList, matchesMapList)
    for i in range(len(musList)):
        x, y = util.dataAsWindowTwoSided([musList[i]], [recList[i]],
                                         [matchesMapList[i]])
        x_test = x.astype('float32')
        x_test = util.splitDataTwoSided(x_test, only_mus=True)
        x_test = x_test.astype('float32')
        predict_on_song_only_mus(model, x_test, [musList[i]], [recList[i]],
                                 [matchesMapList[i]], i)
def main():
    musList, recList, matchesMapList, songNames = util.parseMatchedInput(
        'javaOutput', 8)
    musList, recList = util.normalizeTimes(musList, recList)
    recList, matchesMapList = util.trim(recList, matchesMapList)
    x, y = util.dataAsWindow(musList, recList, matchesMapList)
    x_train = x.astype('float32')
    y_train = y.astype('float32')
    mus_train, rec_train, core_train = util.splitData(x_train)
    mus_train, rec_train, core_train = mus_train.astype(
        'float32'), rec_train.astype('float32'), core_train.astype('float32')

    ################
    isSeq = False  ##
    ################

    mus_train, rec_train, core_train, y_train = util.splitSeqChord(
        mus_train, rec_train, core_train, y_train, isSeq)

    model = train_model(mus_train, rec_train, core_train, y_train)
    if isSeq:
        model.save("enhanced_nn_model_seq.h5")
    else:
        model.save("enhanced_nn_model_chord.h5")
    def __init__(self):
        self.next = self
        self.pages = [
            get_image('backgrounds/ending1.png'),
            get_image('backgrounds/ending1.png'),
            get_image('backgrounds/ending1.png'),
            get_image('backgrounds/ending1.png'),
            get_image('backgrounds/ending2.png'),
            get_image('backgrounds/ending2.png')
        ]
        self.text = [
            util.trim("""
			Despite the fact that you can still see hordes of the
			alien monsters on the horizon, you begin the launch
			sequence for your homemade spaceship, hoping for the best.
			Amazingly enough, the patchwork rocket engine ignites.
			The hastily constructed frame groans as the fuel burns;
			this is a one-way trip, so you better hope your""").split('\n'),
            util.trim("""
			destination isn't too far. You've used the computer to
			calculate where your home world is, hoping you'll be able
			to hide among your family and friends, counting on the fact
			that no one has escaped the prison planet before to mean
			they won't be looking for you. It's a desperate gamble, but
			it's better than being trapped for the rest of your life.
		""").split('\n'),
            util.trim("""
				You're not sure how long you spend traveling through
				the blackness of space, but finally you think you
				have arrived at the location the computer indicated
				your home would be. It's not a moment too soon; your
				fuel supply is nearly depleted. You buckle in and
				start the landing sequence; hoping to survive.""").split('\n'),
            util.trim("""

			Your arrival was more on the "crash" side of landing,
			but you're in one piece! You open the hatch to your rocket,
			ready to make your way home.""").split('\n'),
            util.trim("""
				Except something is wrong; where are the houses,
				the architecture, the parks and fountains? Even
				in the most uninhabited areas, it didn't look
				like this: barren, almost lifeless. You cautiously
				approach the small crowd gathered around your craft;
				they're a motley bunch, looking shifty and suspicious. """).split('\n'),
            util.trim("""
			"Where am I? Isn't this Earth?"
			
			They look at each other, and an older man with one eye
			and a lot of tattoos answers, "Sure was, stranger, but
			it ain't much of anythin' no more."
			
			"What do you mean? This is my home!"
			
			"Ain't no one's home; they moved the locals out of here
			when they made this a prison planet. You must be crazy
			to come here, cause everyone knows there ain't no way out!"
		""").split('\n')
        ]
        self.current = 0
        self.counter = 0
import pygame
from src import scenefactory, util
from src.images import get_image
from src.font import get_text
from src import jukebox

page1 = util.trim("""
They say that in these enlightened times, society has
evolved beyond the need for barbaric customs of 
punishing crime. Long gone are the stocks, the electric
chair, and the prison cell; instead, those who inflict
pain or suffering on others are gently removed and
placed on a lush deserted planet where they are given
the freedom to live peaceful, fulfilling lives in a
community of equals.
""").split('\n')

page2 = util.trim("""
However, they are wrong.
""").split('\n')

page3 = util.trim("""
In truth, not just criminals but anyone who disagrees
with the ruling government is forever exiled to this
remote prison planet. Life on this prison planet is
brutal; it's difficult to scrape out a living when
some of your neighbors are petty thieves and killers,
and the knowledge that no one has ever escaped only
makes existence that much harder.
""").split('\n')
	def __init__(self):
		self.next = self
		self.pages = [
			get_image('backgrounds/ending1.png'),
			get_image('backgrounds/ending1.png'),
			get_image('backgrounds/ending1.png'),
			get_image('backgrounds/ending1.png'),
			get_image('backgrounds/ending2.png'),
			get_image('backgrounds/ending2.png')]
		self.text = [
		util.trim("""
			Despite the fact that you can still see hordes of the
			alien monsters on the horizon, you begin the launch
			sequence for your homemade spaceship, hoping for the best.
			Amazingly enough, the patchwork rocket engine ignites.
			The hastily constructed frame groans as the fuel burns;
			this is a one-way trip, so you better hope your""").split('\n'),
			
		util.trim("""
			destination isn't too far. You've used the computer to
			calculate where your home world is, hoping you'll be able
			to hide among your family and friends, counting on the fact
			that no one has escaped the prison planet before to mean
			they won't be looking for you. It's a desperate gamble, but
			it's better than being trapped for the rest of your life.
		""").split('\n'),

			util.trim("""
				You're not sure how long you spend traveling through
				the blackness of space, but finally you think you
				have arrived at the location the computer indicated
				your home would be. It's not a moment too soon; your
				fuel supply is nearly depleted. You buckle in and
				start the landing sequence; hoping to survive.""").split('\n'),
				
				util.trim("""

			Your arrival was more on the "crash" side of landing,
			but you're in one piece! You open the hatch to your rocket,
			ready to make your way home.""").split('\n'),
			
			util.trim("""
				Except something is wrong; where are the houses,
				the architecture, the parks and fountains? Even
				in the most uninhabited areas, it didn't look
				like this: barren, almost lifeless. You cautiously
				approach the small crowd gathered around your craft;
				they're a motley bunch, looking shifty and suspicious. """).split('\n'),
				
				util.trim("""
			"Where am I? Isn't this Earth?"
			
			They look at each other, and an older man with one eye
			and a lot of tattoos answers, "Sure was, stranger, but
			it ain't much of anythin' no more."
			
			"What do you mean? This is my home!"
			
			"Ain't no one's home; they moved the locals out of here
			when they made this a prison planet. You must be crazy
			to come here, cause everyone knows there ain't no way out!"
		""").split('\n')
		
		]
		self.current = 0
		self.counter = 0
import pygame
from src import scenefactory, util
from src.images import get_image
from src.font import get_text
from src import jukebox

page1 = util.trim("""
They say that in these enlightened times, society has
evolved beyond the need for barbaric customs of 
punishing crime. Long gone are the stocks, the electric
chair, and the prison cell; instead, those who inflict
pain or suffering on others are gently removed and
placed on a lush deserted planet where they are given
the freedom to live peaceful, fulfilling lives in a
community of equals.
""").split('\n')

page2 = util.trim("""
However, they are wrong.
""").split('\n')

page3 = util.trim("""
In truth, not just criminals but anyone who disagrees
with the ruling government is forever exiled to this
remote prison planet. Life on this prison planet is
brutal; it's difficult to scrape out a living when
some of your neighbors are petty thieves and killers,
and the knowledge that no one has ever escaped only
makes existence that much harder.
""").split('\n')