mirror of
https://github.com/modelscope/DiffSynth-Studio.git
synced 2026-03-18 22:08:13 +00:00
update docs
This commit is contained in:
@@ -209,6 +209,13 @@ If you meet problems during installation, they might be caused by upstream depen
|
||||
|
||||
DiffSynth-Studio redesigns the inference and training pipelines for mainstream Diffusion models (including FLUX, Wan, etc.), enabling efficient memory management and flexible model training.
|
||||
|
||||
> Before using model inference or training, you can configure the model download source via [environment variables](/docs/en/Pipeline_Usage/Environment_Variables.md). By default, this project downloads models from ModelScope. Users outside China can switch the download source to Hugging Face:
|
||||
>
|
||||
> ```python
|
||||
> import os
|
||||
> os.environ["DIFFSYNTH_DOWNLOAD_SOURCE"] = "huggingface"
|
||||
> ```
|
||||
|
||||
### Image Synthesis
|
||||
|
||||

|
||||
|
||||
@@ -209,6 +209,13 @@ pip install diffsynth
|
||||
|
||||
DiffSynth-Studio 为主流 Diffusion 模型(包括 FLUX、Wan 等)重新设计了推理和训练流水线,能够实现高效的显存管理、灵活的模型训练。
|
||||
|
||||
> 在进行模型推理和训练前,可通过[环境变量](/docs/zh/Pipeline_Usage/Environment_Variables.md)配置模型下载源,本项目默认从魔搭社区下载模型,非中国用户可将模型下载源修改为 Huggingface:
|
||||
>
|
||||
> ```python
|
||||
> import os
|
||||
> os.environ["DIFFSYNTH_DOWNLOAD_SOURCE"] = "huggingface"
|
||||
> ```
|
||||
|
||||
### 图像生成模型
|
||||
|
||||

