-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runner): add diffusers pull script and upgrade to py3.11
- Loading branch information
1 parent
c0f6434
commit 0771b8c
Showing
4 changed files
with
85 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.10 | ||
3.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.