def setup(opts): checkpoint_path = opts['checkpoint'] model = load_model_from_checkpoint(checkpoint_path) msg = '[SETUP] Ran with options: seed = {}, truncation = {}' print(msg.format(opts['seed'], opts['truncation'])) model = ExampleModel(opts) return model
def setup(opts): msg = '[SETUP] Ran with options: seed = {}, truncation = {}' print(msg.format(opts['seed'], opts['truncation'])) model = ExampleModel(opts) return model
from os import environ from datetime import datetime from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from example_model import Base, ExampleModel # Create engine # db_uri = environ.get('SQLALCHEMY_DATABASE_URI') db_uri = 'sqlite:///data.db' engine = create_engine(db_uri, echo=True) # Create All Tables Base.metadata.create_all(engine) # create session Session = sessionmaker(bind=engine) session = Session() # Adding a Record newModel = ExampleModel(name='todd', description='im testing this', vip=True, join_date=datetime.now()) session.add(newModel) session.commit() print(newModel)
# Setup the model, initialize weights, set the configs of the model, etc. # Every model will have a different set of configurations and requirements. # Check https://sdk.runwayml.com/en/latest/runway_module.html to see a complete # list of supported configs. The setup function should return the model ready to # be used. setup_options = { 'truncation': number(min=5, max=100, step=1, default=10), 'seed': number(min=0, max=1000000) } @runway.setup(options=setup_options) def setup(opts): msg = '[SETUP] Run with options: seed = {}, truncation = {}' print(msg.format(opts['seed'], opts['truncation'])) model = ExampleModel(opts) return model # Every model needs to have at least one command. Every command allows to send # inputs and process outputs. To see a complete list of supported inputs and # outputs data types: https://sdk.runwayml.com/en/latest/data_types.html @runway.command(name='generate', inputs={ 'caption': text() }, outputs={ 'image': image(width=512, height=512) }) def generate(model, args): print('[GENERATE] Ran with caption value "{}"'.format(args['caption'])) # Generate a PIL or Numpy image based on the input caption, and return it output_image = model.run_on_input(args['caption']) return { 'image': output_image }