Qistinasofea commited on
Commit
5ea9ace
·
verified ·
1 Parent(s): 1477597

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -50
app.py DELETED
@@ -1,50 +0,0 @@
1
- import torch
2
- import gradio as gr
3
- from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
4
- from PIL import Image
5
-
6
- DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
7
-
8
- # Load ControlNet
9
- controlnet = ControlNetModel.from_pretrained(
10
- "Qistinasofea/controlnet-floorplan",
11
- torch_dtype=torch.float16 if DEVICE == "cuda" else torch.float32,
12
- )
13
-
14
- # Load Pipeline
15
- pipe = StableDiffusionControlNetPipeline.from_pretrained(
16
- "stable-diffusion-v1-5/stable-diffusion-v1-5",
17
- controlnet=controlnet,
18
- torch_dtype=torch.float16 if DEVICE == "cuda" else torch.float32,
19
- safety_checker=None,
20
- )
21
-
22
- pipe = pipe.to(DEVICE)
23
-
24
- def generate(image, prompt):
25
- if image is None:
26
- return None
27
-
28
- image = image.resize((512, 512))
29
-
30
- result = pipe(
31
- prompt=prompt,
32
- image=image,
33
- num_inference_steps=20, # keep low for CPU
34
- controlnet_conditioning_scale=1.0,
35
- )
36
-
37
- return result.images[0]
38
-
39
- demo = gr.Interface(
40
- fn=generate,
41
- inputs=[
42
- gr.Image(type="pil", label="Upload Colored Segmentation"),
43
- gr.Textbox(label="Describe Your Floorplan", value="A residential floorplan with multiple rooms"),
44
- ],
45
- outputs=gr.Image(type="pil", label="Generated Floorplan"),
46
- title="🏠 ControlNet Floorplan Generator",
47
- description="Upload a colored segmentation image and describe your floorplan. Running on CPU (~30s per generation).",
48
- )
49
-
50
- demo.launch()