예제 #1
0
def main():
  logger = logging.getLogger('clarifai')
  logger.handlers = []
  logger.addHandler(logging.StreamHandler())
  logger.setLevel(logging.INFO)

  app = ClarifaiApp()

  delete_all_inputs(app, logger)
  app.models.delete_all()

  app.wait_until_inputs_delete_finish()
  app.wait_until_models_delete_finish()

  image1 = app.inputs.create_image_from_url(
      urls[0],
      concepts=['train_custom_prepare', 'railway_custom_prepare'],
      allow_duplicate_url=True)
  image2 = app.inputs.create_image_from_url(
      urls[3], concepts=['dog_custom_prepare', 'animal_custom_prepare'], allow_duplicate_url=True)

  app.wait_for_specific_input_uploads_to_finish(ids=[image1.input_id, image2.input_id])

  model_id = uuid.uuid4().hex

  model1 = app.models.create(
      model_id=model_id,
      concepts=[
          'train_custom_prepare', 'railway_custom_prepare', 'dog_custom_prepare',
          'animal_custom_prepare'
      ])
  model1.train(timeout=120, raise_on_timeout=True)
예제 #2
0
def main():
  logger = logging.getLogger('clarifai')
  logger.handlers = []
  logger.addHandler(logging.StreamHandler())
  logger.setLevel(logging.INFO)

  app = ClarifaiApp()

  delete_all_inputs(app, logger)
  app.models.delete_all()

  app.wait_until_inputs_delete_finish()
  app.wait_until_models_delete_finish()

  app.inputs.create_image_from_url(
      urls[0],
      concepts=['train_custom_prepare', 'railway_custom_prepare'],
      allow_duplicate_url=True)
  app.inputs.create_image_from_url(
      urls[3], concepts=['dog_custom_prepare', 'animal_custom_prepare'], allow_duplicate_url=True)

  model_id = uuid.uuid4().hex

  model1 = app.models.create(
      model_id=model_id,
      concepts=[
          'train_custom_prepare', 'railway_custom_prepare', 'dog_custom_prepare',
          'animal_custom_prepare'
      ])
  model = model1.train(timeout=240)

  if model.model_status_code != 21100:
    logger.error('Model not trained in 240 seconds with 2 inputs. Test could not continue.')
    exit(2)
예제 #3
0
def main():
  logger = logging.getLogger('clarifai')
  logger.handlers = []
  logger.addHandler(logging.StreamHandler())
  logger.setLevel(logging.INFO)

  app = ClarifaiApp()

  delete_all_inputs(app, logger)
  app.models.delete_all()

  app.wait_until_inputs_delete_finish()
  app.wait_until_models_delete_finish()

  app.inputs.create_image_from_url(
      urls[0], concepts=['train', 'railway'], allow_duplicate_url=True)
  app.inputs.create_image_from_url(urls[3], concepts=['dog', 'animal'], allow_duplicate_url=True)

  model_id = uuid.uuid4().hex

  model1 = app.models.create(model_id=model_id, concepts=['train', 'railway', 'dog', 'animal'])
  model = model1.train(timeout=240)

  if model.model_status_code != 21100:
    logger.error('Model not trained in 240 seconds with 2 inputs. Test could not continue.')
    exit(2)