예제 #1
0
    def __init__(self,
                 workspace_server_id=None,
                 host='localhost',
                 port=9008,
                 user_id='admin',
                 password='******',
                 debug=False):

        self.printer = pprint.PrettyPrinter(indent=4)

        config = skil_client.Configuration()
        config.host = "{}:{}".format(host, port)
        config.debug = debug
        self.config = config
        self.uploads = []
        self.uploaded_model_names = []
        self.auth_headers = None

        self.api_client = skil_client.ApiClient(configuration=config)
        self.api = skil_client.DefaultApi(api_client=self.api_client)

        try:
            self.printer.pprint('>>> Authenticating SKIL...')
            credentials = Cred(user_id=user_id, password=password)

            token = self.api.login(credentials)
            self.token = token.token
            config.api_key['authorization'] = self.token
            config.api_key_prefix['authorization'] = "Bearer"
            self.printer.pprint('>>> Done!')
        except api_exception as e:
            raise Exception(
                "Exception when calling  DefaultApi->login: {}\n".format(e))

        if workspace_server_id:
            self.server_id = workspace_server_id
        else:
            self.server_id = self.get_default_server_id()

        result = {
            'host': host,
            'port': port,
            'user_id': user_id,
            'password': password,
            'debug': debug,
            'workspace_server_id': self.server_id
        }
        save_skil_config(result)
예제 #2
0
    image_batch = tf.stack(crops)
    return image_batch

def make_single_image_batch(image_path, coder):
    image_data = tf.gfile.FastGFile(image_path, 'rb').read()
    image = coder.decode_jpeg(image_data)
    crop = tf.image.resize_images(image, (227,227))
    image_batch = tf.stack([crop])
    return image_batch

with tf.Session() as sess:
    coder = ImageCoder()
    image_batch = make_multi_crop_batch(image_file, coder)
    image_batch = image_batch.eval()

configuration = skil_client.Configuration()
configuration.host = 'http://192.168.1.128:9008'
configuration.username = '******'
configuration.password = '******'

r = requests.post("http://192.168.1.128:9008/login", json={"userId": "admin", "password": "******"})
token = r.json()['token']

configuration.api_key['authorization'] = f'Bearer {token}'
api_instance = skil_client.DefaultApi(skil_client.ApiClient(configuration))


list_ind_array = [[convert_indarray(np.expand_dims(image_batch[i,:,:,:], axis=0))] for i in range(12)]

batch_results = []
index = 0