cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ConsiglioriWim
New Member

I cannot get the AI model to accept my base64 encoded image from a HTTP request - while opening the file manually works - Help

Hello Fellow Automaters,

 

I'm running into an issue with calling the AI model (running a standard cats vs dogs detection using the Kaggle set).

When I open the file with the content to be detected with a manual trigger, it works fine

 

A very simple flow to open a file, and we see the contents of the file converted to base64, and passed on the AI Model. It runs without errors (except from detecting, need to add more samples ...)

 

Schermafbeelding 2021-09-17 om 11.40.35.png

 

Run the flow manually

 

Schermafbeelding 2021-09-17 om 11.41.19.png

 

The file is imported and the content is converted to base64, the content is passed on to the AI model

 

Schermafbeelding 2021-09-17 om 11.41.41.png

 

And succes!

Schermafbeelding 2021-09-17 om 11.41.55.png

 

However, when I tried to post this same image as base64 content through a HTTP requests, the model refuses to accept the input and fails. Imho it is exactly the same content ( opened the image and used base64encode.org to encode it).

 

This is the HTTP flow request

Schermafbeelding 2021-09-17 om 11.49.14.png

 

The HTTP POST request I send from Postman

 

Schermafbeelding 2021-09-17 om 11.49.42.png

 

The HTTP requests gets processed normally and base64 encoded image is stored in the Image attribute

 

Schermafbeelding 2021-09-17 om 11.50.27.pngSchermafbeelding 2021-09-17 om 11.50.36.png

 

However when passing the Image to the AI model, it fails with a bad request, even though the content of the image attribute is exactly the same as when I'm running it with a manual trigger. 

Schermafbeelding 2021-09-17 om 11.50.47.pngSchermafbeelding 2021-09-17 om 11.50.57.png

 

What am I doing wrong? HELP!

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Antrod
Microsoft
Microsoft

Hi @ConsiglioriWim ,

 

Did you try to convert the explicitly convert the base64 string to binary using base64ToBinary?

 

Thanks

View solution in original post

@Antrod 

Calling base64ToBinary instead of base64ToString did the trick ! Thanks a lot!!!!!!

 

Schermafbeelding 2021-09-17 om 13.55.31.png

 

View solution in original post

8 REPLIES 8
Antrod
Microsoft
Microsoft

Hi @ConsiglioriWim ,

 

Did you try to convert the explicitly convert the base64 string to binary using base64ToBinary?

 

Thanks

View solution in original post

No, why would I do that? The AI model expects base64, not binary. I tried by sending a url to the JPEG image, downloading it with a HTTP GET requests and saving it locally on my OneDrive and passing that to the Model. Didn't work either. Or is there an image object that can open that JPEG file and pass that object to the model, like the open file manual method?

 

AI Builder actions require an explicit conversion to work properly.

 

I made the test with Form processing models and it worked (I think it's the same with object detection):

 

1- Converted my file using the base64 encoder you provided

2- Passed it as a string to my model fails as in your example: 

Antrod_0-1631878284247.png

Antrod_1-1631878295421.png

Antrod_2-1631878375066.png

 

3- If I convert the base64 to binary it now works properly:

Antrod_5-1631878810231.png

Antrod_6-1631878834318.png

 

 

 

 

Hope that helps solve your issue.

 

Hi @Antrod 

Can you just expand the F(x) for calling the Base64 on the Variable, for getting the correct syntax? Thx

I need to apply that on the image attribute. I get an error for F(x) Base64ToString('image')

Schermafbeelding 2021-09-17 om 13.47.16.png

Sure, I just converted the string variable representing the file: base64ToBinary(variables('MyFileBase64String'))

 

Let us know if that works for you!

Note that if the string representation of your file is within double quote you may get this error: 

Antrod_0-1631879667738.png

If possible try to avoid double quoting your string.

@Antrod 

Calling base64ToBinary instead of base64ToString did the trick ! Thanks a lot!!!!!!

 

Schermafbeelding 2021-09-17 om 13.55.31.png

 

View solution in original post

Awesome 🙂

Wish you a great automation journey with AI Builder!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Kudoed Authors
Users online (1,478)