Code Monkey home page Code Monkey logo

clarifai-python's People

Contributors

ackizilkale avatar adithyan-sukumar avatar andrewemendez avatar bohemia420 avatar brendt-napp avatar cemigo114 avatar cjkjvfnby avatar deigen avatar harmitminhas96 avatar harmon758 avatar iankelk avatar isaac-chung avatar jamim avatar johntorcivia avatar luv-bansal avatar mansi-k avatar markmc avatar mogith-pn avatar phatvo9 avatar sainivedh avatar sanjaychelliah avatar sriram-clarifai avatar stmugisha avatar tazarov avatar tiit-clarifai avatar travertischio avatar wemoveon2 avatar yvetteclarifai avatar yvettez2017 avatar zeiler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clarifai-python's Issues

expired token

Hey.
For few days now I receive this errors:
code: 401, reason: Unauthorized, response:{u'status': {u'code': 11001, u'description': u'Invalid authentication token', u'details': u'expired token'}}

I think the reason is because my token is expired. Indeed I save the clarifaiApp and modelvariables because it takes too long to initialize (at least 5 seconds).

Is there any workaround to avoid initializing the token for every photo I want to process?

app.model.predict_by_base64 does not catch ConnectionError

I've had to add to my code the following, but would be nice if this was caught by ApiError

    def model_prediction(self, image):
        """Make a prediction based on an image."""
        try:
            response = self.model.predict_by_base64(encode_image(image))
            if response['status']['description'] == 'Ok':
                return response
        except requests.exceptions.ConnectionError:
            _LOGGER.error("ConnectionError: Is %s accessible?", CLASSIFIER)
            return None

Django error when reading json response

Hello,
I started using clarifai with django, in the home view when I tried to use the example provided in README:

app = ClarifaiApp('xxxxxxxx', 'xxxxxxxx') model = app.models.get('general-v1.3') print(model.predict_by_url('https://samples.clarifai.com/metro-north.jpg'))

An error raised:

TypeError at /
the JSON object must be str, not 'bytes'

Debugging I found that if I commented the line 2223 in the file clarifi/rest/client.py, everything was fine:

logger.debug("\nRESULT:\n%s", pformat(json.loads(res.content)))

Is there anything unproperly configured in my side or is it a library issue? Thanks for any help provided.

Bugs in client / example

Hi guys,

there's a typo in your example:

"from py.client import ClarifaiApi"
should probably be
"from client import ClarifaiApi"

But it would certainly make sense to pack the API client files into an extra directory, so the import would be:
from clarifai.client import ClarifaiApi

In any case: I do get the following error when trying out this simple example:
client.ApiError: URLError(gaierror(11004, 'getaddrinfo failed'),)

That happens both for local and remote files. Any suggestions?

Here's the full trackback:

Traceback (most recent call last):
File "D:\Web\Development\temp.py", line 6, in
print clarifai_api.tag_image_urls('http://pixabay.com/static/uploads/photo/2012/09/08/21/51/balkan-anemone-56414_640.jpg')
File "D:\web\django\python\lib\site-packages\client.py", line 215, in tag_image_urls
return self._multi_imageurl_op(image_urls, ['tag'], model=model)
File "D:\web\django\python\lib\site-packages\client.py", line 367, in _multi_imageurl_op
self._check_batch_size(image_urls)
File "D:\web\django\python\lib\site-packages\client.py", line 331, in _check_batch_size
self.get_info() # sets the image size and other such info from server.
File "D:\web\django\python\lib\site-packages\client.py", line 117, in get_info
self._get_json_response, url, data)
File "D:\web\django\python\lib\site-packages\client.py", line 413, in _get_raw_response
headers = header_func()
File "D:\web\django\python\lib\site-packages\client.py", line 400, in _get_json_headers
headers = self._get_authorization_headers()
File "D:\web\django\python\lib\site-packages\client.py", line 393, in _get_authorization_headers
access_token = self.get_access_token()
File "D:\web\django\python\lib\site-packages\client.py", line 103, in get_access_token
raise ApiError(e)
client.ApiError: URLError(gaierror(11004, 'getaddrinfo failed'),)

Import gives ApiError, ApiThrottledError, ApiBadRequestError

Hi

I am trying to use the ClarifaiApi to tag images using the Python client and I receive the following error when I try to import ClarifaiApi.

Traceback (most recent call last):
from clarifai.client import ClarifaiApi
File "C:\Python34\lib\site-packages\clarifai\client__init__.py", line 3, in
from .client import ClarifaiApi, ApiError, ApiThrottledError, ApiBadRequestError
File "C:\Python34\lib\site-packages\clarifai\client\client.py", line 5
except Exception, e:
^
SyntaxError: invalid syntax

I can't seem to find any documentation related to this error. Any help would be appreciated.

image or video bigger than 1.2M will failed with beloe error info

