File size: 974 Bytes
1504238
3e7fe19
 
 
3e30a8b
1504238
3e30a8b
3e7fe19
 
1504238
3e7fe19
 
 
 
e52b864
3e7fe19
 
 
 
1504238
 
3e7fe19
 
 
3e30a8b
 
232fb2c
3e7fe19
1504238
 
 
3e7fe19
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
import gradio as gr
import requests
import io
import os
from PIL import Image

# Get the API URL and headers from environment variables
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
headers = {"Authorization": f"Bearer {os.getenv('HF_API_TOKEN')}"}

# Define the query function
def query(payload):
    response = requests.post(API_URL, headers=headers, json=payload)
    return response.content

# Define the function to generate the image
def generate_image(input_text):
    image_bytes = query({"inputs": input_text})
    image = Image.open(io.BytesIO(image_bytes))
    return image

# Create Gradio interface
iface = gr.Interface(
    fn=generate_image,
    inputs=gr.Textbox(label="Input Text", placeholder="Enter your description here..."),
    outputs=gr.Image(label="Generated Image"),
    title="LodhranGPT Image Generator",
    description="Enter a description to generate an image."
)

# Launch the Gradio app
iface.launch()