Issue: Incorrect API Response for Upscaling Request
Issue: Incorrect API Response for Upscaling Request
Description:
When sending an API request to upscale an image using the following payload structure:
{
"data": [
str | Dict, // represents base64 url data, or (if tool == "sketch") a dict of image and mask base64 url data of 'Input Image' Image component
str, // represents selected choice of 'Choose Upscaler' Radio component
]
}
the response received is not as expected. The API response is always:
{
'error': None
}
Steps to Reproduce:
- Use the provided payload structure for the API request.
- Ensure the input data is formatted as shown in the example:
image_path = "image02.jpg"
upscaler_model = "modelx4"
encoded_image = encode_image(output_filename)
# Create the payload for the API request
api_payload = {
"data": [encoded_image, upscaler_model]
}
# Send data to the API
api_response = send_data_to_api(api_payload)
print(api_payload)
print(api_response)
output_base64 = api_response.get("data", [])[0]
Expected Result:
The expected response should contain the upscaled image data or an appropriate success message.
Actual Result:
The actual response is always:
{
'error': None
}
This issue is impacting the ability to retrieve the upscaled image data as expected. Any assistance in resolving this matter is highly appreciated.
The encode function is as follows:
# Function to encode an image as base64
def encode_image(image_path):
with open(image_path, "rb") as image_file:
encoded_image = base64.b64encode(image_file.read()).decode("utf-8")
return encoded_image
Hi @rengen45 , thanks for raising this issue.
I've upgraded the Gradio SDK to the latest Gradio v3 available (v3.41.0), and updated to the latest Gradio API. Tested the new build and sent it a sample POST request with your code. It should work now.
Please let me know if you find any further issues.
Cheers,
Wilson
Just for completeness, here's the Python code I ran:
import requests
api_response = requests.post(
"https://bookbot-image-upscaling-playground.hf.space/api/predict",
json={"data": [encoded_image, upscaler_model]}
)
output_base64 = api_response.json().get("data", [])[0]