ApiError:{u'status_code': u'ALL_ERROR', u'status_msg': u'All images in request have failed. Please review the error messages per image.', u'meta': {}, u'results': [{u'docid': 6969405136956554562, u'url': u'http://video-test.eengoo.com/JUFNERPILCQEHCZXSAZVCKZBYVUAQUXF.mp4/14/oss-cn-hangzhou.aliyuncs.com?OSSAccessKeyId=DmbQjIq5KjcRWJ6A&Expires=1477453930&Signature=F3lI%2FKaQsy23JdOHy9ZO1VpbSjU%3D', u'status_code': u'CLIENT_ERROR', u'status_msg': u'Data loading failed, see results for details. ', u'local_id': u'', u'result': {u'error': u"'url' could not be downloaded 'http://video-test.eengoo.com/JUFNERPILCQEHCZXSAZVCKZBYVUAQUXF.mp4/14/oss-cn-hangzhou.aliyuncs.com?OSSAccessKeyId=DmbQjIq5KjcRWJ6A&Expires=1477453930&Signature=F3lI%2FKaQsy23JdOHy9ZO1VpbSjU%3D'"}, u'docid_str': u'0b4007f252be3f5160b84d0bec13fd42'}]}

i also use curl to do same thing, and found that if i use curl post, it is ok:
curl "https://api.clarifai.com/v1/tag/" \ -X POST --data-urlencode "url=http://yinnut-video-test.oss-cn-hangzhou.aliyuncs.com/14%2F2ec26f9bceb7fea5c771c735f8759c45%2FJUFNERPILCQEHCZXSAZVCKZBYVUAQUXF.mp4?OSSAccessKeyId=DmbQjIq5KjcRWJ6A&Expires=1477485065&Signature=FbolxWKyihbYtcu0caBtfmgMtyE%3D" \ -H "Authorization: Eengoo {token}"
but while i use curl get, it will not work:
curl "https://api.clarifai.com/v1/tag/?url=http://yinnut-video-test.oss-cn-hangzhou.aliyuncs.com/14%2F2ec26f9bceb7fea5c771c735f8759c45%2FJUFNERPILCQEHCZXSAZVCKZBYVUAQUXF.mp4?OSSAccessKeyId=DmbQjIq5KjcRWJ6A&Expires=1477485065&Signature=FbolxWKyihbYtcu0caBtfmgMtyE%3D" \ -H "Authorization: Eengoo {token}"

i also notice that, in your demo web, if i upload image or video from local, it will be ok, and if i use url, it will not work. i have send emails to your support email box, please help to fix this proble.

or if there are some selection that i can use tag_image_urls API with POST in your code, please inform me.
here is my code:
result = self.clarifai_api.tag_image_urls(urls=video_url,language=language) if result['status_code']=='TOKEN_EXPIRED': self.update_token() result = self.clarifai_api.tag_image_urls(urls=video_url,language=language) assert result['status_code'] == 'OK' assert result['results'][0]['url'] == video_url except ApiError as e: self.logger.error('calrifai tags error of {0} with {1}'.format(video_url,e)) self.logger.error(traceback.format_exc()) return

Cannot import name 'rest', Installation problems on Ubuntu 16.04

I usually use conda for python package management, and was unable to get past this error

With Conda

which python returns:
/home/sam/anaconda3/envs/python352/bin/python

which clarifai returns:
home/sam/anaconda3/envs/python352/bin/clarifai

python version 3.5.2
clarifai verison 2.0.29

Traceback (most recent call last):
  File "clarifai.py", line 2, in <module>
    from clarifai import rest
  File "/home/sam/Code/barnes-staff-backend/clarifai.py", line 2, in <module>
    from clarifai import rest
ImportError: cannot import name 'rest'

I switched to VirtualEnv and followed instructions that @robertwenquan gave on #66 exactly

With VirtualEnv

I get a slightly different but very similar error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sam/Code/barnes-staff-backend/clarifai.py", line 2, in <module>
    from clarifai import rest
ImportError: cannot import name 'rest'

which python returns:
/home/sam/Code/barnes-staff-backend/bb/bin/python
which clarifai return:
/home/sam/Code/barnes-staff-backend/bb/bin/clarifai

python version 3.5.2
clarifai verison 2.0.29

I have tried different versions of clarifai, and using different python executables and I am having no luck at all.

Headache testing ClarifaiApp.model.predict_by_base64

Hi @rok-povsic I'm having a real hard time trying to test ClarifaiApp.model.predict_by_base64', perhaps you can make a suggestion?

@pytest.fixture
def mock_predict_by_base64_with_error():
    """Mock a predict_by_base64 error."""
    resource = 'https://www.mock.com/url'
    params = {}
    method = 'GET'
    response = None
    error = ApiError(resource, params, method, response)
    with patch('clarifai.rest.ClarifaiApp.model.predict_by_base64',
               side_effect=error) as _mock_response:
        yield _mock_response

Model training failing with error code 21111

