Spaces:
Build error
Build error
Download fl.py from aliasystems/README: direct link, hf CLI and curl.
- Browser
- Download file 811 Bytes
-
https://huggingface.co/spaces/aliasystems/README/resolve/main/fl.py
- Command line
-
hf download hf://spaces/aliasystems/README/fl.py
-
curl -L -o fl.py https://huggingface.co/spaces/aliasystems/README/resolve/main/fl.py
811 Bytes
| from dotenv import load_dotenv | |
| import os | |
| import torch | |
| from diffusers import FluxPipeline | |
| # Load the environment variables from .env | |
| load_dotenv() | |
| # Access the token | |
| access_token = os.getenv("HUGGING_FACE_HUB_TOKEN") | |
| # Load the pipeline | |
| pipe = FluxPipeline.from_pretrained( | |
| "black-forest-labs/FLUX.1-dev", | |
| torch_dtype=torch.bfloat16 | |
| ) | |
| # Move the pipeline to the CPU | |
| pipe.to("cpu") | |
| # Define the prompt | |
| prompt = "A homeless cat holding a sign which says, 'Will Youtube for Food'" | |
| # Generate the image using the pipeline | |
| image = pipe( | |
| prompt, | |
| height=1024, | |
| width=1024, | |
| guidance_scale=3.5, | |
| num_inference_steps=50, | |
| max_sequence_length=512, | |
| generator=torch.Generator("cpu").manual_seed(0) # Use CPU generator | |
| ).images[0] | |
| # Save the generated image | |
| image.save("fluxpng.dev") | |