Spaces:
Runtime error
Runtime error
Update app.py
Browse files1 unmodified line23456789101112131415161718193 unmodified lines2324252627282930313233343536378 unmodified lines464748495051521 unmodified lineimport numpy as npimport randomimport spacesfrom diffusers import AuraFlowPipelineimport torchdevice = "cuda" if torch.cuda.is_available() else "cpu"pipe = AuraFlowPipeline.from_pretrained("fal/AuraFlow-v0.2",torch_dtype=torch.float16).to("cuda")MAX_SEED = np.iinfo(np.int32).maxMAX_IMAGE_SIZE = 1024@spaces.GPU()def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, num_inference_steps=4, progress=gr.Progress(track_tqdm=True)):3 unmodified lineswidth = width,height = height,num_inference_steps = num_inference_steps,generator = generator).images[0]return image, seedexamples = ["A photo of a lavender cat","Astronaut in a jungle, cold color palette, muted colors, detailed, 8k","An astronaut riding a green horse","A delicious ceviche cheesecake slice",]css="""8 unmodified lineswith gr.Column(elem_id="col-container"):gr.Markdown(f"""# FLUX.1 SchnellDemo of the [FLUX.1 Schnell](https://huggingface.co/fal/AuraFlow) 12B parameters rectified flow transformer distilled from [FLUX.1 Pro](https://blackforestlabs.ai/) for fast generation in 4 steps[[blog](https://blackforestlabs.ai/2024/07/31/announcing-black-forest-labs/)] [[model](https://black-forest-labs/FLUX.1-schnell)]]""")1 unmodified line23456789101112131415161718192021222324252627282930313233343536373 unmodified lines4142434445464748495051525354558 unmodified lines646566676869701 unmodified lineimport numpy as npimport randomimport spacesimport torchfrom diffusers import FluxPipeline, FluxTransformer2DModel,FlowMatchEulerDiscreteScheduler, AutoencoderKLfrom transformers import CLIPTextModel, CLIPTokenizer,T5EncoderModel, T5TokenizerFastdtype = torch.bfloat16device = "cuda"sd3_repo = "stabilityai/stable-diffusion-3-medium-diffusers"scheduler = FlowMatchEulerDiscreteScheduler.from_pretrained (sd3_repo, subfolder="scheduler")text_encoder = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14", torch_dtype=dtype)tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14", torch_dtype=dtype)text_encoder_2 = T5EncoderModel.from_pretrained(sd3_repo, subfolder="text_encoder_3", torch_dtype=dtype)tokenizer_2 = T5TokenizerFast.from_pretrained(sd3_repo, subfolder="tokenizer_3", torch_dtype=dtype)vae = AutoencoderKL.from_pretrained("diffusers-internal-dev/FLUX.1-schnell", subfolder="vae", torch_dtype=dtype)transformer = FluxTransformer2DModel.from_pretrained("diffusers-internal-dev/FLUX.1-schnell", subfolder="transformer", torch_dtype=dtype)device = "cuda" if torch.cuda.is_available() else "cpu"pipe = FluxPipeline(scheduler=scheduler,text_encoder=text_encoder,tokenizer=tokenizer,text_encoder_2=text_encoder_2,tokenizer_2=tokenizer_2,vae=vae,transformer=transformer,).to("cuda")MAX_SEED = np.iinfo(np.int32).maxMAX_IMAGE_SIZE = 2048@spaces.GPU()def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, num_inference_steps=4, progress=gr.Progress(track_tqdm=True)):3 unmodified lineswidth = width,height = height,num_inference_steps = num_inference_steps,generator = generator,guidance_scale=0.0).images[0]return image, seedexamples = ["a tiny astronaut hatching from an egg on the moon","a cat holding a sign that says hello world","an anime illustration of a wiener schnitzel",]css="""8 unmodified lineswith gr.Column(elem_id="col-container"):gr.Markdown(f"""# FLUX.1 Schnell[FLUX.1 Schnell](https://huggingface.co/black-forest-labs/FLUX.1-schnell) demo 12B parameters rectified flow transformer distilled from [FLUX.1 Pro](https://blackforestlabs.ai/) for fast generation in 4 steps[[blog](https://blackforestlabs.ai/2024/07/31/announcing-black-forest-labs/)] [[model](https://black-forest-labs/FLUX.1-schnell)]]""")
app.py+29-11