Hi,
I am unable to utilize Clarifai_API for in-built food detection model.
I followed the tutorial mentioned at https://docs.clarifai.com/ & https://www.clarifai.com/models/ai-food-recognition but the operations that I need to perform are not getting through.
Basically, I require my canvas app to pass an image to the API and in return the API provides ingredients list.
I used API key for security:
General definition as this
Request as
Header as (from https://docs.clarifai.com/clarifai-basics/authentication/authorize)
curl -X POST \
-H 'Authorization: Key YOUR_API_KEY' \
-H "Content-Type: application/json" \
-d '
The results shows custom connector is created but I simply can't test it.
CC: @v-xiaochen-msft , @cchannon
Sid
I was able to rectify this by changing schema to an array.
Hi Wearsky,
It works! Thanks. 😊
One last thing: I tried to use a similar custom connector with Onselect of a button as:
Collect(spoonresponses,Spoonacular.acularimage({apiKey:"xxxxxxxx",imageUrl:"https://cdn.pixabay.com/photo/2019/10/12/15/39/falafel-4544137_960_720.jpg",'Content-Type':"application/json"}));
Set(spoondataanswer,spoondata.Run(JSON(spoonresponses,JSONFormat.IndentFour))
I get error: "Invalid type. Expected Object but got Array." in Power Flow.
Basically, this seems to be an issue with the collector as when there are more than 1 item it sends an array instead of object. The issue is now how to parse a JSON array!
Thanks Wearsky!
I performed the steps you mentioned. However, I am getting an error for header: Authorization.
The error is: 'Authorization' header is not allowed. Use 'API Key' authentication type in the Security tab to set this header.
I have set authentication type to 'NO Authentication' in the security tab as your screenshot.
Hi @smehro ,
I agreed with @cchannon .
I did a sample for you.
Add a post request .
Header:Authorization Key {your key}
Body:
{
"inputs": [
{
"data": {
"image": {
"url": "https://samples.clarifai.com/metro-north.jpg",
"allow_duplicate_url": true
}
}
}
]
}
Add a policy
@headers('Access-Token')
Save and test it.
In addition, I did not add response in my example, please don't forget to add it.
Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.
There's a few things here.
1. Your url is wrong. I looked at the clarifyai documentation for a few minutes and quickly found this page which details how to call their predict endpoint for images. What you'll see there is that the url for the requests follows the format:
https://api.clarifai.com/v2/models/{THE_MODEL_ID}/outputs
2. You haven't defined any body or qs params as far as I can tell. At a minimum, you need to build a JSON body to actually send your image to the api. From the quick glance I took at the documentation, it looks like that body is formed something like this:
{
"data": {
"image": {
"base64": "'"$(base64 /path/to/image.jpg)"'"
}
}
}
3. Custom Connectors don't know how to read curl commands. You need to build the header in JSON for the swagger to understand it.
WarrenBelz
146,765
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,091
Most Valuable Professional