Spaces:
Runtime error
Runtime error
lzyhha commited on
Commit ·
42002e4
1
Parent(s): 808cfcf
space
Browse filesFiles changed (2)
- app.py+6-11
- visualcloze.py+5-4
70 unmodified lines717273747576777879801 unmodified line82838485868788899015 unmodified lines10610710810911011111230 unmodified lines14314414514614714814915015115215315415515615715815970 unmodified lines""")gr.Markdown(GUIDANCE)# gr.Markdown("<div style='font-size: 24px; font-weight: bold; color: #FF9999;'>" +# "Note: Click the task button in the right bottom to acquire examples of tasks." +# "</div>", )# Pre-create all possible image componentsall_image_inputs = []1 unmodified linerow_texts = []with gr.Row():# 左侧列:图像网格和提示输入with gr.Column(scale=2):# 图像网格部分for i in range(max_grid_h):# Add row label before each rowrow_texts.append(gr.Markdown(15 unmodified lines)all_image_inputs.append(img_input)# 提示输入部分layout_prompt = gr.Textbox(label="Layout Description (Auto-filled, Read-only)",placeholder="Layout description will be automatically filled based on grid size...",30 unmodified linesgr.Markdown(CITATION)# 右侧列:输出图像with gr.Column(scale=2):output_gallery = gr.Gallery(label="Generated Results",show_label=True,elem_id="output_gallery",columns=None, # 设为None以允许自动调整rows=None, # 设为None以允许自动调整height="auto",allow_preview=True,object_fit="contain" # 确保图片完整显示)gr.Markdown("# Task Examples")70 unmodified lines7172737475761 unmodified line787980818283848515 unmodified lines10110210310410510610730 unmodified lines13813914014114214314414514614714814915015115215315470 unmodified lines""")gr.Markdown(GUIDANCE)# Pre-create all possible image componentsall_image_inputs = []1 unmodified linerow_texts = []with gr.Row():with gr.Column(scale=2):# Image gridfor i in range(max_grid_h):# Add row label before each rowrow_texts.append(gr.Markdown(15 unmodified lines)all_image_inputs.append(img_input)# Promptslayout_prompt = gr.Textbox(label="Layout Description (Auto-filled, Read-only)",placeholder="Layout description will be automatically filled based on grid size...",30 unmodified linesgr.Markdown(CITATION)# Outputwith gr.Column(scale=2):output_gallery = gr.Gallery(label="Generated Results",show_label=True,elem_id="output_gallery",columns=None,rows=None,height="auto",allow_preview=True,object_fit="contain")gr.Markdown("# Task Examples")
240 unmodified lines2412422432442452462478 unmodified lines256257258259260261262125 unmodified lines38838939039139239339450 unmodified lines445446447448449450451240 unmodified linesreturn output_imagedef process_images(self, images: list[list[Image.Image]], text_prompt: list[str],seed: int = 0,cfg: int = 30,steps: int = 30,8 unmodified linesimages (list[list[Image.Image]]): A grid-layout image collection, each row represents an in-context example or the current query,where the current query should be placed in the last row.The target image can be None in the input. The other images should be the PIL Image class (Image.Image).text_prompt (list[str]): Three prompts, representing the layout prompt, task prompt, and content prompt respectively.seed (int): A fixed integer seed to ensure reproducibility of the random elements in the processing.cfg (int): The strength of Classifier-Free Diffusion Guidance.steps (int): The number of sampling steps.125 unmodified linesx = [noise]with torch.no_grad():inp = prepare_modified(t5=self.t5, clip=self.clip, img=x, prompt=[' '.join(text_prompt)], proportion_empty_prompts=0.0)model_kwargs = dict(txt=inp["txt"],50 unmodified linesupsampling_steps=upsampling_steps,upsampling_noise=upsampling_noise,generator=rng,content_prompt=text_prompt[2])ret.append(upsampled)return ret240 unmodified lines2412422432442452462472488 unmodified lines257258259260261262263125 unmodified lines38939039139239339439550 unmodified lines446447448449450451452240 unmodified linesreturn output_imagedef process_images(self, images: list[list[Image.Image]],prompts: list[str],seed: int = 0,cfg: int = 30,steps: int = 30,8 unmodified linesimages (list[list[Image.Image]]): A grid-layout image collection, each row represents an in-context example or the current query,where the current query should be placed in the last row.The target image can be None in the input. The other images should be the PIL Image class (Image.Image).prompts (list[str]): Three prompts, representing the layout prompt, task prompt, and content prompt respectively.seed (int): A fixed integer seed to ensure reproducibility of the random elements in the processing.cfg (int): The strength of Classifier-Free Diffusion Guidance.steps (int): The number of sampling steps.125 unmodified linesx = [noise]with torch.no_grad():inp = prepare_modified(t5=self.t5, clip=self.clip, img=x, prompt=[' '.join(prompts)], proportion_empty_prompts=0.0)model_kwargs = dict(txt=inp["txt"],50 unmodified linesupsampling_steps=upsampling_steps,upsampling_noise=upsampling_noise,generator=rng,content_prompt=prompts[2])ret.append(upsampled)return ret
app.py+6-11
visualcloze.py+5-4