While training my own custom model using the description provided on https://sdk.clarifai.com/python/docs/2.0.10/tutorial.html , the training is failing constantly. I even tried deleting all my custom models and restarting the process, but to no avail. This is the status message as pasted below.
In [38]: model.get_info() Out[38]: {u'model': {u'app_id': u'be6d9581a08847dc80c325f3c530e563', u'created_at': u'2016-10-29T07:01:11Z', u'id': u'flower-v0.1', u'model_version': {u'created_at': u'2016-10-29T07:01:17Z', u'id': u'b981b8b3e912438b82f5a43bdd2a15e8', u'status': {u'code': 21111, u'description': u'Model training had no positive examples.'}}, u'name': u'flower-v0.1', u'output_info': {u'message': u'Show output_info with: GET /models/{model_id}/output_info', u'output_config': {u'closed_environment': False, u'concepts_mutually_exclusive': False}, u'type': u'concept'}}, u'status': {u'code': 10000, u'description': u'Ok'}}

As you can see, the training is failing with error code 21111 saying 'Model training had no positive examples.' Any help would be appreciated. I am attaching a snapshot of my ipython console.
Thanks.

error_msg.txt

Several errors while trying to install Clarifai API Python Client

I have Python 2.7.13 installed on Windows 7 64-bit, but each time I'm going to install Clarifai Python Client, I get various errors. Now stuck at the following error:
error
There are two folders named "setuptools-34.3.2.dist-info" and "setuptools" in C:\Python27\Lib\site-packages directory, also "clarifai-2.0.20.dist-info" and "clarifai", but I can't set my Clarifai credientals.

Can't get video prediction to work

Hello Clarifai team,

I am making a simple Python3 + Tkinter + Clarifai to show the output of the API when supplying image/video files to it. However, I am facing some issues specifically with video files.

My code:

class Clarifi:

	def client(self, app_id, app_secret):

		app = ClarifaiApp(app_id, app_secret)

		# get the general model
		return app.models.get("general-v1.3")

	def run_using_link(self, app_id, app_secret, link):

		return self.client(app_id, app_secret).predict_by_url(url=link);

If I call run_using_link with an image url I get this as an output:

screen shot 2017-02-27 at 10 29 05 pm

However, if I call passing a video (MP4) the output is:

screen shot 2017-02-27 at 10 29 58 pm

I am also facing some difficulties to understand how can I send local files using the API. Having said that, I could not find how to do video uploads with local files.

I got this code:

def run_using_file(self, app_id, app_secret, file_path):

		api = ClarifaiApi(app_id, app_secret)
		return api.tag([open(file_path, "r")])

from another ticket: #36

You guys can find the full source code at: https://github.com/danielmapar/ClarifaiDemo

Error requesting access token

I received this error when following the instructions on the readme. This had to have happened within the past month or so because I have v0.2.1 on my laptop and it worked just fine.

Python 3.5.2 (default, Sep 10 2016, 08:21:44) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from clarifai.client import ClarifaiApi
>>> 
>>> clarifai_api = ClarifaiApi()
>>> 
>>> result = clarifai_api.tag_images(open('/home/bkvaluemeal/Downloads/test.jpg', 'rb'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/clarifai/client/client.py", line 239, in tag
    language=language)
  File "/usr/local/lib/python3.5/dist-packages/clarifai/client/client.py", line 605, in _multi_data_op
    media = self._process_files(files)
  File "/usr/local/lib/python3.5/dist-packages/clarifai/client/client.py", line 526, in _process_files
    self._check_batch_size(input_files)
  File "/usr/local/lib/python3.5/dist-packages/clarifai/client/client.py", line 550, in _check_batch_size
    self.get_info()  # sets the image size and other such info from server.
  File "/usr/local/lib/python3.5/dist-packages/clarifai/client/client.py", line 173, in get_info
    self._get_json_headers, self._get_json_response, url, kwargs)
  File "/usr/local/lib/python3.5/dist-packages/clarifai/client/client.py", line 674, in _get_raw_response
    headers = header_func()
  File "/usr/local/lib/python3.5/dist-packages/clarifai/client/client.py", line 660, in _get_json_headers
    headers = self._get_authorization_headers()
  File "/usr/local/lib/python3.5/dist-packages/clarifai/client/client.py", line 653, in _get_authorization_headers
    access_token = self.get_access_token()
  File "/usr/local/lib/python3.5/dist-packages/clarifai/client/client.py", line 151, in get_access_token
    req = urllib2.Request(url, data, headers)
  File "/usr/lib/python3.5/urllib/request.py", line 269, in __init__
    self.full_url = url
  File "/usr/lib/python3.5/urllib/request.py", line 295, in full_url
    self._parse()
  File "/usr/lib/python3.5/urllib/request.py", line 324, in _parse
    raise ValueError("unknown url type: %r" % self.full_url)
ValueError: unknown url type: 'api.clarifai.com/v1/token/'

Protobuf error when importing both google cloud and clarifai

