Spaces:
Build error
Build error
feat: Enable MCP
#1
by multimodalart HF Staff - opened
3 unmodified lines456789103 unmodified linescolorFrom: purplecolorTo: redsdk: gradiosdk_version: 3.50.2app_file: app.pypinned: falselicense: apache-2.03 unmodified lines456789103 unmodified linescolorFrom: purplecolorTo: redsdk: gradiosdk_version: 5.38.0app_file: app.pypinned: falselicense: apache-2.0
18 unmodified lines1920212223243 unmodified lines28293031323377 unmodified lines11111211311411511611728 unmodified lines14614714814915015115215315415515615745 unmodified lines20320420520618 unmodified lines# Background generation via Replicatedef _gen_bg(prompt: str):url = replicate.run("google/imagen-4-fast",input={"prompt": prompt or "cinematic background", "aspect_ratio": "1:1"},3 unmodified lines# Main processing functiondef process_image_and_text(subject_image, adapter_dict, prompt, _unused1, _unused2, size=ADAPTER_SIZE, rank=10.0):seed, guidance_scale, steps = 42, 2.5, 28adapter_image = adapter_dict["image"] if isinstance(adapter_dict, dict) else adapter_dict77 unmodified linesgr.HTML(header_html)gr.Markdown("**Generate context-aware images of your subject with ZenCtrl’s inpainting playground.** Upload a subject + optional mask, write a prompt, and hit **Generate**. \n""Open *Advanced Settings* for an AI-generated background. \n\n""**Note:** The model was trained mainly on interior scenes and other *rigid* objects. Results on people or highly deformable items may contain visual distortions.")28 unmodified linesdef _load_and_show(subj_path, bg_path, prompt_text):"""Takes the three values coming from an Examples rowand returns FOUR objects – one for every output widget:1. subject PIL image -> subj_img2. dict for the sketch component -> ref_img3. prompt string -> promptbox4. pre-rendered result PIL -> output_img"""out_path = subj_path.replace(".png", "_out.png") # your saved resultreturn (45 unmodified lines# ---------------- Launch ---------------------------------------if __name__ == "__main__":demo.launch()18 unmodified lines1920212223242526272829303132333 unmodified lines37383940414243444546474849505152535455565777 unmodified lines13513613713813914014128 unmodified lines17017117217317417517617717817918018118218318418518618718818919019145 unmodified lines23723823924018 unmodified lines# Background generation via Replicatedef _gen_bg(prompt: str):"""Generate a background image using Replicate's imagen-4-fast model.Args:prompt: Text description for the background to generateReturns:PIL.Image: Generated background image in RGB format"""url = replicate.run("google/imagen-4-fast",input={"prompt": prompt or "cinematic background", "aspect_ratio": "1:1"},3 unmodified lines# Main processing functiondef process_image_and_text(subject_image, adapter_dict, prompt, _unused1, _unused2, size=ADAPTER_SIZE, rank=10.0):"""Process subject and adapter images with text prompt to generate inpainted result.Args:subject_image: PIL.Image of the subject to be placedadapter_dict: Either a PIL.Image or dict with 'image' and 'mask' keys for background/sketchprompt: Text description for the generation_unused1: Unused parameter (placeholder)_unused2: Unused parameter (placeholder)size: Target size for processing (default: ADAPTER_SIZE)rank: Rank parameter for the model (default: 10.0)Returns:tuple: (output_image, raw_image) - both are the same PIL.Image result"""seed, guidance_scale, steps = 42, 2.5, 28adapter_image = adapter_dict["image"] if isinstance(adapter_dict, dict) else adapter_dict77 unmodified linesgr.HTML(header_html)gr.Markdown("**Generate context-aware images of your subject with ZenCtrl's inpainting playground.** Upload a subject + optional mask, write a prompt, and hit **Generate**. \n""Open *Advanced Settings* for an AI-generated background. \n\n""**Note:** The model was trained mainly on interior scenes and other *rigid* objects. Results on people or highly deformable items may contain visual distortions.")28 unmodified linesdef _load_and_show(subj_path, bg_path, prompt_text):"""Load example images and prompt for display in the interface.Takes the three values coming from an Examples rowand returns FOUR objects – one for every output widget:1. subject PIL image -> subj_img2. dict for the sketch component -> ref_img3. prompt string -> promptbox4. pre-rendered result PIL -> output_imgArgs:subj_path: Path to subject image filebg_path: Path to background image fileprompt_text: Example prompt textReturns:tuple: (subject_image, sketch_dict, prompt, output_image)"""out_path = subj_path.replace(".png", "_out.png") # your saved resultreturn (45 unmodified lines# ---------------- Launch ---------------------------------------if __name__ == "__main__":demo.launch(mcp_server=True)
README.md+1-1
app.py+36-2