Skip to content

Commit

Permalink
rename_diffusers_extension_to_onediffx (#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
clackhan authored Jan 30, 2024
1 parent db3b18e commit e7470bb
Showing 31 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -169,7 +169,7 @@ tags

op_prof.csv
*.lock
*out.png
*.png
log
unet_graphs
*.json
2 changes: 1 addition & 1 deletion README_ENTERPRISE.md
Original file line number Diff line number Diff line change
@@ -122,7 +122,7 @@ Type `python3 text_to_image_sdxl_enterprise.py -h` for more options.

#### SDXL + DeepCache

Ensure that you have installed [OneDiff Diffusers Extensions](onediff_diffusers_extensions/README.md#install-and-setup) and then run [text_to_image_deep_cache_sdxl_enterprise.py](examples/text_to_image_deep_cache_sdxl_enterprise.py) by command:
Ensure that you have installed [OneDiffX](onediff_diffusers_extensions/README.md#install-and-setup) and then run [text_to_image_deep_cache_sdxl_enterprise.py](examples/text_to_image_deep_cache_sdxl_enterprise.py) by command:

```bash
python text_to_image_deep_cache_sdxl_enterprise.py --model $model_path --saved_image output_deepcache.png
4 changes: 2 additions & 2 deletions benchmarks/image_to_video.py
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
import torch

from diffusers.utils import load_image, export_to_video
from diffusers_extensions import compile_pipe, compiler_config
from onediffx import compile_pipe, compiler_config


def parse_args():
@@ -160,7 +160,7 @@ def callback_on_step_end(self, pipe, i, t, callback_kwargs={}):
def main():
args = parse_args()
if args.deepcache:
from diffusers_extensions.deep_cache import StableVideoDiffusionPipeline
from onediffx.deep_cache import StableVideoDiffusionPipeline
else:
from diffusers import StableVideoDiffusionPipeline

2 changes: 1 addition & 1 deletion benchmarks/run_image_to_video_benchmark.sh
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ else
[ -d ${MODEL_DIR}/stable-video-diffusion-img2vid-xt ] && SVD_XT_MODEL_PATH=${MODEL_DIR}/stable-video-diffusion-img2vid-xt

python3 -c "import onediff_quant" && echo "enable quant model" && BENCHMARK_QUANT_MODEL=1 || echo "disable quant model"
# python3 -c "import diffusers_extensions" && echo "enable deepcache model" && BENCHMARK_DEEP_CACHE_MODEL=1 || echo "disable deepcache model"
# python3 -c "import onediffx" && echo "enable deepcache model" && BENCHMARK_DEEP_CACHE_MODEL=1 || echo "disable deepcache model"

SVD_XT_QUANT_MODEL_PATH=${MODEL_DIR}/stable-video-diffusion-img2vid-xt-int8
SVD_XT_DEEP_CACHE_QUANT_MODEL_PATH=${MODEL_DIR}/stable-video-diffusion-img2vid-xt-deepcache-int8
2 changes: 1 addition & 1 deletion benchmarks/run_text_to_image_benchmark.sh
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ else
[ -d ${MODEL_DIR}/stable-diffusion-xl-base-1.0 ] && SDXL_MODEL_PATH=${MODEL_DIR}/stable-diffusion-xl-base-1.0

python3 -c "import onediff_quant" && echo "enable quant model" && BENCHMARK_QUANT_MODEL=1 || echo "disable quant model"
# python3 -c "import diffusers_extensions" && echo "enable deepcache model" && BENCHMARK_DEEP_CACHE_MODEL=1 || echo "disable deepcache model"
# python3 -c "import onediffx" && echo "enable deepcache model" && BENCHMARK_DEEP_CACHE_MODEL=1 || echo "disable deepcache model"

SDXL_QUANT_MODEL_PATH=${MODEL_DIR}/stable-diffusion-xl-base-1.0-int8
SDXL_DEEP_CACHE_QUANT_MODEL_PATH=${MODEL_DIR}/stable-diffusion-xl-base-1.0-deepcache-int8
4 changes: 2 additions & 2 deletions benchmarks/text_to_image.py
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
import torch
from PIL import Image, ImageDraw
import oneflow as flow
from diffusers_extensions import compile_pipe
from onediffx import compile_pipe


def parse_args():
@@ -144,7 +144,7 @@ def main():
args = parse_args()
if args.input_image is None:
if args.deepcache:
from diffusers_extensions.deep_cache import (
from onediffx.deep_cache import (
StableDiffusionXLPipeline as pipeline_cls,
)
else:
2 changes: 1 addition & 1 deletion examples/text_to_image_deep_cache_sd.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
from onediff.infer_compiler import oneflow_compile
from onediff.schedulers import EulerDiscreteScheduler

from diffusers_extensions.deep_cache import StableDiffusionPipeline
from onediffx.deep_cache import StableDiffusionPipeline

parser = argparse.ArgumentParser()
parser.add_argument(
2 changes: 1 addition & 1 deletion examples/text_to_image_deep_cache_sdxl.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
from onediff.infer_compiler import oneflow_compile
from onediff.schedulers import EulerDiscreteScheduler

from diffusers_extensions.deep_cache import StableDiffusionXLPipeline
from onediffx.deep_cache import StableDiffusionXLPipeline

parser = argparse.ArgumentParser()
parser.add_argument(
2 changes: 1 addition & 1 deletion examples/text_to_image_deep_cache_sdxl_enterprise.py
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ def parse_args():
os.path.join(args.model, "calibrate_info.txt")
), f"calibrate_info.txt is required in args.model ({args.model})"

from diffusers_extensions.deep_cache import StableDiffusionXLPipeline
from onediffx.deep_cache import StableDiffusionXLPipeline
import onediff_quant
from onediff_quant.utils import replace_sub_module_with_quantizable_module

4 changes: 2 additions & 2 deletions examples/text_to_image_sdxl_lora.py
Original file line number Diff line number Diff line change
@@ -5,9 +5,9 @@
from onediff.infer_compiler.utils import TensorInplaceAssign

try:
from diffusers_extensions.utils.lora import load_and_fuse_lora, unfuse_lora
from onediffx.utils.lora import load_and_fuse_lora, unfuse_lora
except ImportError:
raise RuntimeError("OneDiff diffusers_extensions is not installed. Please check onediff_diffusers_extensions/README.md to install diffusers_extensions.")
raise RuntimeError("OneDiff onediffx is not installed. Please check onediff_diffusers_extensions/README.md to install onediffx.")

MODEL_ID = "stabilityai/stable-diffusion-xl-base-1.0"
pipe = DiffusionPipeline.from_pretrained(
32 changes: 16 additions & 16 deletions onediff_diffusers_extensions/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# OneDiff Diffusers Extensions
# OneDiffX

OneDiff diffusers extensions include multiple popular accelerated versions of the AIGC algorithm, such as DeepCache, which you would have a hard time finding elsewhere.
OneDiffX include multiple popular accelerated versions of the AIGC algorithm, such as DeepCache, which you would have a hard time finding elsewhere.

- [Install and Setup](#install-and-setup)
- [DeepCache Speedup](#deepcache-speedup)
- [Stable Diffusion XL](#run-stable-diffusion-xl-with-onediff-diffusers-extensions)
- [Stable Diffuison 1.5](#run-stable-diffusion-15-with-onediff-diffusers-extensions)
- [Stable Diffusion XL](#run-stable-diffusion-xl-with-onediffx)
- [Stable Diffuison 1.5](#run-stable-diffusion-15-with-onediffx)
- [Contact](#contact)

## Install and setup

1. Follow the steps [here](https://github.com/siliconflow/onediff?tab=readme-ov-file#install-from-source) to install onediff.

2. Install diffusers_extensions by following these steps
2. Install onediffx by following these steps

```
git clone https://github.com/siliconflow/onediff.git
@@ -21,13 +21,13 @@ OneDiff diffusers extensions include multiple popular accelerated versions of th
## DeepCache speedup
### Run Stable Diffusion XL with OneDiff diffusers extensions
### Run Stable Diffusion XL with OneDiffX
```python
import torch
from diffusers_extensions import compile_pipe
from diffusers_extensions.deep_cache import StableDiffusionXLPipeline
from onediffx import compile_pipe
from onediffx.deep_cache import StableDiffusionXLPipeline
pipe = StableDiffusionXLPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
@@ -60,8 +60,8 @@ deepcache_output = pipe(
```python
import torch

from diffusers_extensions import compile_pipe
from diffusers_extensions.deep_cache import StableDiffusionPipeline
from onediffx import compile_pipe
from onediffx.deep_cache import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
@@ -89,14 +89,14 @@ deepcache_output = pipe(
).images[0]
```

### Run Stable Video Diffusion with OneDiff diffusers extensions
### Run Stable Video Diffusion with OneDiffX

```python
import torch

from diffusers.utils import load_image, export_to_video
from diffusers_extensions import compile_pipe, compiler_config
from diffusers_extensions.deep_cache import StableVideoDiffusionPipeline
from onediffx import compile_pipe, compiler_config
from onediffx.deep_cache import StableVideoDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained(
"stabilityai/stable-video-diffusion-img2vid-xt",
@@ -139,13 +139,13 @@ If you possess a OneDiff Enterprise license key, you can access instructions on

## LoRA loading and switching speed up

OneDiff provides a faster implementation of loading LoRA, by invoking `diffusers_extensions.utils.lora.load_and_fuse_lora` you can load and fuse LoRA to pipeline.
OneDiff provides a faster implementation of loading LoRA, by invoking `onediffx.utils.lora.load_and_fuse_lora` you can load and fuse LoRA to pipeline.

```python
import torch
from diffusers import DiffusionPipeline
from diffusers_extensions import compile_pipe
from diffusers_extensions.utils.lora import load_and_fuse_lora, unfuse_lora
from onediffx import compile_pipe
from onediffx.utils.lora import load_and_fuse_lora, unfuse_lora

MODEL_ID = "stabilityai/stable-diffusion-xl-base-1.0"
pipe = DiffusionPipeline.from_pretrained(
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ def compile_pipe(
if 'image_processor' not in ignores:
print("Patching image_processor")

from diffusers_extensions.utils.patch_image_processor import patch_image_prcessor as patch_image_prcessor_
from onediffx.utils.patch_image_processor import patch_image_prcessor as patch_image_prcessor_
patch_image_prcessor_(pipe.image_processor)

return pipe
Original file line number Diff line number Diff line change
@@ -102,11 +102,11 @@ def get_class_obj_and_candidates(library_name, class_name, importable_classes, p
else:
# else we just import it from the library.
if class_name == 'UNet2DConditionModel':
library_name = "diffusers_extensions.deep_cache.models.unet_2d_condition"
library_name = "onediffx.deep_cache.models.unet_2d_condition"

if class_name == 'UNetSpatioTemporalConditionModel':
assert diffusers_version >= version.parse("0.24.0"), "SVD not support in diffusers-" + diffusers_version
library_name = "diffusers_extensions.deep_cache.models.unet_spatio_temporal_condition"
library_name = "onediffx.deep_cache.models.unet_spatio_temporal_condition"

library = importlib.import_module(library_name)
class_obj = getattr(library, class_name)
2 changes: 1 addition & 1 deletion onediff_diffusers_extensions/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import find_packages, setup

setup(
name="diffusers_extensions",
name="onediffx",
version="0.1.0",
description="onediff extensions for diffusers",
url="https://github.com/siliconflow/onediff",

0 comments on commit e7470bb

Please sign in to comment.