`Python 2.7.15 (default, Jun 27 2018, 13:05:28)
[GCC 8.1.1 20180531] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from clarifai.rest import ClarifaiApp
from google.cloud import speech
Traceback (most recent call last):
File "", line 1, in
File "/home/jonm/Code/venv2/lib/python2.7/site-packages/google/cloud/speech.py", line 17, in
from google.cloud.speech_v1 import SpeechClient
File "/home/jonm/Code/venv2/lib/python2.7/site-packages/google/cloud/speech_v1/init.py", line 17, in
from google.cloud.speech_v1.gapic import speech_client
File "/home/jonm/Code/venv2/lib/python2.7/site-packages/google/cloud/speech_v1/gapic/speech_client.py", line 22, in
import google.api_core.operation
File "/home/jonm/Code/venv2/lib/python2.7/site-packages/google/api_core/operation.py", line 45, in
from google.longrunning import operations_pb2
File "/home/jonm/Code/venv2/lib/python2.7/site-packages/google/longrunning/operations_pb2.py", line 23, in
from google.longrunning.operations_grpc_pb2 import *
File "/home/jonm/Code/venv2/lib/python2.7/site-packages/google/longrunning/operations_grpc_pb2.py", line 16, in
from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
File "/home/jonm/Code/venv2/lib/python2.7/site-packages/google/api/annotations_pb2.py", line 16, in
from google.api import http_pb2 as google_dot_api_dot_http__pb2
File "/home/jonm/Code/venv2/lib/python2.7/site-packages/google/api/http_pb2.py", line 22, in
serialized_pb=_b('\n\x15google/api/http.proto\x12\ngoogle.api"+\n\x04Http\x12#\n\x05rules\x18\x01 \x03(\x0b\x32\x14.google.api.HttpRule"\xea\x01\n\x08HttpRule\x12\x10\n\x08selector\x18\x01 \x01(\t\x12\r\n\x03get\x18\x02 \x01(\tH\x00\x12\r\n\x03put\x18\x03 \x01(\tH\x00\x12\x0e\n\x04post\x18\x04 \x01(\tH\x00\x12\x10\n\x06\x64\x65lete\x18\x05 \x01(\tH\x00\x12\x0f\n\x05patch\x18\x06 \x01(\tH\x00\x12/\n\x06\x63ustom\x18\x08 \x01(\x0b\x32\x1d.google.api.CustomHttpPatternH\x00\x12\x0c\n\x04\x62ody\x18\x07 \x01(\t\x12\x31\n\x13\x61\x64\x64itional_bindings\x18\x0b \x03(\x0b\x32\x14.google.api.HttpRuleB\t\n\x07pattern"/\n\x11\x43ustomHttpPattern\x12\x0c\n\x04kind\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x01(\tB'\n\x0e\x63om.google.apiB\tHttpProtoP\x01\xf8\x01\x01\xa2\x02\x04GAPIb\x06proto3')
File "/home/jonm/Code/venv2/lib/python2.7/site-packages/google/protobuf/descriptor.py", line 878, in new
return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "google/api/http.proto":
google.api.Http.rules: "google.api.Http.rules" is already defined in file "proto/google/api/http.proto".
google.api.Http: "google.api.Http" is already defined in file "proto/google/api/http.proto".
google.api.HttpRule.pattern: "google.api.HttpRule.pattern" is already defined in file "proto/google/api/http.proto".
google.api.HttpRule.selector: "google.api.HttpRule.selector" is already defined in file "proto/google/api/http.proto".
google.api.HttpRule.get: "google.api.HttpRule.get" is already defined in file "proto/google/api/http.proto".
google.api.HttpRule.put: "google.api.HttpRule.put" is already defined in file "proto/google/api/http.proto".
google.api.HttpRule.post: "google.api.HttpRule.post" is already defined in file "proto/google/api/http.proto".
google.api.HttpRule.delete: "google.api.HttpRule.delete" is already defined in file "proto/google/api/http.proto".
google.api.HttpRule.patch: "google.api.HttpRule.patch" is already defined in file "proto/google/api/http.proto".
google.api.HttpRule.custom: "google.api.HttpRule.custom" is already defined in file "proto/google/api/http.proto".
google.api.HttpRule.body: "google.api.HttpRule.body" is already defined in file "proto/google/api/http.proto".
google.api.HttpRule.additional_bindings: "google.api.HttpRule.additional_bindings" is already defined in file "proto/google/api/http.proto".
google.api.HttpRule: "google.api.HttpRule" is already defined in file "proto/google/api/http.proto".
google.api.CustomHttpPattern.kind: "google.api.CustomHttpPattern.kind" is already defined in file "proto/google/api/http.proto".
google.api.CustomHttpPattern.path: "google.api.CustomHttpPattern.path" is already defined in file "proto/google/api/http.proto".
google.api.CustomHttpPattern: "google.api.CustomHttpPattern" is already defined in file "proto/google/api/http.proto".
google.api.Http.rules: "google.api.HttpRule" seems to be defined in "proto/google/api/http.proto", which is not imported by "google/api/http.proto". To use it here, please add the necessary import.
google.api.HttpRule.custom: "google.api.CustomHttpPattern" seems to be defined in "proto/google/api/http.proto", which is not imported by "google/api/http.proto". To use it here, please add the necessary import.
google.api.HttpRule.additional_bindings: "google.api.HttpRule" seems to be defined in "proto/google/api/http.proto", which is not imported by "google/api/http.proto". To use it here, please add the necessary import.
`

How to setup clarifai v2.0.14 in ubuntu

Hi!
I have successfully installed the clarifai client. However, when I run the clarifai config command, I get an error that clarifai is not a command.

