Skip to content
Snippets Groups Projects
Commit c3184f53 authored by genekogan's avatar genekogan
Browse files

runway model

parent bb60f86d
No related branches found
No related tags found
No related merge requests found
absl-py==0.7.0
astor==0.7.1
certifi==2018.11.29
chardet==3.0.4
Click==7.0
Flask==1.0.2
Flask-Cors==3.0.7
gast==0.2.2
gevent==1.4.0
greenlet==0.4.15
grpcio==1.19.0
h5py==2.9.0
idna==2.8
itsdangerous==1.1.0
Jinja2==2.10
Keras-Applications==1.0.7
Keras-Preprocessing==1.0.9
Markdown==3.0.1
MarkupSafe==1.1.1
mock==2.0.0
numpy==1.16.2
pbr==5.1.2
Pillow==5.4.1
protobuf==3.6.1
requests==2.21.0
six==1.12.0
tensorflow-gpu==1.15.0
termcolor==1.1.0
urllib3==1.24.1
Werkzeug==0.14.1
wget==3.2
runway-python
\ No newline at end of file
entrypoint: python runway_model.py
python: 3.6
cuda: 10.0
spec:
gpu: True
cpu: False
files:
ignore:
- checkpoints/*
build_steps:
- pip install -r requirements.txt
\ No newline at end of file
import pickle
import numpy as np
import tensorflow as tf
import dnnlib.tflib as tflib
import runway
fmt = dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True)
@runway.setup(options={'checkpoint': runway.file(extension='.pkl')})
def setup(opts):
global Gs
tflib.init_tf()
with open(opts['checkpoint'], 'rb') as file:
_G, _D, Gs = pickle.load(file, encoding='latin1')
noise_vars = [var for name, var in Gs.components.synthesis.vars.items() if name.startswith('noise')]
tflib.set_vars({var: rnd.randn(*var.shape.as_list()) for var in noise_vars})
return Gs
generate_inputs = {
'z': runway.vector(512, sampling_std=0.5),
'truncation': runway.number(min=0, max=1, default=0.8, step=0.01)
}
@runway.command('generate', inputs=generate_inputs, outputs={'image': runway.image})
def convert(model, inputs):
z = inputs['z']
truncation = inputs['truncation']
latents = z.reshape((1, 512))
images = model.run(latents, None, truncation_psi=truncation, randomize_noise=False, output_transform=fmt)
output = np.clip(images[0], 0, 255).astype(np.uint8)
return {'image': output}
if __name__ == '__main__':
runway.run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment