Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files13 unmodified lines1415161718171819202122232420252627283 unmodified lines3233343035363334373839404142404344454634 unmodified lines818283818485868788899088919293948 unmodified lines1031041051031061071081096 unmodified lines1161171181161191201211224 unmodified lines12712812912713013113213385 unmodified lines21922022121922222322422513 unmodified lines"""
css = '''.gradio-container{max-width: 560px !important}h1{text-align:center}.gradio-container { max-width: 560px !important; margin: 0 auto !important;}h1 { text-align: center;}footer { visibility: hidden visibility: hidden;}'''
3 unmodified lines "Vector illustration of a horse, vector graphic design with flat colors on an brown background in the style of vector art, using simple shapes and graphics with simple details, professionally designed as a tshirt logo ready for print on a white background. --ar 89:82 --v 6.0 --style raw", "Man in brown leather jacket posing for camera, in the style of sleek and stylized, clockpunk, subtle shades, exacting precision, ferrania p30 --ar 67:101 --v 5", "Commercial photography, giant burger, white lighting, studio light, 8k octane rendering, high resolution photography, insanely detailed, fine details, on white isolated plain, 8k, commercial photography, stock photo, professional color grading, --v 4 --ar 9:16 " ]
MODEL_ID = os.getenv("MODEL_VAL_PATH") #uses SG161222/RealVisXL_V5.0_Lightning or SG161222/RealVisXL_V4.0_LightningMODEL_ID = os.getenv("MODEL_VAL_PATH") # uses SG161222/RealVisXL_V5.0_Lightning or SG161222/RealVisXL_V4.0_LightningMAX_IMAGE_SIZE = int(os.getenv("MAX_IMAGE_SIZE", "4096"))USE_TORCH_COMPILE = os.getenv("USE_TORCH_COMPILE", "0") == "1"ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "0") == "1"BATCH_SIZE = int(os.getenv("BATCH_SIZE", "1")) # Allow generating multiple images at once
#Load model outside of function# Load model outside of functiondevice = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")pipe = StableDiffusionXLPipeline.from_pretrained( MODEL_ID,34 unmodified lines guidance_scale: float = 3, num_inference_steps: int = 25, randomize_seed: bool = False, use_resolution_binning: bool = True, use_resolution_binning: bool = True, num_images: int = 4, # Number of images to generate progress=gr.Progress(track_tqdm=True),): seed = int(randomize_seed_fn(seed, randomize_seed)) generator = torch.Generator(device=device).manual_seed(seed)
#Options # Options options = { "prompt": [prompt] * num_images, "negative_prompt": [negative_prompt] * num_images if use_negative_prompt else None,8 unmodified lines if use_resolution_binning: options["use_resolution_binning"] = True
#Images potential batches # Images potential batches images = [] for i in range(0, num_images, BATCH_SIZE): batch_options = options.copy()6 unmodified lines return image_paths, seed
with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo: gr.Markdown(DESCRIPTIONx) gr.Markdown(DESCRIPTIONx) with gr.Group(): with gr.Row(): prompt = gr.Text(4 unmodified lines container=False, ) run_button = gr.Button("Run", scale=0) result = gr.Gallery(label="Result", columns=2, show_label=False) result = gr.Gallery(label="Result", columns=2, show_label=False) with gr.Accordion("Advanced options", open=False, visible=True): num_images = gr.Slider( label="Number of Images",85 unmodified lines ], outputs=[result, seed], api_name="run", ) )
if __name__ == "__main__": demo.queue(max_size=40).launch(ssr_mode=False)app.py+16-13