def main(argv):

  # parse arguments
  parser = argparse.ArgumentParser()
  parser.add_argument("-t", "--tag", help="tag images", action='store_true')
  parser.add_argument("-c", "--color", help="color images", action='store_true')
  parser.add_argument("-u", "--usage", help="usage", action='store_true')

  args, argv = parser.parse_known_args()

  if len(argv) == 1:
    imageurl = argv[0]
  else:
    imageurl = 'http://clarifai-img.s3.amazonaws.com/test/toddler-flowers.jpeg'

  api = ClarifaiApi()

  if args.usage:
    response = api.get_usage()
  elif not args.color:
    response = tag_images(api, imageurl)
  elif args.color and not args.tag:
    response = color_images(api, imageurl)
  else:
    raise Exception('call with --tag or --color for the image')

  print(json.dumps(response))
Beispiel #2
0
    def test_usage(self):
        api = ClarifaiApi()

        response = api.get_usage()
        self.assertTrue(response)
        self.assertTrue(len(response['user_throttles']) == 2)