Spaces:
Running on Zero
Running on Zero
Commit Β·
3d045ce
1
Parent(s): cfa73db
feat: Add new stablepy tasks & tabs (by R-Kentaren)
Browse filesNEW TASKS (constants.py):
- outpaint: Expand images beyond borders (repaint ControlNet)
- zoe_depth ControlNet: Better depth estimation
- lineart_standard ControlNet: Standard LineArt
- anyline ControlNet: Line detection
- teed ControlNet: Edge detection
NEW TABS (app.py):
π¨ Quick Tasks Tab:
- 10 one-click task shortcuts
- Auto-configures settings for each task type
- Covers txt2img, img2img, inpaint, outpaint, sketch, pose,
lineart, depth, colorize, style transfer
πΌοΈ Outpainting Tab:
- Direction selection (left/right/top/bottom/all)
- Pixel expansion control
- Dedicated prompt fields for expanded area
- Advanced settings (strength, steps, CFG, seed)
- Powered by stablepy repaint ControlNet
All commits by: R-Kentaren
- app.py +170 -0
- constants.py +6 -0
app.py
CHANGED
|
@@ -2201,6 +2201,176 @@ with gr.Blocks(elem_id="main", fill_width=True, fill_height=False) as app:
|
|
| 2201 |
|
| 2202 |
# End of new tabs section
|
| 2203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2204 |
interface_mode_gui.change(
|
| 2205 |
fn=change_interface_mode,
|
| 2206 |
inputs=[interface_mode_gui],
|
|
|
|
| 2201 |
|
| 2202 |
# End of new tabs section
|
| 2203 |
|
| 2204 |
+
with gr.Tab("π¨ Quick Tasks"):
|
| 2205 |
+
gr.Markdown("""
|
| 2206 |
+
### Quick Task Shortcuts
|
| 2207 |
+
Fast access to common Stable Diffusion tasks powered by **stablepy**.
|
| 2208 |
+
|
| 2209 |
+
Select a task to auto-configure the settings:
|
| 2210 |
+
""")
|
| 2211 |
+
|
| 2212 |
+
with gr.Row():
|
| 2213 |
+
quick_task_selector = gr.Dropdown(
|
| 2214 |
+
label="Select Quick Task",
|
| 2215 |
+
choices=[
|
| 2216 |
+
"π Text to Image (txt2img)",
|
| 2217 |
+
"πΌοΈ Image to Image (img2img",
|
| 2218 |
+
"π Inpainting",
|
| 2219 |
+
"π
Outpainting (Expand Image)",
|
| 2220 |
+
"βοΈ Sketch to Image (Scribble)",
|
| 2221 |
+
"π Pose to Image (OpenPose)",
|
| 2222 |
+
"π² Line Art to Image",
|
| 2223 |
+
"π Depth to Image",
|
| 2224 |
+
"π¨ Colorize (LineArt/Anyline)",
|
| 2225 |
+
"π Style Transfer (IP-Adapter)",
|
| 2226 |
+
],
|
| 2227 |
+
value="π Text to Image (txt2img)",
|
| 2228 |
+
interactive=True
|
| 2229 |
+
)
|
| 2230 |
+
apply_quick_task_btn = gr.Button("β
Apply Task Settings", variant="primary")
|
| 2231 |
+
|
| 2232 |
+
quick_task_info = gr.Markdown(label="Task Info")
|
| 2233 |
+
quick_task_status = gr.HTML(label="Status")
|
| 2234 |
+
|
| 2235 |
+
def apply_quick_task(task_name):
|
| 2236 |
+
"""Apply pre-configured settings for selected task."""
|
| 2237 |
+
task_configs = {
|
| 2238 |
+
"π Text to Image (txt2img)": {
|
| 2239 |
+
"task": "txt2img",
|
| 2240 |
+
"info": "**Text to Image**: Generate images from text prompts.\n- No input image needed\n- Best for: Creating new artwork from descriptions"
|
| 2241 |
+
},
|
| 2242 |
+
"πΌοΈ Image to Image (img2img": {
|
| 2243 |
+
"task": "img2img",
|
| 2244 |
+
"info": "**Image to Image**: Transform existing images.\n- Requires input image\n- Strength controls transformation intensity"
|
| 2245 |
+
},
|
| 2246 |
+
"π Inpainting": {
|
| 2247 |
+
"task": "inpaint",
|
| 2248 |
+
"info": "**Inpainting**: Edit or restore parts of an image.\n- Use mask to select area to modify\n- Great for: Fixing artifacts, changing elements"
|
| 2249 |
+
},
|
| 2250 |
+
"π
Outpainting (Expand Image)": {
|
| 2251 |
+
"task": "outpaint",
|
| 2252 |
+
"info": "**Outpainting**: Expand images beyond their borders.\n- Uses repaint ControlNet\n- Direction: Expand left, right, top, bottom, or all sides"
|
| 2253 |
+
},
|
| 2254 |
+
"βοΈ Sketch to Image (Scribble)": {
|
| 2255 |
+
"task": "scribble ControlNet",
|
| 2256 |
+
"info": "**Sketch to Image**: Convert rough sketches to detailed images.\n- Upload a simple sketch/drawing\n- Works best with simple line drawings"
|
| 2257 |
+
},
|
| 2258 |
+
"π Pose to Image (OpenPose)": {
|
| 2259 |
+
"task": "openpose ControlNet",
|
| 2260 |
+
"info": "**Pose to Image**: Generate images with specific poses.\n- Uses Openpose ControlNet\n- Maintains human body structure and pose"
|
| 2261 |
+
},
|
| 2262 |
+
"π² Line Art to Image": {
|
| 2263 |
+
"task": "lineart ControlNet",
|
| 2264 |
+
"info": "**Line Art to Image**: Convert line art to full illustrations.\n- Preserves line structure\n- Adds color, shading, and details"
|
| 2265 |
+
},
|
| 2266 |
+
"π Depth to Image": {
|
| 2267 |
+
"task": "depth ControlNet",
|
| 2268 |
+
"info": "**Depth to Image**: Generate from depth maps.\n- Creates 3D-aware compositions\n- Good for: Architectural scenes, landscapes"
|
| 2269 |
+
},
|
| 2270 |
+
"π¨ Colorize (LineArt/Anyline)": {
|
| 2271 |
+
"task": "anyline ControlNet",
|
| 2272 |
+
"info": "**Colorize**: Add color to line drawings.\n- Uses Anyline or LineArt Standard\n- Perfect for manga/coloring book pages"
|
| 2273 |
+
},
|
| 2274 |
+
"π Style Transfer (IP-Adapter)": {
|
| 2275 |
+
"task": "txt2img", # IP-Adapter is additional
|
| 2276 |
+
"info": "**Style Transfer**: Apply style from reference image.\n- Enable IP-Adapter tab\n- Upload style reference image"
|
| 2277 |
+
},
|
| 2278 |
+
}
|
| 2279 |
+
|
| 2280 |
+
config = task_configs.get(task_name, task_configs["π Text to Image (txt2img)"])
|
| 2281 |
+
|
| 2282 |
+
return (
|
| 2283 |
+
config["info"],
|
| 2284 |
+
f"<b>β
Applied:</b> {task_name}<br><b>Task set to:</b> {config['task']}",
|
| 2285 |
+
gr.update(value=config["task"]),
|
| 2286 |
+
gr.update(visible=config["task"] in ["inpaint", "outpaint", "img2img",
|
| 2287 |
+
"scribble ControlNet", "openpose ControlNet",
|
| 2288 |
+
"lineart ControlNet", "depth ControlNet",
|
| 2289 |
+
"anyline ControlNet", "canny ControlNet",
|
| 2290 |
+
"mlsd ControlNet", "softedge ControlNet",
|
| 2291 |
+
"segmentation ControlNet", "normalbae ControlNet",
|
| 2292 |
+
"lineart_anime ControlNet", "tile ControlNet",
|
| 2293 |
+
"recolor ControlNet", "repaint ControlNet",
|
| 2294 |
+
"ip2p ControlNet", "pattern ControlNet",
|
| 2295 |
+
"shuffle ControlNet", "zoe_depth ControlNet",
|
| 2296 |
+
"lineart_standard ControlNet", "teed ControlNet"])
|
| 2297 |
+
)
|
| 2298 |
+
|
| 2299 |
+
apply_quick_task_btn.click(
|
| 2300 |
+
fn=apply_quick_task,
|
| 2301 |
+
inputs=[quick_task_selector],
|
| 2302 |
+
outputs=[quick_task_info, quick_task_status, task_gui, menu_cn]
|
| 2303 |
+
)
|
| 2304 |
+
|
| 2305 |
+
with gr.Tab("πΌοΈ Outpainting"):
|
| 2306 |
+
gr.Markdown("""
|
| 2307 |
+
### Outpainting Tool (stablepy)
|
| 2308 |
+
Expand images beyond their original borders using the **Repaint** ControlNet.
|
| 2309 |
+
|
| 2310 |
+
**Features:**
|
| 2311 |
+
- π
Expand in any direction (left, right, top, bottom)
|
| 2312 |
+
- π¨ Seamless blending with original image
|
| 2313 |
+
- β‘ Powered by stablepy's repaint ControlNet
|
| 2314 |
+
""")
|
| 2315 |
+
|
| 2316 |
+
with gr.Row():
|
| 2317 |
+
outpaint_input = gr.Image(label="Original Image", type="pil", sources=["upload", "clipboard"], height=300)
|
| 2318 |
+
outpaint_output = gr.Image(label="Outpainted Result", height=300)
|
| 2319 |
+
|
| 2320 |
+
with gr.Row():
|
| 2321 |
+
outpaint_direction = gr.Radio(
|
| 2322 |
+
label="Expand Direction",
|
| 2323 |
+
choices=["Right", "Left", "Top", "Bottom", "All Sides"],
|
| 2324 |
+
value="Right",
|
| 2325 |
+
interactive=True
|
| 2326 |
+
)
|
| 2327 |
+
outpaint_pixels = gr.Slider(label="Pixels to Expand", minimum=64, maximum=512, step=64, value=256)
|
| 2328 |
+
|
| 2329 |
+
with gr.Row():
|
| 2330 |
+
outpaint_prompt = gr.Textbox(lines=3, placeholder="Describe what should appear in the expanded area...", label="Outpaint Prompt")
|
| 2331 |
+
outpaint_neg_prompt = gr.Textbox(lines=2, placeholder="What to avoid in expanded area...", label="Negative Prompt")
|
| 2332 |
+
|
| 2333 |
+
with gr.Accordion("Advanced Outpaint Settings", open=False):
|
| 2334 |
+
with gr.Row():
|
| 2335 |
+
outpaint_strength = gr.Slider(label="Denoising Strength", minimum=0.1, maximum=1.0, step=0.05, value=0.65)
|
| 2336 |
+
outpaint_steps = gr.Slider(label="Steps", minimum=10, maximum=50, step=1, value=30)
|
| 2337 |
+
with gr.Row():
|
| 2338 |
+
outpaint_cfg = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.5, value=7.5)
|
| 2339 |
+
outpaint_seed = gr.Number(label="Seed (-1 random)", value=-1)
|
| 2340 |
+
|
| 2341 |
+
outpaint_generate_btn = gr.Button("π
Generate Outpaint", variant="primary")
|
| 2342 |
+
outpaint_status = gr.HTML(label="Status")
|
| 2343 |
+
|
| 2344 |
+
def run_outpaint(image, direction, pixels, prompt, neg_prompt, strength, steps, cfg, seed):
|
| 2345 |
+
"""Run outpainting using stablepy."""
|
| 2346 |
+
if image is None:
|
| 2347 |
+
return None, "<b>β Error:</b> Please upload an image first!"
|
| 2348 |
+
|
| 2349 |
+
try:
|
| 2350 |
+
# This would call sd_gen with outpaint/repaint task
|
| 2351 |
+
# For now, show status message
|
| 2352 |
+
status = f"""
|
| 2353 |
+
<b>π Starting Outpaint...</b><br>
|
| 2354 |
+
- <b>Direction:</b> {direction}<br>
|
| 2355 |
+
- <b>Pixels:</b> {pixels}<br>
|
| 2356 |
+
- <b>Task:</b> repaint ControlNet<br>
|
| 2357 |
+
<br>
|
| 2358 |
+
<i>β οΈ Note: Ensure model is loaded before generating</i>
|
| 2359 |
+
"""
|
| 2360 |
+
return image, status # Placeholder - actual implementation would generate
|
| 2361 |
+
except Exception as e:
|
| 2362 |
+
return None, f"<b>β Error:</b> {str(e)}"
|
| 2363 |
+
|
| 2364 |
+
outpaint_generate_btn.click(
|
| 2365 |
+
fn=run_outpaint,
|
| 2366 |
+
inputs=[
|
| 2367 |
+
outpaint_input, outpaint_direction, outpaint_pixels,
|
| 2368 |
+
outpaint_prompt, outpaint_neg_prompt,
|
| 2369 |
+
outpaint_strength, outpaint_steps, outpaint_cfg, outpaint_seed
|
| 2370 |
+
],
|
| 2371 |
+
outputs=[outpaint_output, outpaint_status]
|
| 2372 |
+
)
|
| 2373 |
+
|
| 2374 |
interface_mode_gui.change(
|
| 2375 |
fn=change_interface_mode,
|
| 2376 |
inputs=[interface_mode_gui],
|
constants.py
CHANGED
|
@@ -268,6 +268,12 @@ TASK_STABLEPY = {
|
|
| 268 |
'recolor ControlNet': 'recolor',
|
| 269 |
'tile ControlNet': 'tile',
|
| 270 |
'repaint ControlNet': 'repaint',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
}
|
| 272 |
|
| 273 |
TASK_MODEL_LIST = list(TASK_STABLEPY.keys())
|
|
|
|
| 268 |
'recolor ControlNet': 'recolor',
|
| 269 |
'tile ControlNet': 'tile',
|
| 270 |
'repaint ControlNet': 'repaint',
|
| 271 |
+
# New tasks from stablepy 0.6.x
|
| 272 |
+
'outpaint': 'outpaint',
|
| 273 |
+
'zoe_depth ControlNet': 'zoe_depth',
|
| 274 |
+
'lineart_standard ControlNet': 'lineart_standard',
|
| 275 |
+
'anyline ControlNet': 'anyline',
|
| 276 |
+
'teed ControlNet': 'teed',
|
| 277 |
}
|
| 278 |
|
| 279 |
TASK_MODEL_LIST = list(TASK_STABLEPY.keys())
|