File size: 981 Bytes
2a0517c
 
 
c48064c
2a0517c
c48064c
2a0517c
c48064c
 
 
 
 
 
 
2a0517c
c48064c
 
2a0517c
c48064c
2a0517c
 
 
c48064c
2a0517c
 
 
 
c48064c
 
 
 
2a0517c
c48064c
2a0517c
 
 
 
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
import gradio as gr
from control import main
from diffusers.utils import load_image
from mask import create_mask

def process_image(image, prompt):
    try:
        # Create mask from input image
        mask = create_mask(image)
        
        # First show the generated mask
        yield mask
        
        # Then process image with mask
        result = main(image, mask, prompt)
        yield result
        
    except Exception as e:
        yield str(e)

# Create Gradio interface
demo = gr.Interface(
    fn=process_image,
    inputs=[
        gr.Image(label="Input Image", type="pil"),
        gr.Textbox(label="Prompt"),
    ],
    outputs=[
        gr.Image(label="Generated Mask"),
        gr.Image(label="Generated Image")
    ],
    title="Image Inpainting with FLUX ControlNet",
    description="Upload an image and provide a prompt. The system will first generate a mask and then create the inpainted result.",
)

if __name__ == "__main__":
    demo.launch()