|
||||
|
||||
@@ -11,7 +11,7 @@ class ModelConfig:
|
||||
path: Union[str, list[str]] = None
|
||||
model_id: str = None
|
||||
origin_file_pattern: Union[str, list[str]] = None
|
||||
download_resource: str = None
|
||||
download_source: str = None
|
||||
local_model_path: str = None
|
||||
skip_download: bool = None
|
||||
offload_device: Optional[Union[str, torch.device]] = None
|
||||
@@ -36,14 +36,14 @@ class ModelConfig:
|
||||
else:
|
||||
return self.origin_file_pattern
|
||||
|
||||
def parse_download_resource(self):
|
||||
if self.download_resource is None:
|
||||
if os.environ.get('DIFFSYNTH_DOWNLOAD_RESOURCE') is not None:
|
||||
return os.environ.get('DIFFSYNTH_DOWNLOAD_RESOURCE')
|
||||
def parse_download_source(self):
|
||||
if self.download_source is None:
|
||||
if os.environ.get('DIFFSYNTH_DOWNLOAD_SOURCE') is not None:
|
||||
return os.environ.get('DIFFSYNTH_DOWNLOAD_SOURCE')
|
||||
else:
|
||||
return "modelscope"
|
||||
else:
|
||||
return self.download_resource
|
||||
return self.download_source
|
||||
|
||||
def parse_skip_download(self):
|
||||
if self.skip_download is None:
|
||||
@@ -60,8 +60,8 @@ class ModelConfig:
|
||||
def download(self):
|
||||
origin_file_pattern = self.parse_original_file_pattern()
|
||||
downloaded_files = glob.glob(origin_file_pattern, root_dir=os.path.join(self.local_model_path, self.model_id))
|
||||
download_resource = self.parse_download_resource()
|
||||
if download_resource.lower() == "modelscope":
|
||||
download_source = self.parse_download_source()
|
||||
if download_source.lower() == "modelscope":
|
||||
snapshot_download(
|
||||
self.model_id,
|
||||
local_dir=os.path.join(self.local_model_path, self.model_id),
|
||||
@@ -69,7 +69,7 @@ class ModelConfig:
|
||||
ignore_file_pattern=downloaded_files,
|
||||
local_files_only=False
|
||||
)
|
||||
elif download_resource.lower() == "huggingface":
|
||||
elif download_source.lower() == "huggingface":
|
||||
hf_snapshot_download(
|
||||
self.model_id,
|
||||
local_dir=os.path.join(self.local_model_path, self.model_id),
|
||||
@@ -78,7 +78,7 @@ class ModelConfig:
|
||||
local_files_only=False
|
||||
)
|
||||
else:
|
||||
raise ValueError("`download_resource` should be `modelscope` or `huggingface`.")
|
||||
raise ValueError("`download_source` should be `modelscope` or `huggingface`.")
|
||||
|
||||
def require_downloading(self):
|
||||
if self.path is not None:
|
||||
|
||||
@@ -34,6 +34,6 @@ Attention mechanism implementation method. Can be set to `flash_attention_3`, `f
|
||||
|
||||
Buffer size in disk mapping. Default is 1B (1000000000). Larger values occupy more memory but result in faster speeds.
|
||||
|
||||
## `DIFFSYNTH_DOWNLOAD_RESOURCE`
|
||||
## `DIFFSYNTH_DOWNLOAD_SOURCE`
|
||||
|
||||
Remote model download source. Can be set to `modelscope` or `huggingface` to control the source of model downloads. Default value is `modelscope`.
|
||||
@@ -69,11 +69,11 @@ os.environ["DIFFSYNTH_SKIP_DOWNLOAD"] = "True"
|
||||
import diffsynth
|
||||
```
|
||||
|
||||
To download models from [HuggingFace](https://huggingface.co/), set [environment variable DIFFSYNTH_DOWNLOAD_RESOURCE](/docs/en/Pipeline_Usage/Environment_Variables.md#diffsynth_download_resource) to `huggingface`.
|
||||
To download models from [HuggingFace](https://huggingface.co/), set [environment variable DIFFSYNTH_DOWNLOAD_SOURCE](/docs/en/Pipeline_Usage/Environment_Variables.md#diffsynth_download_source) to `huggingface`.
|
||||
|
||||
```shell
|
||||
import os
|
||||
os.environ["DIFFSYNTH_DOWNLOAD_RESOURCE"] = "huggingface"
|
||||
os.environ["DIFFSYNTH_DOWNLOAD_SOURCE"] = "huggingface"
|
||||
import diffsynth
|
||||
```
|
||||
|
||||
|
||||
@@ -34,6 +34,6 @@ DIFFSYNTH_MODEL_BASE_PATH="./path_to_my_models" python xxx.py
|
||||
|
||||
硬盘直连中的 Buffer 大小,默认是 1B(1000000000),数值越大,占用内存越大,速度越快。
|
||||
|
||||
## `DIFFSYNTH_DOWNLOAD_RESOURCE`
|
||||
## `DIFFSYNTH_DOWNLOAD_SOURCE`
|
||||
|
||||
远程模型下载源,可设置为 `modelscope` 或 `huggingface`,控制模型下载的来源,默认值为 `modelscope`。
|
||||
|
||||
@@ -69,11 +69,11 @@ os.environ["DIFFSYNTH_SKIP_DOWNLOAD"] = "True"
|
||||
import diffsynth
|
||||
```
|
||||
|
||||
如需从 [HuggingFace](https://huggingface.co/) 下载模型,请将[环境变量 DIFFSYNTH_DOWNLOAD_RESOURCE](/docs/zh/Pipeline_Usage/Environment_Variables.md#diffsynth_download_resource) 设置为 `huggingface`。
|
||||
如需从 [HuggingFace](https://huggingface.co/) 下载模型,请将[环境变量 DIFFSYNTH_DOWNLOAD_SOURCE](/docs/zh/Pipeline_Usage/Environment_Variables.md#diffsynth_download_source) 设置为 `huggingface`。
|
||||
|
||||
```shell
|
||||
import os
|
||||
os.environ["DIFFSYNTH_DOWNLOAD_RESOURCE"] = "huggingface"
|
||||
os.environ["DIFFSYNTH_DOWNLOAD_SOURCE"] = "huggingface"
|
||||
import diffsynth
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user