How can I fix this? Otherwise, how else can I set up my client id and client secret?

Thanks in advance

How to return filenames as local_id in response json objects?

Hi

I am running clarifai Python client to tag images in a folder on my local drive. I get the response array of tags for all images, however, I am unable to determine which response corresponds to which image as the order of images is not the same as that in the folder.

I would like to know if there a way to return image filename in response json object along with the tags? The documentation says there is a response parameter local_id which is "a user-supplied identifier, echoed back in each result if supplied in the request, or the URL of the image is returned if available." Can anyone tell me the syntax to provide local_id when making a call to api.tag_images(images) for a folder?

Any help would be appreciated!

Install clarifai on windows

Hello,
Why should I download and install MS Build tools (which are about 5gb with VS) for using clarifai in python? Pls fix it and build what you need on your side. This installation pattern is very unfriendly

Support Python 3.6

Currently Clarifai requires Pillow == 2.9.0 which supports python 2.6, 2.7, 3.2, 3.3, 3.4, 3.5
It would be nice to support Pillow >= 4.0.0 which supports python 3.6.0 if possible. Thanks!

configuration error on windows

hi I encountered the following error

E:\winpython\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\Scripts>python clarifai config
CLARIFAI_APP_ID: []: X*******************************6-e
CLARIFAI_APP_SECRET: []: K**************************wYinsz
Traceback (most recent call last):
File "clarifai", line 167, in
main()
File "clarifai", line 159, in main
configure()
File "clarifai", line 93, in configure
setup(app_id_input, app_secret_input)
File "clarifai", line 32, in setup
os.mkdir(CONF_DIR)
FileNotFoundError: [WinError 3] 系统找不到指定的路径。: '\Users\Administrator\.clarifai'

The system can not find the specified path. : '\ Users \ Administrator \. clarifai'

I checked that there is no folder named .clarifai under \Users\Administrator.the script clarifai fails to create .clarifai.
and there is no Environment variable “HOMEPATH” or "HOME" .is it necessary to create these variables?and What values should these variables have?

Sending file to api from Windows7 fails?

Hi, just started to experiment with clarifai, but I've problems with Windows7 & python2.7.10

python --version
Python 2.7.10 :: Anaconda 2.3.0 (64-bit)

I've line like:

result = clarifai_api.tag_images([open(fullfilename)])

but the verbose msg from api is (with some extra debug prints:)

File exists?:  True
DEBUG, file used:  [<open file 'A:/temp/toka.jpg', mode 'r' at 0x0000000002904390>]
WARNING:clarifai.client.client:Could not open image file: 0, still sending to server.
Traceback (most recent call last):
  File "clar_koe.py", line 71, in <module>
    result = clarifai_api.tag_images([open(fullfilename)])
  File "A:\bin\anaconda\lib\site-packages\clarifai\client\client.py", line 259, in tag
    language=language)
  File "A:\bin\anaconda\lib\site-packages\clarifai\client\client.py", line 633, in _multi_data_op
    self._get_multipart_headers, post_data_multipart, url, kwargs)
  File "A:\bin\anaconda\lib\site-packages\clarifai\client\client.py", line 728, in _get_raw_response
    raise ApiError(response) # raise original error.

