Spaces:
Runtime error
Runtime error
import gradio as gr | |
import requests | |
from PIL import Image | |
from io import BytesIO | |
# Define the function to call the existing Gradio space API | |
def enhance_image(input_image): | |
# Convert the image to bytes | |
img_byte_arr = BytesIO() | |
input_image.save(img_byte_arr, format='PNG') | |
img_bytes = img_byte_arr.getvalue() | |
# Prepare the payload | |
payload = {'data': [img_bytes]} | |
# Call the existing Gradio space API | |
api_url = "https://radames/Enhance-This-HiDiffusion-SDXL/api/predict" | |
response = requests.post(api_url, files={'file': img_bytes}) | |
if response.status_code == 200: | |
output_image = Image.open(BytesIO(response.content)) | |
return output_image | |
else: | |
return None | |
# Create the Gradio interface | |
interface = gr.Interface( | |
fn=enhance_image, | |
inputs=gr.inputs.Image(type="pil", label="Input Image"), | |
outputs=gr.outputs.Image(type="pil", label="Enhanced Image"), | |
title="Enhance This HiDiffusion SDXL", | |
description="Upload an image to enhance it using HiDiffusion SDXL." | |
) | |
# Launch the app | |
interface.launch() | |