Upload folder using huggingface_hub
Browse files- .gitignore +2 -0
- README.md +15 -2
- download_checkpoints.py +3 -4
- util_and_constant.py +2 -2
.gitignore
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
examples
|
| 2 |
data
|
|
|
|
| 3 |
.cursorignore
|
| 4 |
.specstory
|
| 5 |
|
|
@@ -69,6 +70,7 @@ ttt*
|
|
| 69 |
|
| 70 |
*.pt
|
| 71 |
*.pth
|
|
|
|
| 72 |
|
| 73 |
|
| 74 |
*.pkl
|
|
|
|
| 1 |
examples
|
| 2 |
data
|
| 3 |
+
checkpoints
|
| 4 |
.cursorignore
|
| 5 |
.specstory
|
| 6 |
|
|
|
|
| 70 |
|
| 71 |
*.pt
|
| 72 |
*.pth
|
| 73 |
+
*.ckpt
|
| 74 |
|
| 75 |
|
| 76 |
*.pkl
|
README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
# UniBioTransfer
|
| 2 |
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
| 7 |
## Abstract
|
| 8 |
>Deepface generation has traditionally followed a task-driven paradigm, where distinct tasks (e.g., face transfer and hair transfer) are addressed by task-specific models. Nevertheless, this single-task setting severely limits model generalization and scalability. A unified model capable of solving multiple deepface generation tasks in a single pass represents a promising and practical direction, yet remains challenging due to data scarcity and cross-task conflicts arising from heterogeneous attribute transformations. To this end, we propose UniBioTransfer, the first unified framework capable of handling both conventional deepface tasks (e.g., face transfer and face reenactment) and shape-varying transformations (e.g., hair transfer and head transfer). Besides, UniBioTransfer naturally generalizes to unseen tasks, like lip, eye, and glasses transfer, with minimal fine-tuning. Generally, UniBioTransfer addresses data insufficiency in multi-task generation through a unified data construction strategy, including a swapping-based corruption mechanism designed for spatially dynamic attributes like hair. It further mitigates cross-task interference via an innovative BioMoE, a mixture-of-experts based model coupled with a novel two-stage training strategy that effectively disentangles task-specific knowledge. Extensive experiments demonstrate the effectiveness, generalization, and scalability of UniBioTransfer, outperforming both existing unified models and task-specific methods across a wide range of deepface generation tasks.
|
|
@@ -19,6 +19,8 @@
|
|
| 19 |
|
| 20 |
|
| 21 |
## Setup
|
|
|
|
|
|
|
| 22 |
```
|
| 23 |
conda create -n "unibio" python=3.10.16 -y
|
| 24 |
conda activate unibio
|
|
@@ -26,11 +28,22 @@ sh setup.sh
|
|
| 26 |
```
|
| 27 |
|
| 28 |
|
|
|
|
| 29 |
Download pre-trained checkpoints via `python download_checkpoints.py`
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
## Citing Us
|
| 36 |
If you find our work valuable, we kindly ask you to consider citing our paper.
|
|
|
|
| 1 |
# UniBioTransfer
|
| 2 |
|
| 3 |
|
| 4 |
+
[](https://arxiv.org/abs/2603.19637)
|
| 5 |
+
[](https://scy639.github.io/UniBioTransfer.github.io/)
|
| 6 |
|
| 7 |
## Abstract
|
| 8 |
>Deepface generation has traditionally followed a task-driven paradigm, where distinct tasks (e.g., face transfer and hair transfer) are addressed by task-specific models. Nevertheless, this single-task setting severely limits model generalization and scalability. A unified model capable of solving multiple deepface generation tasks in a single pass represents a promising and practical direction, yet remains challenging due to data scarcity and cross-task conflicts arising from heterogeneous attribute transformations. To this end, we propose UniBioTransfer, the first unified framework capable of handling both conventional deepface tasks (e.g., face transfer and face reenactment) and shape-varying transformations (e.g., hair transfer and head transfer). Besides, UniBioTransfer naturally generalizes to unseen tasks, like lip, eye, and glasses transfer, with minimal fine-tuning. Generally, UniBioTransfer addresses data insufficiency in multi-task generation through a unified data construction strategy, including a swapping-based corruption mechanism designed for spatially dynamic attributes like hair. It further mitigates cross-task interference via an innovative BioMoE, a mixture-of-experts based model coupled with a novel two-stage training strategy that effectively disentangles task-specific knowledge. Extensive experiments demonstrate the effectiveness, generalization, and scalability of UniBioTransfer, outperforming both existing unified models and task-specific methods across a wide range of deepface generation tasks.
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
## Setup
|
| 22 |
+
|
| 23 |
+
### 1. Environment setup
|
| 24 |
```
|
| 25 |
conda create -n "unibio" python=3.10.16 -y
|
| 26 |
conda activate unibio
|
|
|
|
| 28 |
```
|
| 29 |
|
| 30 |
|
| 31 |
+
### 2. Download pre-trained weight
|
| 32 |
Download pre-trained checkpoints via `python download_checkpoints.py`
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
+
## Inference
|
| 38 |
+
|
| 39 |
+
Minimum **11GB** VRAM required.
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
python infer.py --task-name=face --tgt=examples/face/tgt.png --ref=examples/face/ref.png --out-dir=examples/face
|
| 43 |
+
python infer.py --task-name=hair --tgt=examples/hair/tgt.png --ref=examples/hair/ref.png --out-dir=examples/hair
|
| 44 |
+
python infer.py --task-name=motion --tgt=examples/motion/tgt.png --ref=examples/motion/ref.png --out-dir=examples/motion
|
| 45 |
+
python infer.py --task-name=head --tgt=examples/head/tgt.png --ref=examples/head/ref.png --out-dir=examples/head
|
| 46 |
+
```
|
| 47 |
|
| 48 |
## Citing Us
|
| 49 |
If you find our work valuable, we kindly ask you to consider citing our paper.
|
download_checkpoints.py
CHANGED
|
@@ -5,8 +5,7 @@ from confs import *
|
|
| 5 |
|
| 6 |
|
| 7 |
def _download(repo_id, filename, local_path: Path) -> Path:
|
| 8 |
-
|
| 9 |
-
return local_path
|
| 10 |
from huggingface_hub import hf_hub_download
|
| 11 |
local_path.parent.mkdir(parents=True, exist_ok=True)
|
| 12 |
token = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACE_HUB_TOKEN")
|
|
@@ -22,5 +21,5 @@ def _download(repo_id, filename, local_path: Path) -> Path:
|
|
| 22 |
|
| 23 |
|
| 24 |
_download("CompVis/stable-diffusion-v-1-4-original",SD14_filename, SD14_localpath)
|
| 25 |
-
_download("scy639/UniBioTransfer",PRETRAIN_CKPT_PATH,
|
| 26 |
-
_download("scy639/UniBioTransfer",PRETRAIN_JSON_PATH,
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
def _download(repo_id, filename, local_path: Path) -> Path:
|
| 8 |
+
local_path = Path(local_path)
|
|
|
|
| 9 |
from huggingface_hub import hf_hub_download
|
| 10 |
local_path.parent.mkdir(parents=True, exist_ok=True)
|
| 11 |
token = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACE_HUB_TOKEN")
|
|
|
|
| 21 |
|
| 22 |
|
| 23 |
_download("CompVis/stable-diffusion-v-1-4-original",SD14_filename, SD14_localpath)
|
| 24 |
+
_download("scy639/UniBioTransfer",PRETRAIN_CKPT_PATH, ".")
|
| 25 |
+
_download("scy639/UniBioTransfer",PRETRAIN_JSON_PATH, ".")
|
util_and_constant.py
CHANGED
|
@@ -106,8 +106,8 @@ _gate_k2tu = { # id 2 (max_run,interval,prob)
|
|
| 106 |
'vis-ffn_gate_input' : ( 3, 3, None ),
|
| 107 |
'[warning]: no param to sync' : (10,1, None ),#-------------TP-----------
|
| 108 |
'[TP] shared sync counts' : (10,1, None ),
|
| 109 |
-
'[Conv2d param stats] count, name (sorted desc):': (
|
| 110 |
-
'avg full_name=' : (
|
| 111 |
}
|
| 112 |
def gate_(id_, *args, **kw, ): # gate for some vis or print behaviour, just for vis/debug
|
| 113 |
# return 0
|
|
|
|
| 106 |
'vis-ffn_gate_input' : ( 3, 3, None ),
|
| 107 |
'[warning]: no param to sync' : (10,1, None ),#-------------TP-----------
|
| 108 |
'[TP] shared sync counts' : (10,1, None ),
|
| 109 |
+
'[Conv2d param stats] count, name (sorted desc):': (0,1, None ),#-------------upcycle-----------
|
| 110 |
+
'avg full_name=' : ( 0, 1, None ),
|
| 111 |
}
|
| 112 |
def gate_(id_, *args, **kw, ): # gate for some vis or print behaviour, just for vis/debug
|
| 113 |
# return 0
|