Skip to content

Commit

Permalink
添加example的测试, 添加json文件
Browse files Browse the repository at this point in the history
  • Loading branch information
JunnYu committed Aug 9, 2023
1 parent 514515b commit df6c961
Show file tree
Hide file tree
Showing 11 changed files with 680 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ __pycache__/
*.so

# json file
*.json
# *.json

# log file
*.log
Expand Down
36 changes: 36 additions & 0 deletions ppdiffusers/examples/autoencoder/vae/config/vae.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"act_fn": "silu",
"block_out_channels": [
128,
256,
512,
512
],
"down_block_out_channels": null,
"down_block_types": [
"DownEncoderBlock2D",
"DownEncoderBlock2D",
"DownEncoderBlock2D",
"DownEncoderBlock2D"
],
"in_channels": 3,
"layers_per_block": 2,
"norm_num_groups": 32,
"out_channels": 3,
"sample_size": 512,
"up_block_out_channels": [
128,
256,
256,
256,
512
],
"latent_channels": 4,
"up_block_types": [
"UpDecoderBlock2D",
"UpDecoderBlock2D",
"UpDecoderBlock2D",
"UpDecoderBlock2D",
"UpDecoderBlock2D"
]
}
16 changes: 16 additions & 0 deletions ppdiffusers/examples/t2i-adapter/config/openpose_adapter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"_class_name": "Adapter",
"_ppdiffusers_version": "0.2.2",
"channels_in": 3,
"block_out_channels": [
320,
640,
1280,
1280
],
"num_res_blocks": 2,
"kernel_size": 1,
"res_block_skip": true,
"use_conv": false,
"input_scale_factor": 8
}
15 changes: 15 additions & 0 deletions ppdiffusers/examples/text_to_image_laion400m/config/ldmbert.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"vocab_size": 30522,
"max_position_embeddings": 77,
"encoder_layers": 32,
"encoder_ffn_dim": 5120,
"encoder_attention_heads": 8,
"head_dim": 64,
"activation_function": "gelu",
"d_model": 1280,
"dropout": 0.0,
"attention_dropout": 0.0,
"activation_dropout": 0.0,
"init_std": 0.02,
"pad_token_id": 0
}
35 changes: 35 additions & 0 deletions ppdiffusers/examples/text_to_image_laion400m/config/unet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"act_fn": "silu",
"attention_head_dim": 8,
"block_out_channels": [
320,
640,
1280,
1280
],
"center_input_sample": false,
"cross_attention_dim": 1280,
"down_block_types": [
"CrossAttnDownBlock2D",
"CrossAttnDownBlock2D",
"CrossAttnDownBlock2D",
"DownBlock2D"
],
"downsample_padding": 1,
"flip_sin_to_cos": true,
"freq_shift": 0,
"in_channels": 4,
"layers_per_block": 2,
"mid_block_scale_factor": 1,
"norm_eps": 1e-05,
"norm_num_groups": 32,
"out_channels": 4,
"sample_size": 32,
"up_block_types": [
"UpBlock2D",
"CrossAttnUpBlock2D",
"CrossAttnUpBlock2D",
"CrossAttnUpBlock2D"
]
}

4 changes: 4 additions & 0 deletions ppdiffusers/ppdiffusers/utils/dynamic_modules_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ def check_imports(filename):
try:
importlib.import_module(imp)
except ImportError:
if imp == "ligo":
imp = "ligo-segments"
if imp == "cv2":
imp = "opencv-python"
missing_packages.append(imp)

if len(missing_packages) > 0:
Expand Down
3 changes: 3 additions & 0 deletions ppdiffusers/tests/examples_test/download_sd15.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ppdiffusers import DiffusionPipeline
# CompVis/stable-diffusion-v1-4
p = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
1 change: 1 addition & 0 deletions ppdiffusers/tests/examples_test/fire.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nohup sh train.sh 1> train.log 2>&1 &
39 changes: 39 additions & 0 deletions ppdiffusers/tests/examples_test/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
pip install -r requirements.txt
pip uninstall ppdiffusers -y
cd ../../
pip install -e .
cd -

python download_sd15.py

cd ../../examples/dreambooth
wget https://paddlenlp.bj.bcebos.com/models/community/junnyu/develop/dogs.tar.gz
tar -zxvf dogs.tar.gz
cd -

cd ../../examples/textual_inversion
wget https://paddlenlp.bj.bcebos.com/models/community/junnyu/develop/cat-toy.tar.gz
tar -zxvf cat-toy.tar.gz
cd -

cd ../../examples/text_to_image_laion400m
wget https://paddlenlp.bj.bcebos.com/models/community/junnyu/develop/laion400m_demo_data.tar.gz
rm -rf data
tar -zxvf laion400m_demo_data.tar.gz
cp laion400m_demo_data.tar.gz ../stable_diffusion
cp laion400m_demo_data.tar.gz ../autoencoder/vae
cd -

cd ../../examples/autoencoder/vae
rm -rf data
tar -zxvf laion400m_demo_data.tar.gz
cd -

cd ../../examples/controlnet
wget https://paddlenlp.bj.bcebos.com/models/community/junnyu/develop/fill50k.zip
unzip -o fill50k.zip

cd -
cd ../../examples/t2i-adapter
wget https://paddlenlp.bj.bcebos.com/models/community/westfish/t2i-adapter/openpose_data_demo.tar.gz
tar -zxvf openpose_data_demo.tar.gz
17 changes: 17 additions & 0 deletions ppdiffusers/tests/examples_test/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
paddlenlp>=2.6.0rc0
ppdiffusers>=0.16.1
scipy
safetensors
pyyaml
opencv-python
albumentations
fastcore
visualdl
requests
Pillow
cchardet
datasets
visualdl
einops
ligo-segments
opencv-python-headless<=4.3
Loading

0 comments on commit df6c961

Please sign in to comment.