GPT4V is unable to interpret the image encoded in base64

Why is the response coming in *

This image cannot be displayed because it is in Base64 format. To view the image, you would need to convert it to a standard image format such as JPEG or PNG using a Base64 decoder

  • What could be wrong?
1 Like

Can you provide the code you are using to convert the image to base64 format?

Thank you for your response!

I am working on a project using Unreal Engine where I request image descriptions from GPT using local image files.

I will show you part of the code first.

if (FFileHelper::LoadFileToArray(ImageData, *ImagePath))
{
     FString EncodedImage = FBase64::Encode(ImageData);
}

and Contents part

ImageUrlObject->SetStringField(TEXT("type"), TEXT("image_url"));
ImageUrlObject->SetObjectField(TEXT("image_url"), MakeShareable(new FJsonObject{ { { TEXT("url"), MakeShareable(new FJsonValueString(FString(TEXT("data:image/jpeg;base64,")) + *EncodedImage)) } } }));
ContentList.Add(MakeShareable(new FJsonValueObject(ImageUrlObject)));

I’m not familiar with unreal engine. I use Python for the API, but I think the problem might has something to do with “SetObjectField”. In python I decode the base64 data to string and pass it as a string.

1 Like

Thank you

I try next day

:smiley: :grinning:

It’s perhaps worth asking if the image data is actually that of a JPEG or something else such as a PNG. Depending on the answer, you need to change the mime type from image/jpeg to something else such as image/png