Spaces:
Build error
Build error
Commit ·
f7ea271
1
Parent(s): 966167e
update
Browse files284 unmodified lines28528628728828929019 unmodified lines31031131231331431531631731831932032132248 unmodified lines37137237337437537637737855 unmodified lines434435436437438439440284 unmodified linesexcept:prompt = caption_idscomposed_prompt = tokenizer.decode(prompt)else:19 unmodified linestext_str = ' '.join([f'[{c}]' for c in list(text)])user_prompt += f'<|startoftext|> l{x0} t{y0} r{x1} b{y1} {text_str} <|endoftext|>'composed_prompt = user_promptprompt = tokenizer.encode(user_prompt)if radio == 'TextDiffuser-2':prompt = prompt[:77]while len(prompt) < 77:prompt.append(tokenizer.pad_token_id)prompts_cond = promptprompts_nocond = [tokenizer.pad_token_id]*7748 unmodified lines# negative_prompt=negative_prompt,num_inference_steps=slider_step,guidance_scale=1,).images[0]return tuple([image]), composed_promptwith gr.Blocks() as demo:55 unmodified linesradio = gr.Radio(["TextDiffuser-2", "TextDiffuser-2-LCM"], label="Choices of models", value="TextDiffuser-2")slider_step = gr.Slider(minimum=1, maximum=50, value=20, step=1, label="Sampling step", info="The sampling step for TextDiffuser-2.")slider_guidance = gr.Slider(minimum=1, maximum=9, value=7.5, step=0.5, label="Scale of classifier-free guidance", info="The scale of classifier-free guidance and is set to 7.5 in default.")slider_batch = gr.Slider(minimum=1, maximum=4, value=4, step=1, label="Batch size", info="The number of images to be sampled.")slider_temperature = gr.Slider(minimum=0.1, maximum=2, value=0.7, step=0.1, label="Temperature", info="Control the diversity of layout planner. Higher value indicates more diversity.")slider_natural = gr.Checkbox(label="Natural image generation", value=False, info="The text position and content info will not be incorporated.")284 unmodified lines28528628728828929029119 unmodified lines31131231331431531631731831932032132232332432532648 unmodified lines37537637737837938038138238355 unmodified lines439440441442443444445284 unmodified linesexcept:prompt = caption_idsuser_prompt = tokenizer.decode(prompt)composed_prompt = tokenizer.decode(prompt)else:19 unmodified linestext_str = ' '.join([f'[{c}]' for c in list(text)])user_prompt += f'<|startoftext|> l{x0} t{y0} r{x1} b{y1} {text_str} <|endoftext|>'# composed_prompt = user_promptprompt = tokenizer.encode(user_prompt)composed_prompt = tokenizer.decode(prompt)prompt = prompt[:77]while len(prompt) < 77:prompt.append(tokenizer.pad_token_id)if radio == 'TextDiffuser-2':prompts_cond = promptprompts_nocond = [tokenizer.pad_token_id]*7748 unmodified lines# negative_prompt=negative_prompt,num_inference_steps=slider_step,guidance_scale=1,num_images_per_prompt=slider_batch,).imagesreturn tuple(image), composed_promptwith gr.Blocks() as demo:55 unmodified linesradio = gr.Radio(["TextDiffuser-2", "TextDiffuser-2-LCM"], label="Choices of models", value="TextDiffuser-2")slider_step = gr.Slider(minimum=1, maximum=50, value=20, step=1, label="Sampling step", info="The sampling step for TextDiffuser-2.")slider_guidance = gr.Slider(minimum=1, maximum=9, value=7.5, step=0.5, label="Scale of classifier-free guidance", info="The scale of cfg and is set to 7.5 in default. When using LCM, cfg is set to 1.")slider_batch = gr.Slider(minimum=1, maximum=4, value=4, step=1, label="Batch size", info="The number of images to be sampled.")slider_temperature = gr.Slider(minimum=0.1, maximum=2, value=0.7, step=0.1, label="Temperature", info="Control the diversity of layout planner. Higher value indicates more diversity.")slider_natural = gr.Checkbox(label="Natural image generation", value=False, info="The text position and content info will not be incorporated.")
app.py+12-7