Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk input throwing an error #82

Closed
AnkitRai opened this issue Mar 28, 2018 · 4 comments
Closed

Bulk input throwing an error #82

AnkitRai opened this issue Mar 28, 2018 · 4 comments

Comments

@AnkitRai
Copy link

AnkitRai commented Mar 28, 2018

Hi, I'm using the following code to create bulk input:
from clarifai.rest import ClarifaiApp
from clarifai.rest import Image as ClImage

app = ClarifaiApp(api_key='YOUR_API_KEY')

img1 = ClImage(url="https://samples.clarifai.com/metro-north.jpg", image_id="train1")
img2 = ClImage(url="https://samples.clarifai.com/puppy.jpeg", image_id="puppy1")

app.inputs.bulk_create_images([img1, img2])

However, keep getting error.

@rok-povsic
Copy link
Contributor

Hi @AnkitRai ,

In your case I suspect that the error occurs either because the image ID is already taken or the URL has already been added.

To fix the first case, change the image_id fields to some unique values. To allow having multiple images with same URL, set allow_dup_url to True, if this is what you want.

Changing your two image lines to the lines below does both and should fix your problem.

img1 = ClImage(url="https://samples.clarifai.com/metro-north.jpg", image_id="train2", allow_dup_url=True)
img2 = ClImage(url="https://samples.clarifai.com/puppy.jpeg", image_id="puppy2", allow_dup_url=True)

@AnkitRai
Copy link
Author

Thanks @rok-povsic for your response. That did work with the sample examples. But it is still showing the error when running the same script on my images. Please see below the POST message I'm getting:
{"status":{"code":11001,"description":"Invalid authentication token","details":"Empty or missing Authorization header","req_id":"xxxxxxxxxxx"},"inputs":[]}

P.S. removing the key with 'xxxxxxxxx'
Any idea?
Thanks

@rok-povsic
Copy link
Contributor

@AnkitRai If the images are available (online) at the specified URLs, this should not happen. Could you provide a sample URL where this happens so I can double check it? However I don't believe this is the reason for the error. Could you double check your API key and make sure that you're using the right ClarifaiApp object/variable (if you maybe have two of them, or something like that)?

Thanks

@AnkitRai
Copy link
Author

Thanks @rok-povsic for your response. I figured it out, it's with the duplicate image_id in the image data. So I can run it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants