theoracle commited on
Commit
156fb34
·
verified ·
1 Parent(s): 4603d0f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -0
app.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from PIL import Image
4
+ from diffusers import AutoPipelineForImage2Image
5
+
6
+ # Load SDXL base pipeline
7
+ pipe = AutoPipelineForImage2Image.from_pretrained(
8
+ "stabilityai/stable-diffusion-xl-base-1.0",
9
+ torch_dtype=torch.float16,
10
+ variant="fp16",
11
+ use_safetensors=True
12
+ ).to("cuda")
13
+
14
+ # Load your LoRA weights from Hugging Face
15
+ pipe.load_lora_weights("theoracle/sdxl-tok-lounge-lora")
16
+
17
+ # Inference function
18
+ def generate(image, prompt, negative_prompt, strength):
19
+ image = image.resize((1024, 1024))
20
+ result = pipe(
21
+ prompt=prompt,
22
+ negative_prompt=negative_prompt,
23
+ image=image,
24
+ strength=strength,
25
+ guidance_scale=15,
26
+ num_inference_steps=30
27
+ ).images[0]
28
+ return result
29
+
30
+ # Default prompt
31
+ default_prompt = (
32
+ "a blue maritime-themed TOK lounge, inspired by classic coastal elegance and deep ocean hues, "
33
+ "navy and seafoam color palette, whitewashed wooden walls, large panoramic windows with ocean views, "
34
+ "nautical decor like ropes, brass instruments, and ship wheels subtly integrated, "
35
+ "linen sofas in soft ivory and deep blue, striped cushions and driftwood coffee table, "
36
+ "open shelves with coral sculptures, vintage maritime maps and glass fishing floats, "
37
+ "light oak flooring and woven jute rug, sheer curtains billowing in a coastal breeze, "
38
+ "ambient natural light, serene and breezy atmosphere, luxury seaside escape with timeless nautical charm, "
39
+ "8k ultra photorealistic, crisp focus, interior photography with coastal lighting and peaceful mood"
40
+ )
41
+
42
+ default_negative = (
43
+ "empty rooms, clutter, mess, disorganized, visible wires, tangled cables, chaotic layout, "
44
+ "outdated design, old furniture, vintage upholstery, faded fabric, chipped wood, "
45
+ "dirty carpet, old carpet, boring colors, muted tones, brown overload, yellow tint, "
46
+ "stains, dust, peeling wallpaper, worn out textures, bad lighting, overexposed, "
47
+ "low detail, blurry, deformed, flat perspective, bad composition, watermark, text, "
48
+ "ugly, dated, dark corners, awkward layout, excessive decoration, chaotic patterns, no new doors, no new windows, no new opening"
49
+ )
50
+
51
+ # Gradio UI
52
+ gr.Interface(
53
+ fn=generate,
54
+ inputs=[
55
+ gr.Image(type="pil", label="Input Image"),
56
+ gr.Textbox(label="Prompt", value=default_prompt, lines=6),
57
+ gr.Textbox(label="Negative Prompt", value=default_negative, lines=4),
58
+ gr.Slider(0.1, 1.0, value=0.5, label="Strength")
59
+ ],
60
+ outputs=gr.Image(label="Generated Image"),
61
+ title="TOK Lounge Generator (LoRA SDXL)",
62
+ description="Upload an image and generate a stylized TOK lounge interior using a LoRA fine-tuned Stable Diffusion XL model."
63
+ ).launch()