Even referring to file from current directory, without pathname doesn't work.
File exists check uses os.path.isfile, which passes. Via curl everything works ok for the same file and also if I give the image location via url. (Anyhow, I'd really need to use a local filename instead).

Api's error msg is just:
"data 0 is not a valid because: Data is corrupt or data type is not supported.."

Typo in README.md

In first example for the Tag from URL there is double g at the end of the link to the image.

There is:
result = clarifai_api.tag_image_urls('https://samples.clarifai.com/metro-north.jpgg')
It should be:
result = clarifai_api.tag_image_urls('https://samples.clarifai.com/metro-north.jpg')

UnboundLocalError during load testing

When we load test an internal API that calls Clarifai with a known model name, we sometimes get an UnboundLocalError:

UnboundLocalError: local variable 'model' referenced before assignment
at get (/env/lib/python3.6/site-packages/clarifai/rest/client.py:1340)
at tag_urls (/env/lib/python3.6/site-packages/clarifai/rest/client.py:144)
...(rest of backtrace in our code)

It appears that the client code in the get() method only handles 401s and 404s from your API, and silently passes out of the except: clause for other types of ApiError. Presumably it should just raise it instead

https://github.com/Clarifai/clarifai-python/blob/master/clarifai/rest/client.py#L1340

Not an issue, but here's my resume.

CurrentResume.pdf
I'm an soon-to-be new grad looking for a position in computer vision engineering. I have 4 years of research experience in applied machine learning and statistics (for biology and neuroscience) as an undergrad. This is likely not allowed, so you can close the issue and I'll disappear forever - but that is a risk I'm willing to take.
My email is [email protected], please contact me if you would like to get to know me better.

Assumption of resizing need/success if PIL module is available

The client uses the importability of PIL as an indicator that it "can resize":

from PIL import Image
CAN_RESIZE = True

However, it uses "can resize" as an unconditional/non-overridable "should resize" here:

# Resize any images such that the min dimension is in range.
if CAN_RESIZE:
for i, image_tup in enumerate(files):
files[i] = self._resize_image_tuple(image_tup)

Alas, the underlying resizing that's attempted via PIL is totally broken if the files that are passed in are file objects encapsulating non-randomly-seekable pipes (which the module is perfectly capable of using otherwise). For applications where the resizing is dealt with externally, and the image data piped into the client, the unconditional nature of this additional resizing becomes a show-stopper.

It is especially surprising when previously-working code stops working merely due to the independent installation of PIL via pip for an entirely different purpose. As a workaround, doing:

import sys
sys.modules['PIL'] = None

before this client module is imported "hides" PIL from it.

It would be very desirable to disable additional resizing via an explicit argument, probably to the constructor.

Installation Issues

Hello,

I recently installed Clarifai from pip (I tried this on both python 2.7 and 3.5).

I am trying to follow the code sample here: https://developer.clarifai.com/quick-start/ (The python one)

When I run from clarifai.rest import ClarifaiApp I receive this error:

>>> from clarifai.rest import ClarifaiApp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/site-packages/clarifai/rest/__init__.py", line 3, in <module>
    from .client import ApiClient, ApiError, UserError, TokenError
  File "/usr/local/lib/python3.5/site-packages/clarifai/rest/client.py", line 19, in <module>
    from past.builtins import basestring
  File "/usr/local/lib/python3.5/site-packages/past/__init__.py", line 89, in <module>
    from future import __version__, __copyright__, __license__
ImportError: cannot import name '__version__'

What should I do to resolve this?

Resource does not exist

model = app.models.get("general-v1.3")

outputs:

RESULT:
{u'status': {u'code': 11101,
u'description': u'Resource does not exist',
u'details': u"model_id 'general-v1.3' not found. Check the url of your request."}}

Will clarifai.rest.ClarifaiApp v2.0.14 support application's "Default Language" option?

Currently clarifai.rest.ClarifaiApp (v2.0.14) doesn't seem to support the "Default Language" option in "Manage Your Applications" page, while clarifai.client.ClarifaiApi does. ClarifaiApp always returns class names in English with the predict_by_url method.
Will clarifai.rest.ClarifaiApp v2.0.14 support application's "Default Language" option? (I would appreciate any tentative schedule.)

How to return filenames as local_id in response json objects?

Hi

I am running clarifai Python client to tag images in a folder on my local drive. I get the response array of tags for all images, however, I am unable to determine which response corresponds to which image as the order of images is not the same as that in the folder.

I would like to know if there a way to return image filename in response json object along with the tags? The documentation says there is a response parameter local_id which is "a user-supplied identifier, echoed back in each result if supplied in the request, or the URL of the image is returned if available." Can anyone tell me the syntax to provide local_id when making a call to api.tag_images(images) for a folder?

Any help would be appreciated!

how to config on windows

dear team,
hello, i am a stranger on python , can you give me a detailed introduction how to config in windows?

best!

Message type "clarifai.api.ModelVersion" has no field named "train_stats"

While creating an instance of Clarifai Object, I get the following stack trace

`Traceback (most recent call last):
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/google/protobuf/json_format.py", line 489, in _ConvertFieldValuePair
message_descriptor.fields))
google.protobuf.json_format.ParseError: Message type "clarifai.api.ModelVersion" has no field named "train_stats".
Available Fields(except extensions):

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/google/protobuf/json_format.py", line 547, in _ConvertFieldValuePair
self.ConvertMessage(value, sub_message)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/google/protobuf/json_format.py", line 452, in ConvertMessage
self._ConvertFieldValuePair(value, message)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/clarifai/rest/grpc/custom_converters/custom_dict_to_message.py", line 29, in _ConvertFieldValuePair
super(_CustomParser, self)._ConvertFieldValuePair(js, message)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/google/protobuf/json_format.py", line 554, in _ConvertFieldValuePair
raise ParseError(str(e))
google.protobuf.json_format.ParseError: Message type "clarifai.api.ModelVersion" has no field named "train_stats".
Available Fields(except extensions):

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/google/protobuf/json_format.py", line 532, in _ConvertFieldValuePair
self.ConvertMessage(item, sub_message)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/google/protobuf/json_format.py", line 452, in ConvertMessage
self._ConvertFieldValuePair(value, message)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/clarifai/rest/grpc/custom_converters/custom_dict_to_message.py", line 29, in _ConvertFieldValuePair
super(_CustomParser, self)._ConvertFieldValuePair(js, message)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/google/protobuf/json_format.py", line 552, in _ConvertFieldValuePair
raise ParseError('Failed to parse {0} field: {1}'.format(name, e))
google.protobuf.json_format.ParseError: Failed to parse model_version field: Message type "clarifai.api.ModelVersion" has no field named "train_stats".
Available Fields(except extensions):

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1664, in
main()
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1658, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1068, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/application.py", line 3, in
from tag_watch import app,api
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/tag_watch/init.py", line 57, in
clarifaiService = ClarifaiService()
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/tag_watch/services/clarifai_service.py", line 9, in init
app = ClarifaiApp(api_key=config.CLARIFAI_KEY)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/clarifai/rest/client.py", line 115, in init
self.models = Models(self.api)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/clarifai/rest/client.py", line 1053, in init
self.model_id_cache = self.init_model_cache()
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/clarifai/rest/client.py", line 1070, in init_model_cache
for m in models:
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/clarifai/rest/client.py", line 1173, in get_all
res = self.api.get_models(page, per_page)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/clarifai/rest/client.py", line 3754, in get_models
ListModelsRequest(page=page, per_page=per_page))
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/clarifai/rest/client.py", line 3463, in _grpc_request
res = method(argument)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/clarifai/rest/grpc/grpc_json_channel.py", line 194, in call
result = dict_to_protobuf(message, response_json)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/clarifai/rest/grpc/custom_converters/custom_dict_to_message.py", line 9, in dict_to_protobuf
parser.ConvertMessage(js_dict, message)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/google/protobuf/json_format.py", line 452, in ConvertMessage
self._ConvertFieldValuePair(value, message)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/clarifai/rest/grpc/custom_converters/custom_dict_to_message.py", line 29, in _ConvertFieldValuePair
super(_CustomParser, self)._ConvertFieldValuePair(js, message)
File "/Users/anuj/Desktop/AnujSyal/projects/repo/tag-watch/server/env/lib/python3.6/site-packages/google/protobuf/json_format.py", line 552, in _ConvertFieldValuePair
raise ParseError('Failed to parse {0} field: {1}'.format(name, e))
google.protobuf.json_format.ParseError: Failed to parse models field: Failed to parse model_version field: Message type "clarifai.api.ModelVersion" has no field named "train_stats".
Available Fields(except extensions): `

Tagging celebrities and logos

Hello,

While testing out your application, our team noticed that your API does not identify celebrities or logos when uploaded. Is this purposefully done to avoid copyright issues? I would recommend adding this to the README as we were not able to find reference to this bug on your GitHub page or the Clarifai webpage.

Yousif

Support for /usage API

Add support for the usage API so that there is a way to programmatically know the monthly usage

Has concepts list a limit length? (Python 3.5, clarifai 2.0.17)

Hello, I want to create a image from url with the next information:
image_id = "1088078"
image = "http://mcdn.zulilyinc.com/media/catalog/product/145423/zu27577138_main_tm1436807694.jpg"
concepts = ['ca_9', 'cp_100004', 'cp_100007', 'at_11', 'at_12', 'at_18', 'at_19', 'at_21', 'at_22', 'at_23', 'at_24', 'at_25', 'at_26', 'at_27', 'at_28', 'at_29', 'at_30', 'at_31', 'at_32', 'at_36', 'at_37', 'at_38', 'at_39', 'at_40', 'at_41', 'at_42', 'at_43', 'at_45', 'at_46', 'at_49', 'at_50', 'at_51', 'at_52', 'at_53', 'at_54', 'at_55', 'at_56', 'at_57', 'at_58', 'at_98', 'at_101', 'at_102', 'at_119', 'at_120', 'at_133', 'at_134', 'at_135', 'at_136', 'at_137', 'at_138', 'at_139', 'at_140', 'at_160', 'at_161', 'at_164', 'at_170', 'at_181', 'at_183', 'at_184', 'at_185', 'at_186', 'at_187', 'at_188', 'at_189', 'at_190', 'at_202', 'at_211', 'at_212', 'at_213', 'at_215', 'at_216', 'at_217', 'at_218', 'at_219', 'at_234', 'at_236', 'at_240', 'at_242', 'at_243', 'at_244', 'at_245', 'at_246', 'at_247', 'at_249', 'at_252', 'at_254', 'at_255', 'at_257', 'at_268', 'at_269', 'at_270', 'at_271', 'at_272', 'at_273', 'at_274', 'at_275', 'at_276', 'at_277', 'at_278', 'at_279', 'at_280', 'at_281', 'at_282', 'at_283', 'at_510', 'at_521', 'at_522', 'at_738', 'at_739', 'at_740', 'at_741', 'at_742', 'at_743', 'at_744', 'at_745', 'at_804', 'at_897', 'at_898', 'at_899', 'at_909', 'at_920', 'at_927', 'at_952', 'at_959', 'oc_230', 'oc_231', 'oc_232', 'oc_233', 'oc_647', 'oc_648', 'oc_649', 'oc_650', 'oc_652', 'oc_653', 'oc_867', 'cs_100001']

But Clarifai API returns the next message:
Traceback (most recent call last): File "load-items.py", line 40, in <module> app.inputs.create_image_from_url(image_id=d['ItemId'], url=d['LinkToImage'], concepts=concept_by_item, allow_duplicate_url=True) File "/usr/local/lib/python3.5/dist-packages/clarifai/rest/client.py", line 795, in create_image_from_url return self.create_image(image) File "/usr/local/lib/python3.5/dist-packages/clarifai/rest/client.py", line 767, in create_image ret = self.api.add_inputs([image]) File "/usr/local/lib/python3.5/dist-packages/clarifai/rest/client.py", line 2369, in add_inputs res = self.post(resource, data) File "/usr/local/lib/python3.5/dist-packages/clarifai/rest/client.py", line 2339, in post return self._requester(resource, params, 'POST', version) File "/usr/local/lib/python3.5/dist-packages/clarifai/rest/client.py", line 2329, in _requester raise ApiError(resource, params, method, res) clarifai.rest.client.ApiError: POST inputs FAILED. code: 400, reason: Bad Request, response:<Response [400]>

I was thinking this message is given because list concepts length is too large. In this case are 136 items (1152 bytes, using sys.getsizeof function). So, I tried to decrease the list until it worked, I found with decreasing until length was 71 elements (744 bytes).
concepts = ['ca_9', 'cp_100004', 'cp_100007', 'at_11', 'at_12', 'at_18', 'at_19', 'at_21', 'at_22', 'at_23', 'at_24', 'at_25', 'at_26', 'at_27', 'at_28', 'at_29', 'at_30', 'at_31', 'at_32', 'at_36', 'at_37', 'at_38', 'at_39', 'at_40', 'at_41', 'at_42', 'at_43', 'at_45', 'at_46', 'at_49', 'at_50', 'at_51', 'at_52', 'at_53', 'at_54', 'at_55', 'at_56', 'at_57', 'at_58', 'at_98', 'at_101', 'at_102', 'at_119', 'at_120', 'at_133', 'at_134', 'at_135', 'at_136', 'at_137', 'at_138', 'at_139', 'at_140', 'at_160', 'at_161', 'at_164', 'at_170', 'at_181', 'at_183', 'at_184', 'at_185', 'at_186', 'at_187', 'at_188', 'at_189', 'at_190', 'at_202', 'at_211', 'at_212', 'at_213', 'at_215', 'at_216']

I did the same with another images that I want to create and they coincided that need the same length to load in my app.

It appears that has a restrictions in limit length or size (bytes). If it is the problem, does Clarifai API accept to append new concepts to existing concepts in image id?

What do you think?

ApiError requires initialisation?

Attempting to reproduce test_auth.py in my own test env I get the error:

raise(ApiError)

TypeError: __init__() missing 4 required positional arguments: 'resource', 'params', 'method', and 'response'

I see that the error is initialised here but I'm not sure how to init in my test scenario (here)

Install python client in windows 10

When I use:
pip install git+git://github.com/Clarifai/clarifai-python.git

I get this:
Collecting git+git://github.com/Clarifai/clarifai-python.git Cloning git://github.com/Clarifai/clarifai-python.git to c:\users\shetty\appdata\local\temp\pip-cgvfqm-build fatal: read error: Invalid argument Command "git clone -q git://github.com/Clarifai/clarifai-python.git c:\users\shetty\appdata\local\temp\pip-cgvfqm-build" failed with error code 128 in None

Thoughts?
Using Python 2.7. Tried on Win10, 7 and Mac OS (friend's laptop)

Error during installing

Trying to install on latest MacOS with python3.6, getting this error

` clang: warning: -framework Tk: 'linker' input unused [-Wunused-command-line-argument]
In file included from _imagingtk.c:19:
In file included from Tk/tkImaging.c:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/tk.h52:78:11: :
fatal error: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/tk.h:78:'X11/Xlib.h' file not found
11: fatal error: 'X11/Xlib.h' file not found
# include <X11/Xlib.h># include <X11/Xlib.h>

                ^                ^

1 error generated.
1 error generated.
/usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-3.6/_imagingtk.o build/temp.macosx-10.6-intel-3.6/Tk/tkImaging.o -L/Users/petriichuk/projects/django/petrichuk.com/petrichuk/venv/lib -L/opt/local/lib -L/usr/local/lib -L/usr/local/Cellar/freetype/2.7.1/lib -L/usr/lib -o build/lib.macosx-10.6-intel-3.6/PIL/_imagingtk.cpython-36m-darwin.so -framework Tcl -framework Tk
clang: error: no such file or directory: 'build/temp.macosx-10.6-intel-3.6/_imagingtk.o'
clang: error: no such file or directory: 'build/temp.macosx-10.6-intel-3.6/Tk/tkImaging.o'
error: command '/usr/bin/clang' failed with exit status 1

----------------------------------------

Rolling back uninstall of Pillow
Command "/Users/petriichuk/projects/django/petrichuk.com/petrichuk/venv/bin/python3 -u -c "import setuptools, tokenize;file='/private/var/folders/1p/lzxyybzj6qbgx4gb1bh8l81c0000gn/T/pip-build-lv3cpwre/Pillow/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /var/folders/1p/lzxyybzj6qbgx4gb1bh8l81c0000gn/T/pip-5ihdvylb-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/petriichuk/projects/django/petrichuk.com/petrichuk/venv/include/site/python3.6/Pillow" failed with error code 1 in /private/var/folders/1p/lzxyybzj6qbgx4gb1bh8l81c0000gn/T/pip-build-lv3cpwre/Pillow/`

Proxy support

I am working on a server and my GW to internet is though proxy,
Whay there is no proxy support ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.