Instructions to use huaichang/EditaLive with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use huaichang/EditaLive with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("huaichang/EditaLive", 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 webcam/protocol.py from huaichang/EditaLive: direct link, hf CLI and curl.
- Browser
- Download file 737 Bytes
-
https://huggingface.co/huaichang/EditaLive/resolve/main/webcam/protocol.py
- Command line
-
hf download hf://huaichang/EditaLive/webcam/protocol.py
-
curl -L -o protocol.py https://huggingface.co/huaichang/EditaLive/resolve/main/webcam/protocol.py
737 Bytes
| import json | |
| import struct | |
| MAX_IMAGE_BYTES = 16 * 1024 * 1024 | |
| MAX_HEADER_BYTES = 8192 | |
| def pack(header, payload): | |
| data = json.dumps(header, separators=(",", ":"), allow_nan=False).encode() | |
| return struct.pack("!I", len(data)) + data + payload | |
| def unpack(data): | |
| if len(data) < 5 or len(data) > MAX_IMAGE_BYTES + MAX_HEADER_BYTES + 4: | |
| raise ValueError("Invalid image message size.") | |
| size = struct.unpack("!I", data[:4])[0] | |
| if not 0 < size <= MAX_HEADER_BYTES or 4 + size >= len(data): | |
| raise ValueError("Invalid image header.") | |
| header = json.loads(data[4:4 + size]) | |
| if not isinstance(header, dict): | |
| raise ValueError("Image header must be an object.") | |
| return header, data[4 + size:] | |