File size: 1,001 Bytes
cd068c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import torch
from diffusers import FluxPipeline, DPMSolverMultistepScheduler

# Load the model
model_id = "black-forest-labs/FLUX.1-dev"
pipe = FluxPipeline.from_pretrained(model_id, torch_dtype=torch.float16, safety_checker=None)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe.enable_xformers_memory_efficient_attention()

if torch.cuda.is_available():
    pipe = pipe.to("cuda")

# Define the function to generate images
def generate_image(prompt):
  image = pipe(prompt, num_inference_steps=25).images[0]
  return image

# Title for your Space
title = "Kailouis AI Image Generator"

# Description for your Space
description = "Generate amazing images with Kailouis AI, powered by the FLUX.1-dev model."

# Create the UI
import gradio as gr

demo = gr.Interface(
    fn=generate_image,
    inputs=[gr.Textbox(lines=1, placeholder="Enter your prompt")],
    outputs=[gr.Image(type="pil")],
    title=title,
    description=description,
)

demo.launch(share=True)