Exemple #1
0
    def train_blocking(self):
        if (self.uobject.VerbosePythonLog):
            ue.log(self.uobject.TensorFlowModule +
                   ' training started on bt thread.')

        #calculate the time it takes to train your network
        start = time.time()
        self.trained = self.tfapi.onBeginTraining()
        stop = time.time()

        if self.trained is None:
            ue.log(
                'Training Note: no summary object returned from training. See your onBeginTraining(): method'
            )
            return

        if 'summary' in self.trained:
            summary = self.trained['summary']
        else:
            summary = {}

        summary['elapsed'] = stop - start

        #run callbacks only if we're still in a valid game world
        if (self.ValidGameWorld):
            ue.run_on_gt(self.training_complete, summary)
Exemple #2
0
 def custom_event(self, event, data=None, useJson=False):
     #embedd the data
     eventdata = {}
     eventdata['event'] = event
     eventdata['data'] = data
     eventdata['useJson'] = useJson
     ue.run_on_gt(self.custom_event_gt, eventdata)
Exemple #3
0
    def setup_blocking(self):

        #call the api setup (may be multi-threaded!)
        self.tfapi.onSetup()

        #run callbacks only if we're still in a valid game world
        if (self.ValidGameWorld):
            ue.run_on_gt(self.setup_complete)
def testaction(args=""):
    ue.log('starting action with <' + str(args) + '>')
    #onfinished()

    #pretend you take time to finish
    time.sleep(1)
    ue.log('wait complete')
    ue.run_on_gt(onfinished, args)
    ue.run_on_gt(onfinishedempty)
Exemple #5
0
    def json_input_blocking(self, args):
        #pass the raw json to the script to handle
        resultJson = self.tfapi.onJsonInput(json.loads(args))

        if (self.uobject.ShouldUseMultithreading):
            #pass prediction json back
            if (self.ValidGameWorld):
                ue.run_on_gt(self.json_input_gt_callback, resultJson)
        else:
            self.json_input_gt_callback(resultJson)
def backgroundAction(args=None):
    #ue.log(args)
    action = args[0]
    if len(args) > 1:
        callback = args[1]

    #call the blocking action
    action()

    #return the result if we have a callback
    if callback:
        ue.run_on_gt(callback)
	def trainBlocking(self):
		if(self.uobject.VerbosePythonLog):
			ue.log(self.uobject.TensorFlowModule + ' training started on bt thread.')

		#calculate the time it takes to train your network
		start = time.time()
		self.trained = self.tf.train()
		stop = time.time()

		if 'summary' in self.trained:
			summary = self.trained['summary']
		else:
			summary = {}

		summary['elapsed'] = stop-start

		ue.run_on_gt(self.trainingComplete, summary)
    def trainBlocking(self):
        if (self.uobject.VerbosePythonLog):
            ue.log(self.uobject.TensorFlowModule +
                   ' training started on bt thread.')

        #calculate the time it takes to train your network
        start = time.time()
        self.trained = self.tf.train()
        stop = time.time()

        if 'summary' in self.trained:
            summary = self.trained['summary']
        else:
            summary = {}

        summary['elapsed'] = stop - start

        ue.run_on_gt(self.trainingComplete, summary)
Exemple #9
0
    def train_blocking(self):
        if (self.uobject.VerbosePythonLog):
            ue.log(self.uobject.TensorFlowModule +
                   ' training started on bt thread.')

        #calculate the time it takes to train your network
        start = time.time()
        self.trained = self.tfapi.onBeginTraining()
        stop = time.time()

        if hasattr(self.trained, 'summary'):
            summary = self.trained['summary']
        else:
            summary = {}

        summary['elapsed'] = stop - start

        #run callbacks only if we're still in a valid game world
        if (self.ValidGameWorld):
            ue.run_on_gt(self.training_complete, summary)
def backgroundAction(args=None):
    #ue.log(args)

    action = args[0]
    actionArgs = None

    if len(args) > 1:
        actionArgs = args[1]

    if len(args) > 2:
        callback = args[2]

    #call the blocking action
    if actionArgs:
        result = action(actionArgs)
    else:
        result = action()

    #return the result if we have a callback
    if callback:
        if result:
            ue.run_on_gt(callback, result)
        else:
            ue.run_on_gt(callback)
def doLongTask():
    ue.log('started my task')

    for x in range(1, 10):
        time.sleep(0.5)
        ue.run_on_gt(progresscallback, x)