Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
|
| 4 |
+
def generate_fn(prompt, image):
|
| 5 |
+
# Stub: echo for now (swap with real gen later)
|
| 6 |
+
if not prompt and image is None:
|
| 7 |
+
raise gr.Error("Add a prompt or an image.")
|
| 8 |
+
msg = f"OK ✅ Prompt length: {len(prompt or '')} | Image: {'yes' if image else 'no'}"
|
| 9 |
+
return msg
|
| 10 |
+
|
| 11 |
+
CUSTOM_CSS = """
|
| 12 |
+
/* Page padding & grid background hint (optional) */
|
| 13 |
+
.gradio-container { padding: 24px; }
|
| 14 |
+
|
| 15 |
+
/* Big rounded prompt box */
|
| 16 |
+
#prompt-box textarea {
|
| 17 |
+
border-radius: 28px !important;
|
| 18 |
+
min-height: 180px;
|
| 19 |
+
font-size: 18px;
|
| 20 |
+
line-height: 1.45;
|
| 21 |
+
padding: 18px 22px;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
/* Rounded square image card */
|
| 25 |
+
#add-image .wrap.svelte-1ipelgc,
|
| 26 |
+
#add-image .wrap { /* compat across versions */
|
| 27 |
+
border-radius: 28px !important;
|
| 28 |
+
}
|
| 29 |
+
#add-image .input-image,
|
| 30 |
+
#add-image .empty.svelte-1ipelgc {
|
| 31 |
+
border-radius: 28px !important;
|
| 32 |
+
min-width: 240px;
|
| 33 |
+
min-height: 240px;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/* Pill generate button (right side) */
|
| 37 |
+
#gen-btn button {
|
| 38 |
+
border-radius: 999px !important;
|
| 39 |
+
padding: 12px 24px;
|
| 40 |
+
font-size: 18px;
|
| 41 |
+
}
|
| 42 |
+
"""
|
| 43 |
+
|
| 44 |
+
with gr.Blocks(css=CUSTOM_CSS, title="StitchMaster – UI Sketch") as demo:
|
| 45 |
+
# Row 1: Big rounded prompt input
|
| 46 |
+
prompt = gr.Textbox(
|
| 47 |
+
label=None,
|
| 48 |
+
placeholder="Prompt input",
|
| 49 |
+
lines=8,
|
| 50 |
+
elem_id="prompt-box"
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
# Row 2: Left = Add Image card | Right = Generate button
|
| 54 |
+
with gr.Row():
|
| 55 |
+
with gr.Column(scale=1, min_width=300):
|
| 56 |
+
img = gr.Image(
|
| 57 |
+
label="Add Image",
|
| 58 |
+
type="pil",
|
| 59 |
+
elem_id="add-image"
|
| 60 |
+
)
|
| 61 |
+
with gr.Column(scale=3, min_width=300):
|
| 62 |
+
# Spacer effect using Markdown (empty height) then right-aligned button
|
| 63 |
+
gr.Markdown(" \n\n ", elem_classes=["spacer"])
|
| 64 |
+
gen = gr.Button("Generate", elem_id="gen-btn")
|
| 65 |
+
|
| 66 |
+
out = gr.Markdown("") # simple status/output for now
|
| 67 |
+
gen.click(fn=generate_fn, inputs=[prompt, img], outputs=out)
|
| 68 |
+
|
| 69 |
+
if __name__ == "__main__":
|
| 70 |
+
demo.launch()
|