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 validate_deployment.py from socialtrait/flux-3-image-klein-infendpoint: direct link, hf CLI and curl.
- Browser
- Download file 2.23 kB
-
https://huggingface.co/socialtrait/flux-3-image-klein-infendpoint/resolve/main/validate_deployment.py
- Command line
-
hf download hf://socialtrait/flux-3-image-klein-infendpoint/validate_deployment.py
-
curl -L -o validate_deployment.py https://huggingface.co/socialtrait/flux-3-image-klein-infendpoint/resolve/main/validate_deployment.py
2.23 kB
| """Isolated A10 smoke test: prepare on CPU, then load and generate with Hub offline.""" | |
| import base64 | |
| import json | |
| from pathlib import Path | |
| import modal | |
| from modal_app import ROOT, cache, image | |
| validation_image = image.add_local_file(ROOT / 'verify_checkpoint.py', '/root/verify_checkpoint.py', copy=True) | |
| for filename in ('modal_app.py', 'requirements.txt'): | |
| validation_image = validation_image.add_local_file(ROOT / filename, f'/root/{filename}', copy=True) | |
| app = modal.App('socialtrait-flux3-checkpoint-validation') | |
| def prepare(): | |
| from flux3_engine import Settings, download_weights | |
| from verify_checkpoint import verify_checkpoint | |
| settings = Settings.from_env() | |
| path = download_weights(settings) | |
| verification = verify_checkpoint(path, settings.quantization, check_hashes=True) | |
| cache.commit() | |
| return {'path': path, 'verification': verification} | |
| def generate_offline(path: str): | |
| from handler import EndpointHandler | |
| # Exercise the mounted-repository HF handler with network downloads disabled. | |
| handler = EndpointHandler(path) | |
| return handler({'inputs': 'A photographic portrait of an adult woman, natural face and eyes, bright background', | |
| 'width': 1024, 'height': 1024, 'seed': 42}) | |
| def main(output_dir: str = '/tmp/flux-selfcontained-validation'): | |
| prepared = prepare.remote() | |
| print('Verified selected Socialtrait weights:', prepared['verification']) | |
| result = generate_offline.remote(prepared['path']) | |
| output = Path(output_dir) | |
| output.mkdir(parents=True, exist_ok=True) | |
| (output / 'sample.jpg').write_bytes(base64.b64decode(result.pop('image'))) | |
| result.update(status='success', hub_offline=True, verification=prepared['verification']) | |
| (output / 'results.json').write_text(json.dumps(result, indent=2) + '\n') | |
| print(json.dumps(result, indent=2)) | |