Instructions to use socialtrait/flux-3-image-klein-infendpoint with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use socialtrait/flux-3-image-klein-infendpoint with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("socialtrait/flux-3-image-klein-infendpoint", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Download web.py from socialtrait/flux-3-image-klein-infendpoint: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/socialtrait/flux-3-image-klein-infendpoint/resolve/main/web.py
- Command line
-
hf download hf://socialtrait/flux-3-image-klein-infendpoint/web.py
-
curl -L -o web.py https://huggingface.co/socialtrait/flux-3-image-klein-infendpoint/resolve/main/web.py
1.23 kB
| """Authenticated HTTP wrapper; Modal queues requests to one resident GPU worker.""" | |
| import hmac | |
| import os | |
| from fastapi import Depends, FastAPI, Header, HTTPException | |
| from flux3_engine import GenerationRequest, LegacyRequest | |
| def create_app(engine, startup_error=None): | |
| token = os.environ.get('FLUX_API_TOKEN') | |
| if not token: | |
| raise RuntimeError('FLUX_API_TOKEN must be set for the cloud API') | |
| def authorize(authorization: str | None = Header(default=None)): | |
| if not hmac.compare_digest((authorization or '').encode(), f'Bearer {token}'.encode()): | |
| raise HTTPException(401, 'Invalid bearer token') | |
| app = FastAPI(title='FLUX.3 Klein', dependencies=[Depends(authorize)]) | |
| def ready(): | |
| if startup_error or not engine or engine.pipe is None: | |
| raise HTTPException(503, startup_error or 'Model not ready') | |
| def health(): | |
| ready() | |
| return engine.health() | |
| def generate(request: GenerationRequest): | |
| ready() | |
| return engine.generate(request) | |
| def legacy(request: LegacyRequest): | |
| ready() | |
| return engine.legacy(request.model_dump()) | |
| return app | |