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 +9 -6
demo/hf_repo_assets.py
CHANGED
|
@@ -6,11 +6,14 @@ from pathlib import Path
|
|
| 6 |
|
| 7 |
from huggingface_hub import snapshot_download
|
| 8 |
|
| 9 |
-
|
| 10 |
|
| 11 |
|
| 12 |
-
def
|
| 13 |
-
return
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
def get_cache_dir() -> str | None:
|
|
@@ -19,8 +22,8 @@ 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
|
| 23 |
-
resolved_repo_id = repo_id or
|
| 24 |
if not resolved_repo_id:
|
| 25 |
return None
|
| 26 |
|
|
@@ -43,7 +46,7 @@ def ensure_repo_assets(repo_id: str | None = None) -> Path | None:
|
|
| 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 {}
|
|
|
|
| 6 |
|
| 7 |
from huggingface_hub import snapshot_download
|
| 8 |
|
| 9 |
+
DEFAULT_STAGE2_MODEL_REPO_ID = "SynLayers/synlayers"
|
| 10 |
|
| 11 |
|
| 12 |
+
def get_stage2_model_repo_id() -> str:
|
| 13 |
+
return (
|
| 14 |
+
os.environ.get("SYNLAYERS_STAGE2_MODEL_REPO")
|
| 15 |
+
or DEFAULT_STAGE2_MODEL_REPO_ID
|
| 16 |
+
)
|
| 17 |
|
| 18 |
|
| 19 |
def get_cache_dir() -> str | None:
|
|
|
|
| 22 |
|
| 23 |
@lru_cache(maxsize=4)
|
| 24 |
def ensure_repo_assets(repo_id: str | None = None) -> Path | None:
|
| 25 |
+
"""Download Stage 2 runtime assets from the configured model repo."""
|
| 26 |
+
resolved_repo_id = repo_id or get_stage2_model_repo_id()
|
| 27 |
if not resolved_repo_id:
|
| 28 |
return None
|
| 29 |
|
|
|
|
| 46 |
|
| 47 |
|
| 48 |
def build_repo_asset_overrides(repo_id: str | None = None) -> dict[str, str]:
|
| 49 |
+
"""Return repo-local Stage 2 asset paths after downloading the uploaded bundle."""
|
| 50 |
local_root = ensure_repo_assets(repo_id)
|
| 51 |
if local_root is None:
|
| 52 |
return {}
|