R
RunPod11mo ago
Husar

image returns as base64

I'm using the SD Anything v5 model. when im making a api call (RUNSYNC/RUN) im getting the image in a base64 text. How do i get it to return a link to the image? my only header except authorization is Content-Type: application/json
11 Replies
navin_hariharan
navin_hariharan11mo ago
What are you using to recieve the request? Python? Postman?
FOR PYTHON pip install pillow import base64 from PIL import Image from io import BytesIO def base64_to_image(base64_string, save_path='output_image.png'): try: # Decode Base64 string image_data = base64.b64decode(base64_string) # Create a PIL Image object from the decoded data image = Image.open(BytesIO(image_data)) # Save the image (optional) image.save(save_path) # Display the image (optional) image.show() return image except Exception as e: print(f"Error converting Base64 to image: {e}") return None # Example usage: base64_string = "Your_Base64_Encoded_String_Goes_Here" image = base64_to_image(base64_string)
Husar
HusarOP11mo ago
I mean, I saw in the examples in the API documentation that it returns a link to the image and I would prefer that from base64 image. I'm using insomnia
ashleyk
ashleyk11mo ago
You can provide s3 compatible storage credentials if you are using RunPod endpoints, otherwise if you're using your own custom handler, you have to handle it yourself. eg:
{
"input": {},
"s3Config": {
"bucketName": "<bucket-name>",
"accessId": "<accessId>",
"accessSecret": "<accessSecret>",
"endpointUrl": "https://<bucket-name>.s3.us-west-1.amazonaws.com"
}
}
{
"input": {},
"s3Config": {
"bucketName": "<bucket-name>",
"accessId": "<accessId>",
"accessSecret": "<accessSecret>",
"endpointUrl": "https://<bucket-name>.s3.us-west-1.amazonaws.com"
}
}
Husar
HusarOP11mo ago
ok great! do you know if the runpod storage is and if yes where to find all the values?
ashleyk
ashleyk11mo ago
RunPod don't provide S3 compatible storage, you will have to use AWS/DigitalOcean/Backblaze/R2/etc/etc.
Husar
HusarOP11mo ago
ok good to know thx a bunch
justin
justin11mo ago
Any easy place to start is the Firebase API https://github.com/justinwlin/FirebaseStorageWrapperPython At least to me
GitHub
GitHub - justinwlin/FirebaseStorageWrapperPython: Easy wrapper arou...
Easy wrapper around Firebase File Storage Wrapper in Python - GitHub - justinwlin/FirebaseStorageWrapperPython: Easy wrapper around Firebase File Storage Wrapper in Python
justin
justin11mo ago
I have a firebase storage wrapper, where I use firebase file storage (which is just a wrapper from Google around Google storage buckets) And I can when i upload get public links
ashleyk
ashleyk11mo ago
Is it s3 compatible? if not, it can't work with RunPod official endpoints.
justin
justin11mo ago
AH makes sense i was thinking was custom handler oops makes sense now tho got it
Want results from more Discord servers?
Add your server