Skip to content

Commit

Permalink
feat(runner): add diffusers pull script and upgrade to py3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
philwinder committed Nov 24, 2024
1 parent c0f6434 commit 0771b8c
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 212 deletions.
2 changes: 1 addition & 1 deletion runner/helix-diffusers/.python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.10
3.11
53 changes: 53 additions & 0 deletions runner/helix-diffusers/pull.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import argparse
import os

from huggingface_hub import snapshot_download


def download_model(model_name: str, save_path: str, pipeline_type: str = "sd"):
"""
Download model weights from Hugging Face Hub
Args:
model_name (str): Name of the model on Hugging Face Hub
save_path (str): Local directory path to save the model
pipeline_type (str): Type of pipeline to use ('sd' for StableDiffusion or 'flux' for Flux)
"""
print(f"Downloading model: {model_name}")

os.makedirs(save_path, exist_ok=True)

# Download all model files directly without pipeline initialization
snapshot_download(
repo_id=model_name,
cache_dir=save_path,
local_dir=save_path,
ignore_patterns=["*.md", "*.txt"],
)

print(f"Model successfully downloaded to: {save_path}")

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Download Stable Diffusion or Flux model weights")
parser.add_argument(
"--model_name",
type=str,
required=True,
help="Name of the model on Hugging Face Hub (e.g., 'runwayml/stable-diffusion-v1-5' or 'black-forest-labs/FLUX.1-schnell')"
)
parser.add_argument(
"--save_path",
type=str,
default="models",
help="Directory path to save the model (default: 'models')"
)
parser.add_argument(
"--pipeline_type",
type=str,
choices=["sd", "flux"],
default="sd",
help="Type of pipeline to use: 'sd' for StableDiffusion or 'flux' for Flux (default: 'sd')"
)

args = parser.parse_args()
download_model(args.model_name, args.save_path, args.pipeline_type)
14 changes: 11 additions & 3 deletions runner/helix-diffusers/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ name = "helix-diffusers"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
"accelerate>=1.1.1",
"diffusers>=0.31.0",
"fastapi>=0.115.5",
"httpx>=0.27.2",
"protobuf>=5.28.3",
"sentencepiece>=0.2.0",
"torch>=2.5.1",
"torch==2.5.1+cu124",
"transformers>=4.46.3",
"uvicorn>=0.32.1",
]
Expand All @@ -24,6 +24,14 @@ dev = [
"ruff>=0.8.0",
]

[tool.uv.sources]
torch = { index = "pytorch-cu124" }

[[tool.uv.index]]
name = "pytorch-cu124"
url = "https://download.pytorch.org/whl/cu124"
explicit = true

[tool.ruff]
line-length = 100
indent-width = 4
Expand All @@ -33,4 +41,4 @@ target-version = "py311"
filterwarnings = [
"ignore::UserWarning",
"ignore::DeprecationWarning",
]
]
Loading

0 comments on commit 0771b8c

Please sign in to comment.