Instructions to use RobertML/edge-super-compile-08 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use RobertML/edge-super-compile-08 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("RobertML/edge-super-compile-08", 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
Download src/main.py from RobertML/edge-super-compile-08: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/RobertML/edge-super-compile-08/resolve/main/src/main.py
- Command line
-
hf download hf://RobertML/edge-super-compile-08/src/main.py
-
curl -L -o main.py https://huggingface.co/RobertML/edge-super-compile-08/resolve/main/src/main.py
1.42 kB
| import atexit | |
| from io import BytesIO | |
| from multiprocessing.connection import Listener | |
| from os import chmod, remove | |
| from os.path import abspath, exists | |
| from pathlib import Path | |
| import torch | |
| from PIL.JpegImagePlugin import JpegImageFile | |
| from pipelines.models import TextToImageRequest | |
| from pipeline import load_pipeline, infer | |
| SOCKET = abspath(Path(__file__).parent.parent / "inferences.sock") | |
| data = BytesIO() | |
| def send_image(image, connection): | |
| data.seek(0) | |
| data.truncate() | |
| image.save(data, format='JPEG') | |
| connection.send_bytes(data.getvalue()) | |
| def at_exit(): | |
| torch.cuda.empty_cache() | |
| def main(): | |
| atexit.register(at_exit) | |
| print(f"Loading pipeline") | |
| pipeline = load_pipeline() | |
| print(f"Pipeline loaded, creating socket at '{SOCKET}'") | |
| if exists(SOCKET): | |
| remove(SOCKET) | |
| with Listener(SOCKET) as listener: | |
| chmod(SOCKET, 0o777) | |
| print(f"Awaiting connections") | |
| with listener.accept() as connection: | |
| print(f"Connected") | |
| while True: | |
| try: | |
| request = TextToImageRequest.model_validate_json(connection.recv_bytes().decode("utf-8")) | |
| except EOFError: | |
| print(f"Inference socket exiting") | |
| return | |
| image = infer(request, pipeline) | |
| send_image(image,connection) | |
| if __name__ == '__main__': | |
| main() | |