File size: 1,085 Bytes
ef7e565
2eaf831
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()