Image-to-Image
Diffusers
Safetensors
image-decomposition
layered-image-editing
diffusion
flux
lora
transparent-rgba
Instructions to use SynLayers/synlayers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use SynLayers/synlayers with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("fill-in-base-model", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("SynLayers/synlayers") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps
- Draw Things
Upload demo/hf_repo_assets.py with huggingface_hub
Browse files- demo/hf_repo_assets.py +7 -5
demo/hf_repo_assets.py
CHANGED
|
@@ -6,9 +6,11 @@ from pathlib import Path
|
|
| 6 |
|
| 7 |
from huggingface_hub import snapshot_download
|
| 8 |
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
def get_cache_dir() -> str | None:
|
|
@@ -17,8 +19,8 @@ def get_cache_dir() -> str | None:
|
|
| 17 |
|
| 18 |
@lru_cache(maxsize=4)
|
| 19 |
def ensure_repo_assets(repo_id: str | None = None) -> Path | None:
|
| 20 |
-
"""Download
|
| 21 |
-
resolved_repo_id = repo_id or
|
| 22 |
if not resolved_repo_id:
|
| 23 |
return None
|
| 24 |
|
|
@@ -41,7 +43,7 @@ def ensure_repo_assets(repo_id: str | None = None) -> Path | None:
|
|
| 41 |
|
| 42 |
|
| 43 |
def build_repo_asset_overrides(repo_id: str | None = None) -> dict[str, str]:
|
| 44 |
-
"""Return repo-local
|
| 45 |
local_root = ensure_repo_assets(repo_id)
|
| 46 |
if local_root is None:
|
| 47 |
return {}
|
|
|
|
| 6 |
|
| 7 |
from huggingface_hub import snapshot_download
|
| 8 |
|
| 9 |
+
DEFAULT_MODEL_REPO_ID = "SynLayers/Bbox-caption-8b"
|
| 10 |
|
| 11 |
+
|
| 12 |
+
def get_model_repo_id() -> str | None:
|
| 13 |
+
return os.environ.get("SYNLAYERS_MODEL_REPO") or DEFAULT_MODEL_REPO_ID
|
| 14 |
|
| 15 |
|
| 16 |
def get_cache_dir() -> str | None:
|
|
|
|
| 19 |
|
| 20 |
@lru_cache(maxsize=4)
|
| 21 |
def ensure_repo_assets(repo_id: str | None = None) -> Path | None:
|
| 22 |
+
"""Download required runtime assets from the uploaded model repo when configured."""
|
| 23 |
+
resolved_repo_id = repo_id or get_model_repo_id()
|
| 24 |
if not resolved_repo_id:
|
| 25 |
return None
|
| 26 |
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
def build_repo_asset_overrides(repo_id: str | None = None) -> dict[str, str]:
|
| 46 |
+
"""Return repo-local asset paths after downloading the uploaded bundle."""
|
| 47 |
local_root = ensure_repo_assets(repo_id)
|
| 48 |
if local_root is None:
|
| 49 |
return {}
|