コード例 #1
0
def dump_layers(config):
    dreamp = proc.Proc(model_path=config.get('model_path'),
                       model_name=config.get('model_name'))
    layers = dreamp.net_layers()
    layers = [layer for layer in layers if layer not in ['prob', 'data']]
    s = json.dumps(layers, indent=2, sort_keys=True)
    print(s)
コード例 #2
0
ファイル: test_proc.py プロジェクト: acrispin/test_python
 def test_ping_host_succeeds(self):
     ping = proc.Proc()
     with mock.patch("proc.subprocess") as subprocess:
         subprocess.Popen.return_value.returncode = 0
         ping.ping_host('localhost')
         subprocess.Popen.assert_called_once_with(['ping', 'localhost'],
                                                  shell=True)
コード例 #3
0
 def getProcs(self):
     """Returns a list of procs under this host.
     @rtype: list<Proc>
     @return: A list of procs under this host
     """
     response = self.stub.GetProcs(host_pb2.HostGetProcsRequest(host=self.data),
                                   timeout=Cuebot.Timeout)
     return [proc.Proc(p) for p in response.procs.procs]
コード例 #4
0
def dream_output_layers(config):
    dreamp = proc.Proc(model_path=config.get('model_path'),
                       model_name=config.get('model_name'))

    layers = [
        layer for layer in dreamp.net_layers() if layer.endswith('output')
    ]
    for layer in layers:
        log.info('Running layer [{}]'.format(layer))
        config['deepdream_params']['end'] = layer
        run_dream(config, dreamp=dreamp)
コード例 #5
0
def run_dream(config, dreamp=None):
    output_fp, config_output_fp = make_output_fp(config)
    if not dreamp:
        dreamp = proc.Proc(model_path=config.get('model_path'),
                           model_name=config.get('model_name'))

    dreamp.process_image(input_fp=config.get('input'),
                         output_fp=output_fp,
                         **config.get('deepdream_params'))

    with open(config_output_fp, 'wb') as f:
        f.write(json.dumps(config))

    return output_fp
コード例 #6
0
def continual_dream(config, n, zoom=False, intensify=0):
    # XXX Add the zoom code from google here?
    dreamp = proc.Proc(model_path=config.get('model_path'),
                       model_name=config.get('model_name'))
    log.info('Dreaming the same image {} times'.format(n))
    for i in range(n):
        if i and i % 10 == 0:
            if intensify:
                iterations = config['deepdream_params']['iter_n']
                ni = iterations + intensify
                log.info('Setting the iterations value to {}'.format(ni))
                config['deepdream_params']['iter_n'] = ni
        log.info('Dream iteration {}'.format(i + 1))
        output_fp = run_dream(config, dreamp=dreamp)
        config['input'] = output_fp
コード例 #7
0
def march(config, param, start, end, increment):
    dreamp = proc.Proc(model_path=config.get('model_path'),
                       model_name=config.get('model_name'))
    for i in range(start, end, increment):
        config['deepdream_params'][param] = i
        run_dream(config, dreamp=dreamp)
コード例 #8
0
ファイル: test_proc.py プロジェクト: acrispin/test_python
 def test_count_the_shells3(self):
     shell = proc.Proc()
     with mock.patch("proc.subprocess") as mocked_popen:
         mocked_popen.Popen.return_value.stdout = open('testps.out')
         mocked_popen.Popen.return_value.wait.return_value = False
         self.assertEqual(shell.count_the_shells(), 1)
コード例 #9
0
ファイル: test_proc.py プロジェクト: acrispin/test_python
 def test_count_the_shells2(self, mocked_popen):
     shell = proc.Proc()
     mocked_popen.Popen.return_value.stdout = open('testps.out')
     mocked_popen.Popen.return_value.wait.return_value = False
     self.assertEqual(shell.count_the_shells(), 1)
コード例 #10
0
ファイル: test_proc.py プロジェクト: acrispin/test_python
 def test_ping_host_fails_and_throws_exception(self):
     ping = proc.Proc()
     with mock.patch('proc.subprocess') as subprocess:
         subprocess.Popen.return_value.returncode = 1
         self.assertRaises(Exception, ping.ping_host, 'localhost')