File size: 1,425 Bytes
2893884
 
 
 
 
 
 
 
f90108e
2893884
 
 
 
 
 
 
 
29724c2
2893884
 
4a57a54
192e5ea
d4616ff
 
66bf926
12564d7
 
cb4024a
2893884
 
 
 
 
 
 
f90108e
 
2893884
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
import gradio as gr
import requests
import io, os
from PIL import Image



api_key = os.environ.get("HF_API_KEY")
API_URL = "https://api-inference.huggingface.co/models/multimodalart/liminal-spaces"
headers = {"Authorization": f"Bearer {api_key}"}

# Function to query the model
def query_image(inputs):
    payload = {"inputs": inputs}
    response = requests.post(API_URL, headers=headers, json=payload)
    image_bytes = response.content
    image = Image.open(io.BytesIO(image_bytes))
    return image, inputs

# Define Gradio Blocks UI
with gr.Blocks(theme="nevreal/blues") as demo:
    gr.Markdown("# liminal spaces")
    with gr.Row():
        gr.Markdown("model by [multimodalart](https://huggingface.co/multimodalart) this spces by [nevreal](https://huggingface.co/nevreal)")

    with gr.Row():
        prompt = gr.Textbox(label="Enter your prompt", value="Astronaut riding a horse", lines=2)
        submit_button = gr.Button("Generate Image")
        
        with gr.Column():
            output_image = gr.Image(label="Generated Image")

    # Add examples
    examples = gr.Examples(
        examples=[
            "A person in a bustling cafe as a liminal space",
            "The city of Paris as a liminal space"
        ],
        inputs=prompt,
    )
    
    # Link button action to function
    submit_button.click(fn=query_image, inputs=prompt, outputs=output_image)

# Launch the web UI
demo.launch()