Exemplo n.º 1
0
def test_e2e(Skil):
    model_path = './dummy.pb'

    skil_server = Skil()
    skil_server.upload_model(model_path)

    ws = WorkSpace(skil_server, 'jupyter_ws')
    experiment = Experiment(ws, 'test_exp')

    model = Model(model_path, experiment)
    model.add_evaluation(accuracy=0.93)

    deployment = Deployment(skil_server, 'test_deployment')
    model.deploy(deployment, start_server=False)
Exemplo n.º 2
0
def test_experiment(Skil):
    skil_server = Skil()
    ws = WorkSpace(skil_server)
    experiment = Experiment(ws)
Exemplo n.º 3
0
from skil import Skil, WorkSpace, Experiment, Model, Deployment
from keras.datasets import mnist

skil_server = Skil()
work_space = WorkSpace(skil_server)
experiment = Experiment(work_space)
model = Model('model.pb', model_id='tf_model', experiment=experiment)

deployment = Deployment(skil_server)
service = model.deploy(deployment,
                       input_names=['input'],
                       output_names=['output'])

(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_test = x_test.reshape(10000, 784)
x_test = x_test.astype('float32')
x_test /= 255

print(service.predict_single(x_test[0]))
print(service.predict(x_test[:10]))
Exemplo n.º 4
0
from skil import Skil, WorkSpace, Experiment, Model, Deployment
import json

# Initialize a new experiment in a workspace
skil_server = Skil()
ws = WorkSpace(skil_server)
experiment = Experiment(ws)
deployment = Deployment(skil_server, "keras_models")

skil_models = []
for epoch in range(2):
    model_name = 'model_{epoch:02d}.hdf5'.format(epoch=epoch + 1)
    model = Model(model_name, id=epoch, experiment=experiment)
    model.deploy(start_server=False, deployment=deployment)
    skil_models.append(model)

with open('history.json', 'r') as f:
    history = json.loads(f.read())
    acc = history.get('val_acc')
best_model = skil_models[acc.index(max(acc))]
best_model.serve()
def test_work_space(Skil):
    skil_server = Skil()
    ws = WorkSpace(skil_server)
Exemplo n.º 6
0
from skil import Skil, WorkSpace, Experiment, Model, Deployment
import json

# Initialize a new experiment in a workspace
skil_server = Skil()

work_space = WorkSpace(skil_server, name='mnist-workspace')
experiment = Experiment(work_space, name='mnist-experiment')

deployment = Deployment(skil_server, name='mnist-deployment')

# Deploy all models with SKIL
skil_services = []
for epoch in range(2):
    model_name = 'model_{epoch:02d}.hdf5'.format(epoch=epoch + 1)
    model = Model(model_name, model_id=epoch, experiment=experiment)
    service = model.deploy(start_server=False, deployment=deployment)
    skil_services.append(service)

# Serve the best one
with open('history.json', 'r') as f:
    history = json.loads(f.read())
    acc = history.get('val_acc')
best_service = skil_services[acc.index(max(acc))]
best_service.start()
Exemplo n.º 7
0
#import skil_client
#
#configuration = skil_client.Configuration()
#configuration.host = 'http://52.15.103.124:9008'
#configuration.api_key['authorization'] = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJTa2lsVXNlciIsInN1YiI6IntcInVzZXJJZFwiOlwiYWRtaW5cIixcInVzZXJOYW1lXCI6XCJhZG1pblwiLFwicm9sZVwiOlwiYWRtaW5cIixcInNjb3BlXCI6XCJhZG1pblwifSIsImlzcyI6IlNraWxBdXRoTWFuYWdlciIsImV4cCI6MTU4NjgyODcxMCwiaWF0IjoxNTU1MjkyNzEwfQ.vXXpr0kk9H8nMbkcM8sPWPJwuws1GGvI8SWc76qKvUo'
#api_instance = skil_client.DefaultApi(skil_client.ApiClient(configuration))
#api_response = api_instance.predictimage("yolo", "default", "yolomodel", image='input.jpg')
#
from skil import Skil

skil_server = Skil(host='52.15.103.124', password='******')

from skil import WorkSpace, Experiment, Model

work_space = WorkSpace(skil_server, name="Object detection project")
experiment = Experiment(work_space, name="YOLO")
model = Model('yolo_v2.pb', name='yolo_model', experiment=experiment)
#
from skil import Deployment

deployment = Deployment(skil_server)
service = model.deploy(deployment,
                       scale=1,
                       input_names=['input'],
                       output_names=['output'])
#
#from skil.utils.yolo import annotate_image
#import cv2
#
#image = cv2.imread('input.jpg')
#detection = service.detect_objects(image)
Exemplo n.º 8
0
                'deployment_id': ''
            },
            f)

with open('.skil', 'r') as f:
    skil_conf = json.load(f)

# Connect to SKIL and create an experiment for storing our model experiments.
skil_server = Skil(host=skil_conf['host'],
                   port=skil_conf['port'],
                   user_id=skil_conf['username'],
                   password=skil_conf['password'])

work_space = None
if skil_conf['workspace_id'] == '':
    work_space = WorkSpace(skil_server, name="Mnist Sample")
    skil_conf['workspace_id'] = work_space.id
else:
    work_space = skil.get_workspace_by_id(None, skil_server,
                                          skil_conf['workspace_id'])

experiment = None
if skil_conf['experiment_id'] == '':
    experiment = Experiment(work_space, name='Simple MLP')
    skil_conf['experiment_id'] = experiment.id
else:
    experiment = skil.get_experiment_by_id(work_space,
                                           skil_conf['experiment_id'])

with open('.skil', 'w') as f:
    json.dump(skil_conf, f)