Upload folder using huggingface_hub
Browse files- .gitattributes +2 -0
- README.md +35 -0
- __assets__/banner.gif +3 -0
- controlnet/config.json +52 -0
- controlnet/diffusion_pytorch_model.safetensors +3 -0
- net_id2token.pth +3 -0
- net_image2token.pth +3 -0
- net_seg_res18.pth +3 -0
- pretrained_unet/config.json +68 -0
- pretrained_unet/diffusion_pytorch_model.safetensors +3 -0
- third_party/79999_iter.pth +3 -0
- third_party/BFM_model_front.mat +3 -0
- third_party/d3dfr_res50_nofc.pth +3 -0
- third_party/insightface_glint360k.pth +3 -0
- third_party/models/antelopev2/.gitattributes +35 -0
- third_party/models/antelopev2/1k3d68.onnx +3 -0
- third_party/models/antelopev2/2d106det.onnx +3 -0
- third_party/models/antelopev2/README.md +5 -0
- third_party/models/antelopev2/__pycache__/resnet.cpython-310.pyc +0 -0
- third_party/models/antelopev2/genderage.onnx +3 -0
- third_party/models/antelopev2/glintr100.onnx +3 -0
- third_party/models/antelopev2/inference.py +22 -0
- third_party/models/antelopev2/model.onnx +3 -0
- third_party/models/antelopev2/model.pt +3 -0
- third_party/models/antelopev2/resnet.py +209 -0
- third_party/models/antelopev2/scrfd_10g_bnkps.onnx +3 -0
- third_party/models/antelopev2/test.jpg +0 -0
- third_party/resnet18-5c106cde.pth +3 -0
- vision_encoder/config.json +23 -0
- vision_encoder/pytorch_model.bin +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
__assets__/banner.gif filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
third_party/BFM_model_front.mat filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# FaceAdapter Model Card
|
| 6 |
+
|
| 7 |
+
<div align="center">
|
| 8 |
+
|
| 9 |
+
[**Project Page**](https://faceadapter.github.io/face-adapter.github.io/) **|** [**Paper**](https://arxiv.org/pdf/2405.12970) **|** [**Code**](https://github.com/FaceAdapter/Face-Adapter) **|** [🤗 **Gradio demo**](https://huggingface.co/spaces/FaceAdapter/FaceAdapter)
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
</div>
|
| 13 |
+
|
| 14 |
+
## Introduction
|
| 15 |
+
|
| 16 |
+
Face-Adapter is an efficient and effective face editing adapter for pre-trained diffusion models, specifically targeting face reenactment and swapping tasks.
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
<div align="center">
|
| 20 |
+
<img src='__assets__/banner.gif'>
|
| 21 |
+
</div>
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
## Usage
|
| 25 |
+
|
| 26 |
+
You can directly download the model in this repository or download in python script:
|
| 27 |
+
|
| 28 |
+
```python
|
| 29 |
+
# Download a specific file
|
| 30 |
+
from huggingface_hub import hf_hub_download
|
| 31 |
+
hf_hub_download(repo_id="FaceAdapter/FaceAdapter", filename="controlnet/config.json", local_dir="./checkpoints")
|
| 32 |
+
# Download all files
|
| 33 |
+
from huggingface_hub import snapshot_download
|
| 34 |
+
snapshot_download(repo_id="FaceAdapter/FaceAdapter", local_dir="./checkpoints")
|
| 35 |
+
```
|
__assets__/banner.gif
ADDED
|
Git LFS Details
|
controlnet/config.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "ControlNetModel",
|
| 3 |
+
"_diffusers_version": "0.26.0",
|
| 4 |
+
"_name_or_path": "exps/facedrive_faceswap_facelora128_ftclip/controlnet/",
|
| 5 |
+
"act_fn": "silu",
|
| 6 |
+
"addition_embed_type": null,
|
| 7 |
+
"addition_embed_type_num_heads": 64,
|
| 8 |
+
"addition_time_embed_dim": null,
|
| 9 |
+
"attention_head_dim": 8,
|
| 10 |
+
"block_out_channels": [
|
| 11 |
+
320,
|
| 12 |
+
640,
|
| 13 |
+
1280,
|
| 14 |
+
1280
|
| 15 |
+
],
|
| 16 |
+
"class_embed_type": null,
|
| 17 |
+
"conditioning_channels": 3,
|
| 18 |
+
"conditioning_embedding_out_channels": [
|
| 19 |
+
16,
|
| 20 |
+
32,
|
| 21 |
+
96,
|
| 22 |
+
256
|
| 23 |
+
],
|
| 24 |
+
"controlnet_conditioning_channel_order": "rgb",
|
| 25 |
+
"cross_attention_dim": 768,
|
| 26 |
+
"down_block_types": [
|
| 27 |
+
"CrossAttnDownBlock2D",
|
| 28 |
+
"CrossAttnDownBlock2D",
|
| 29 |
+
"CrossAttnDownBlock2D",
|
| 30 |
+
"DownBlock2D"
|
| 31 |
+
],
|
| 32 |
+
"downsample_padding": 1,
|
| 33 |
+
"encoder_hid_dim": null,
|
| 34 |
+
"encoder_hid_dim_type": null,
|
| 35 |
+
"flip_sin_to_cos": true,
|
| 36 |
+
"freq_shift": 0,
|
| 37 |
+
"global_pool_conditions": false,
|
| 38 |
+
"in_channels": 4,
|
| 39 |
+
"layers_per_block": 2,
|
| 40 |
+
"mid_block_scale_factor": 1,
|
| 41 |
+
"mid_block_type": "UNetMidBlock2DCrossAttn",
|
| 42 |
+
"norm_eps": 1e-05,
|
| 43 |
+
"norm_num_groups": 32,
|
| 44 |
+
"num_attention_heads": null,
|
| 45 |
+
"num_class_embeds": null,
|
| 46 |
+
"only_cross_attention": false,
|
| 47 |
+
"projection_class_embeddings_input_dim": null,
|
| 48 |
+
"resnet_time_scale_shift": "default",
|
| 49 |
+
"transformer_layers_per_block": 1,
|
| 50 |
+
"upcast_attention": false,
|
| 51 |
+
"use_linear_projection": false
|
| 52 |
+
}
|
controlnet/diffusion_pytorch_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:804a9ada677cac97f12eb2651fe226ab4c92ab6d025c893482e4a29a19d0f609
|
| 3 |
+
size 1445157120
|
net_id2token.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5167d894e592b94f518e4465da233397737047ee5cb8424a22bddec54029f9a7
|
| 3 |
+
size 48184531
|
net_image2token.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:07ffcd587de77a34924da6e3532d83ec5e96fc8af8735355fd25e3debb750e96
|
| 3 |
+
size 98717322
|
net_seg_res18.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:041ab78a4f8f756cd7e93df0d2840d03162e46b9c463c144f7fdf3ee3e6c4233
|
| 3 |
+
size 57429148
|
pretrained_unet/config.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "UNet2DConditionModel",
|
| 3 |
+
"_diffusers_version": "0.26.0",
|
| 4 |
+
"_name_or_path": "facelora",
|
| 5 |
+
"act_fn": "silu",
|
| 6 |
+
"addition_embed_type": null,
|
| 7 |
+
"addition_embed_type_num_heads": 64,
|
| 8 |
+
"addition_time_embed_dim": null,
|
| 9 |
+
"attention_head_dim": 8,
|
| 10 |
+
"attention_type": "default",
|
| 11 |
+
"block_out_channels": [
|
| 12 |
+
320,
|
| 13 |
+
640,
|
| 14 |
+
1280,
|
| 15 |
+
1280
|
| 16 |
+
],
|
| 17 |
+
"center_input_sample": false,
|
| 18 |
+
"class_embed_type": null,
|
| 19 |
+
"class_embeddings_concat": false,
|
| 20 |
+
"conv_in_kernel": 3,
|
| 21 |
+
"conv_out_kernel": 3,
|
| 22 |
+
"cross_attention_dim": 768,
|
| 23 |
+
"cross_attention_norm": null,
|
| 24 |
+
"down_block_types": [
|
| 25 |
+
"CrossAttnDownBlock2D",
|
| 26 |
+
"CrossAttnDownBlock2D",
|
| 27 |
+
"CrossAttnDownBlock2D",
|
| 28 |
+
"DownBlock2D"
|
| 29 |
+
],
|
| 30 |
+
"downsample_padding": 1,
|
| 31 |
+
"dropout": 0.0,
|
| 32 |
+
"dual_cross_attention": false,
|
| 33 |
+
"encoder_hid_dim": null,
|
| 34 |
+
"encoder_hid_dim_type": null,
|
| 35 |
+
"flip_sin_to_cos": true,
|
| 36 |
+
"freq_shift": 0,
|
| 37 |
+
"in_channels": 4,
|
| 38 |
+
"layers_per_block": 2,
|
| 39 |
+
"mid_block_only_cross_attention": null,
|
| 40 |
+
"mid_block_scale_factor": 1,
|
| 41 |
+
"mid_block_type": "UNetMidBlock2DCrossAttn",
|
| 42 |
+
"norm_eps": 1e-05,
|
| 43 |
+
"norm_num_groups": 32,
|
| 44 |
+
"num_attention_heads": null,
|
| 45 |
+
"num_class_embeds": null,
|
| 46 |
+
"only_cross_attention": false,
|
| 47 |
+
"out_channels": 4,
|
| 48 |
+
"projection_class_embeddings_input_dim": null,
|
| 49 |
+
"resnet_out_scale_factor": 1.0,
|
| 50 |
+
"resnet_skip_time_act": false,
|
| 51 |
+
"resnet_time_scale_shift": "default",
|
| 52 |
+
"reverse_transformer_layers_per_block": null,
|
| 53 |
+
"sample_size": 64,
|
| 54 |
+
"time_cond_proj_dim": null,
|
| 55 |
+
"time_embedding_act_fn": null,
|
| 56 |
+
"time_embedding_dim": null,
|
| 57 |
+
"time_embedding_type": "positional",
|
| 58 |
+
"timestep_post_act": null,
|
| 59 |
+
"transformer_layers_per_block": 1,
|
| 60 |
+
"up_block_types": [
|
| 61 |
+
"UpBlock2D",
|
| 62 |
+
"CrossAttnUpBlock2D",
|
| 63 |
+
"CrossAttnUpBlock2D",
|
| 64 |
+
"CrossAttnUpBlock2D"
|
| 65 |
+
],
|
| 66 |
+
"upcast_attention": false,
|
| 67 |
+
"use_linear_projection": false
|
| 68 |
+
}
|
pretrained_unet/diffusion_pytorch_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e9d196563bfa563d70eca3357e8df5ab6242178f8990510699e5b81f87700ed7
|
| 3 |
+
size 1719125992
|
third_party/79999_iter.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:468e13ca13a9b43cc0881a9f99083a430e9c0a38abd935431d1c28ee94b26567
|
| 3 |
+
size 53289463
|
third_party/BFM_model_front.mat
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a9f127eb18c3d022acbdbfcf1b6b353d01a6e01785d675a67cc31a3826a5be0f
|
| 3 |
+
size 127170280
|
third_party/d3dfr_res50_nofc.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:52c54b90304a06c16b6813910c26faff1a907d4f8bd69a71ad4ecff43b41a090
|
| 3 |
+
size 96449126
|
third_party/insightface_glint360k.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5f631718e783448b41631e15073bdc622eaeef56509bbad4e5085f23bd32db83
|
| 3 |
+
size 261223796
|
third_party/models/antelopev2/.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
third_party/models/antelopev2/1k3d68.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:df5c06b8a0c12e422b2ed8947b8869faa4105387f199c477af038aa01f9a45cc
|
| 3 |
+
size 143607619
|
third_party/models/antelopev2/2d106det.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f001b856447c413801ef5c42091ed0cd516fcd21f2d6b79635b1e733a7109dbf
|
| 3 |
+
size 5030888
|
third_party/models/antelopev2/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Inference
|
| 2 |
+
|
| 3 |
+
```bash
|
| 4 |
+
python inference.py
|
| 5 |
+
```
|
third_party/models/antelopev2/__pycache__/resnet.cpython-310.pyc
ADDED
|
Binary file (5.89 kB). View file
|
|
|
third_party/models/antelopev2/genderage.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4fde69b1c810857b88c64a335084f1c3fe8f01246c9a191b48c7bb756d6652fb
|
| 3 |
+
size 1322532
|
third_party/models/antelopev2/glintr100.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b2fe1b5874b96c1025efdc8a9cf4152511384dcb1282c79290d5ed3241692297
|
| 3 |
+
size 260694151
|
third_party/models/antelopev2/inference.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from resnet import get_model
|
| 2 |
+
import torch
|
| 3 |
+
from PIL import Image
|
| 4 |
+
from torchvision.transforms.functional import pil_to_tensor
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
model = get_model("r100", dropout=0.0, fp16=True, num_features=512).cuda()
|
| 8 |
+
model.load_state_dict(torch.load("model.pt"))
|
| 9 |
+
model.eval()
|
| 10 |
+
img = pil_to_tensor(Image.open("test.jpg").resize((112,112))).permute(0, 1, 2).to("cuda", torch.float16).unsqueeze(dim = 0)
|
| 11 |
+
embeddings = model(img)
|
| 12 |
+
|
| 13 |
+
from insightface.app import FaceAnalysis
|
| 14 |
+
import insightface
|
| 15 |
+
from huggingface_hub import snapshot_download
|
| 16 |
+
snapshot_download('Warlord-K/resnet100', local_dir='models/antelopev2')
|
| 17 |
+
app = FaceAnalysis(
|
| 18 |
+
name='antelopev2', root='.', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']
|
| 19 |
+
)
|
| 20 |
+
app.prepare(ctx_id=0, det_size=(640, 640))
|
| 21 |
+
handler_ante = insightface.model_zoo.get_model('models/antelopev2/glintr100.onnx')
|
| 22 |
+
handler_ante.prepare(ctx_id=0)
|
third_party/models/antelopev2/model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b2fe1b5874b96c1025efdc8a9cf4152511384dcb1282c79290d5ed3241692297
|
| 3 |
+
size 260694151
|
third_party/models/antelopev2/model.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2c1d9f2ca1d152743e8c9588aa2b888434b66848ad68f941c0c2cf4f884755f4
|
| 3 |
+
size 261152502
|
third_party/models/antelopev2/resnet.py
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from torch import nn
|
| 3 |
+
from torch.utils.checkpoint import checkpoint
|
| 4 |
+
|
| 5 |
+
__all__ = ['iresnet18', 'iresnet34', 'iresnet50', 'iresnet100', 'iresnet200']
|
| 6 |
+
using_ckpt = False
|
| 7 |
+
|
| 8 |
+
def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
|
| 9 |
+
"""3x3 convolution with padding"""
|
| 10 |
+
return nn.Conv2d(in_planes,
|
| 11 |
+
out_planes,
|
| 12 |
+
kernel_size=3,
|
| 13 |
+
stride=stride,
|
| 14 |
+
padding=dilation,
|
| 15 |
+
groups=groups,
|
| 16 |
+
bias=False,
|
| 17 |
+
dilation=dilation)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def conv1x1(in_planes, out_planes, stride=1):
|
| 21 |
+
"""1x1 convolution"""
|
| 22 |
+
return nn.Conv2d(in_planes,
|
| 23 |
+
out_planes,
|
| 24 |
+
kernel_size=1,
|
| 25 |
+
stride=stride,
|
| 26 |
+
bias=False)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class IBasicBlock(nn.Module):
|
| 30 |
+
expansion = 1
|
| 31 |
+
def __init__(self, inplanes, planes, stride=1, downsample=None,
|
| 32 |
+
groups=1, base_width=64, dilation=1):
|
| 33 |
+
super(IBasicBlock, self).__init__()
|
| 34 |
+
if groups != 1 or base_width != 64:
|
| 35 |
+
raise ValueError('BasicBlock only supports groups=1 and base_width=64')
|
| 36 |
+
if dilation > 1:
|
| 37 |
+
raise NotImplementedError("Dilation > 1 not supported in BasicBlock")
|
| 38 |
+
self.bn1 = nn.BatchNorm2d(inplanes, eps=1e-05,)
|
| 39 |
+
self.conv1 = conv3x3(inplanes, planes)
|
| 40 |
+
self.bn2 = nn.BatchNorm2d(planes, eps=1e-05,)
|
| 41 |
+
self.prelu = nn.PReLU(planes)
|
| 42 |
+
self.conv2 = conv3x3(planes, planes, stride)
|
| 43 |
+
self.bn3 = nn.BatchNorm2d(planes, eps=1e-05,)
|
| 44 |
+
self.downsample = downsample
|
| 45 |
+
self.stride = stride
|
| 46 |
+
|
| 47 |
+
def forward_impl(self, x):
|
| 48 |
+
identity = x
|
| 49 |
+
out = self.bn1(x)
|
| 50 |
+
out = self.conv1(out)
|
| 51 |
+
out = self.bn2(out)
|
| 52 |
+
out = self.prelu(out)
|
| 53 |
+
out = self.conv2(out)
|
| 54 |
+
out = self.bn3(out)
|
| 55 |
+
if self.downsample is not None:
|
| 56 |
+
identity = self.downsample(x)
|
| 57 |
+
out += identity
|
| 58 |
+
return out
|
| 59 |
+
|
| 60 |
+
def forward(self, x):
|
| 61 |
+
if self.training and using_ckpt:
|
| 62 |
+
return checkpoint(self.forward_impl, x)
|
| 63 |
+
else:
|
| 64 |
+
return self.forward_impl(x)
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
class IResNet(nn.Module):
|
| 68 |
+
fc_scale = 7 * 7
|
| 69 |
+
def __init__(self,
|
| 70 |
+
block, layers, dropout=0, num_features=512, zero_init_residual=False,
|
| 71 |
+
groups=1, width_per_group=64, replace_stride_with_dilation=None, fp16=False):
|
| 72 |
+
super(IResNet, self).__init__()
|
| 73 |
+
self.extra_gflops = 0.0
|
| 74 |
+
self.fp16 = fp16
|
| 75 |
+
self.inplanes = 64
|
| 76 |
+
self.dilation = 1
|
| 77 |
+
if replace_stride_with_dilation is None:
|
| 78 |
+
replace_stride_with_dilation = [False, False, False]
|
| 79 |
+
if len(replace_stride_with_dilation) != 3:
|
| 80 |
+
raise ValueError("replace_stride_with_dilation should be None "
|
| 81 |
+
"or a 3-element tuple, got {}".format(replace_stride_with_dilation))
|
| 82 |
+
self.groups = groups
|
| 83 |
+
self.base_width = width_per_group
|
| 84 |
+
self.conv1 = nn.Conv2d(3, self.inplanes, kernel_size=3, stride=1, padding=1, bias=False)
|
| 85 |
+
self.bn1 = nn.BatchNorm2d(self.inplanes, eps=1e-05)
|
| 86 |
+
self.prelu = nn.PReLU(self.inplanes)
|
| 87 |
+
self.layer1 = self._make_layer(block, 64, layers[0], stride=2)
|
| 88 |
+
self.layer2 = self._make_layer(block,
|
| 89 |
+
128,
|
| 90 |
+
layers[1],
|
| 91 |
+
stride=2,
|
| 92 |
+
dilate=replace_stride_with_dilation[0])
|
| 93 |
+
self.layer3 = self._make_layer(block,
|
| 94 |
+
256,
|
| 95 |
+
layers[2],
|
| 96 |
+
stride=2,
|
| 97 |
+
dilate=replace_stride_with_dilation[1])
|
| 98 |
+
self.layer4 = self._make_layer(block,
|
| 99 |
+
512,
|
| 100 |
+
layers[3],
|
| 101 |
+
stride=2,
|
| 102 |
+
dilate=replace_stride_with_dilation[2])
|
| 103 |
+
self.bn2 = nn.BatchNorm2d(512 * block.expansion, eps=1e-05,)
|
| 104 |
+
self.dropout = nn.Dropout(p=dropout, inplace=True)
|
| 105 |
+
self.fc = nn.Linear(512 * block.expansion * self.fc_scale, num_features)
|
| 106 |
+
self.features = nn.BatchNorm1d(num_features, eps=1e-05)
|
| 107 |
+
nn.init.constant_(self.features.weight, 1.0)
|
| 108 |
+
self.features.weight.requires_grad = False
|
| 109 |
+
|
| 110 |
+
for m in self.modules():
|
| 111 |
+
if isinstance(m, nn.Conv2d):
|
| 112 |
+
nn.init.normal_(m.weight, 0, 0.1)
|
| 113 |
+
elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):
|
| 114 |
+
nn.init.constant_(m.weight, 1)
|
| 115 |
+
nn.init.constant_(m.bias, 0)
|
| 116 |
+
|
| 117 |
+
if zero_init_residual:
|
| 118 |
+
for m in self.modules():
|
| 119 |
+
if isinstance(m, IBasicBlock):
|
| 120 |
+
nn.init.constant_(m.bn2.weight, 0)
|
| 121 |
+
|
| 122 |
+
def _make_layer(self, block, planes, blocks, stride=1, dilate=False):
|
| 123 |
+
downsample = None
|
| 124 |
+
previous_dilation = self.dilation
|
| 125 |
+
if dilate:
|
| 126 |
+
self.dilation *= stride
|
| 127 |
+
stride = 1
|
| 128 |
+
if stride != 1 or self.inplanes != planes * block.expansion:
|
| 129 |
+
downsample = nn.Sequential(
|
| 130 |
+
conv1x1(self.inplanes, planes * block.expansion, stride),
|
| 131 |
+
nn.BatchNorm2d(planes * block.expansion, eps=1e-05, ),
|
| 132 |
+
)
|
| 133 |
+
layers = []
|
| 134 |
+
layers.append(
|
| 135 |
+
block(self.inplanes, planes, stride, downsample, self.groups,
|
| 136 |
+
self.base_width, previous_dilation))
|
| 137 |
+
self.inplanes = planes * block.expansion
|
| 138 |
+
for _ in range(1, blocks):
|
| 139 |
+
layers.append(
|
| 140 |
+
block(self.inplanes,
|
| 141 |
+
planes,
|
| 142 |
+
groups=self.groups,
|
| 143 |
+
base_width=self.base_width,
|
| 144 |
+
dilation=self.dilation))
|
| 145 |
+
|
| 146 |
+
return nn.Sequential(*layers)
|
| 147 |
+
|
| 148 |
+
def forward(self, x):
|
| 149 |
+
with torch.cuda.amp.autocast(self.fp16):
|
| 150 |
+
x = self.conv1(x)
|
| 151 |
+
x = self.bn1(x)
|
| 152 |
+
x = self.prelu(x)
|
| 153 |
+
x = self.layer1(x)
|
| 154 |
+
x = self.layer2(x)
|
| 155 |
+
x = self.layer3(x)
|
| 156 |
+
x = self.layer4(x)
|
| 157 |
+
x = self.bn2(x)
|
| 158 |
+
x = torch.flatten(x, 1)
|
| 159 |
+
x = self.dropout(x)
|
| 160 |
+
x = self.fc(x.float() if self.fp16 else x)
|
| 161 |
+
x = self.features(x)
|
| 162 |
+
return x
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
def _iresnet(arch, block, layers, pretrained, progress, **kwargs):
|
| 166 |
+
model = IResNet(block, layers, **kwargs)
|
| 167 |
+
if pretrained:
|
| 168 |
+
raise ValueError()
|
| 169 |
+
return model
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
def iresnet18(pretrained=False, progress=True, **kwargs):
|
| 173 |
+
return _iresnet('iresnet18', IBasicBlock, [2, 2, 2, 2], pretrained,
|
| 174 |
+
progress, **kwargs)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
def iresnet34(pretrained=False, progress=True, **kwargs):
|
| 178 |
+
return _iresnet('iresnet34', IBasicBlock, [3, 4, 6, 3], pretrained,
|
| 179 |
+
progress, **kwargs)
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
def iresnet50(pretrained=False, progress=True, **kwargs):
|
| 183 |
+
return _iresnet('iresnet50', IBasicBlock, [3, 4, 14, 3], pretrained,
|
| 184 |
+
progress, **kwargs)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def iresnet100(pretrained=False, progress=True, **kwargs):
|
| 188 |
+
return _iresnet('iresnet100', IBasicBlock, [3, 13, 30, 3], pretrained,
|
| 189 |
+
progress, **kwargs)
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
def iresnet200(pretrained=False, progress=True, **kwargs):
|
| 193 |
+
return _iresnet('iresnet200', IBasicBlock, [6, 26, 60, 6], pretrained,
|
| 194 |
+
progress, **kwargs)
|
| 195 |
+
|
| 196 |
+
def get_model(name, **kwargs):
|
| 197 |
+
# resnet
|
| 198 |
+
if name == "r18":
|
| 199 |
+
return iresnet18(False, **kwargs)
|
| 200 |
+
elif name == "r34":
|
| 201 |
+
return iresnet34(False, **kwargs)
|
| 202 |
+
elif name == "r50":
|
| 203 |
+
return iresnet50(False, **kwargs)
|
| 204 |
+
elif name == "r100":
|
| 205 |
+
return iresnet100(False, **kwargs)
|
| 206 |
+
elif name == "r200":
|
| 207 |
+
return iresnet200(False, **kwargs)
|
| 208 |
+
else:
|
| 209 |
+
raise ValueError
|
third_party/models/antelopev2/scrfd_10g_bnkps.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5838f7fe053675b1c7a08b633df49e7af5495cee0493c7dcf6697200b85b5b91
|
| 3 |
+
size 16923827
|
third_party/models/antelopev2/test.jpg
ADDED
|
third_party/resnet18-5c106cde.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5c106cde386e87d4033832f2996f5493238eda96ccf559d1d62760c4de0613f8
|
| 3 |
+
size 46827520
|
vision_encoder/config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "exps/facedrive_faceswap_facelora128_ftclip/vision_encoder/",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"CLIPVisionModel"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"dropout": 0.0,
|
| 8 |
+
"hidden_act": "gelu",
|
| 9 |
+
"hidden_size": 1280,
|
| 10 |
+
"image_size": 224,
|
| 11 |
+
"initializer_factor": 1.0,
|
| 12 |
+
"initializer_range": 0.02,
|
| 13 |
+
"intermediate_size": 5120,
|
| 14 |
+
"layer_norm_eps": 1e-05,
|
| 15 |
+
"model_type": "clip_vision_model",
|
| 16 |
+
"num_attention_heads": 16,
|
| 17 |
+
"num_channels": 3,
|
| 18 |
+
"num_hidden_layers": 32,
|
| 19 |
+
"patch_size": 14,
|
| 20 |
+
"projection_dim": 1024,
|
| 21 |
+
"torch_dtype": "float32",
|
| 22 |
+
"transformers_version": "4.30.2"
|
| 23 |
+
}
|
vision_encoder/pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6b7445201beeb55edb415ed542c3ddfebd020e5ad0cce31930239a92313b7771
|
| 3 |
+
size 2523246442
|