Datasets:
Update README.md
Browse files
README.md
CHANGED
|
@@ -42,6 +42,128 @@ configs:
|
|
| 42 |
[](https://huggingface.co/WithAnyone/WithAnyone)
|
| 43 |
[](https://huggingface.co/datasets/WithAnyone/MultiID-Bench)
|
| 44 |
[](https://huggingface.co/datasets/WithAnyone/MultiID-2M)
|
| 45 |
-
[ for the usage of this benchmark.
|
|
|
|
| 42 |
[](https://huggingface.co/WithAnyone/WithAnyone)
|
| 43 |
[](https://huggingface.co/datasets/WithAnyone/MultiID-Bench)
|
| 44 |
[](https://huggingface.co/datasets/WithAnyone/MultiID-2M)
|
| 45 |
+
[](https://huggingface.co/spaces/WithAnyone/WithAnyone_demo)
|
| 46 |
+
|
| 47 |
+
**Please refer to [GitHub repo](https://github.com/Doby-Xu/WithAnyone) for the usage of this benchmark.**
|
| 48 |
+
|
| 49 |
+
## Download
|
| 50 |
+
|
| 51 |
+
[HuggingFace Dataset](https://huggingface.co/datasets/WithAnyone/MultiID-Bench)
|
| 52 |
+
|
| 53 |
+
```
|
| 54 |
+
huggingface-cli download WithAnyone/MultiID-Bench --repo-type dataset --local-dir <path to MultiID-Bench directory>
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
## Evaluation
|
| 58 |
+
|
| 59 |
+
**Please refer to [GitHub repo](https://github.com/Doby-Xu/WithAnyone) for the usage of this benchmark.**
|
| 60 |
+
|
| 61 |
+
### Environment Setup
|
| 62 |
+
|
| 63 |
+
Besides the `requirements.txt` in [GitHub repo](https://github.com/Doby-Xu/WithAnyone), you need to install the following packages:
|
| 64 |
+
|
| 65 |
+
```bash
|
| 66 |
+
pip install aesthetic-predictor-v2-5
|
| 67 |
+
pip install facexlib
|
| 68 |
+
pip install colorama
|
| 69 |
+
pip install pytorch_lightning
|
| 70 |
+
git clone https://github.com/timesler/facenet-pytorch.git facenet_pytorch
|
| 71 |
+
|
| 72 |
+
# in MultiID_Bench/
|
| 73 |
+
mkdir pretrained
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
You need the following models to run the evaluation:
|
| 78 |
+
|
| 79 |
+
- CLIP
|
| 80 |
+
- arcface
|
| 81 |
+
- aesthetic-v2.5
|
| 82 |
+
- adaface
|
| 83 |
+
- facenet
|
| 84 |
+
|
| 85 |
+
For the first three models, they will be automatically downloaded when you run the evaluation script for the first time. Most of the models will be cached in the `HF_HOME` directory, which is usually `~/.cache/huggingface`. About 5GB of disk space is needed.
|
| 86 |
+
|
| 87 |
+
For adaface, you need to download the model weights from [adaface_ir50_ms1mv2.ckpt](https://drive.google.com/file/d/1eUaSHG4pGlIZK7hBkqjyp2fc2epKoBvI/view?usp=sharing) (This is the original link provided by the authors of AdaFace) and put it in the `pretrained` directory.
|
| 88 |
+
|
| 89 |
+
This repository includes code from [AdaFace](https://github.com/mk-minchul/AdaFace?tab=readme-ov-file). AdaFace is included in this codebase for merely easier import. You can also clone it separately from its original repository, and modify the import paths accordingly.
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
### Data to Evaluate
|
| 93 |
+
|
| 94 |
+
By running:
|
| 95 |
+
```
|
| 96 |
+
python hf2bench.py \
|
| 97 |
+
--dataset WithAnyone/MultiID-Bench \
|
| 98 |
+
--output <root directory to save the data> \
|
| 99 |
+
--from_hub
|
| 100 |
+
```
|
| 101 |
+
you can arrange the generated images and the corresponding text prompts in the following structure:
|
| 102 |
+
```
|
| 103 |
+
root/
|
| 104 |
+
βββ id1/
|
| 105 |
+
β βββ out.jpg
|
| 106 |
+
β βββ ori.jpg
|
| 107 |
+
β βββ ref_1.jpg
|
| 108 |
+
β βββ ref_2.jpg
|
| 109 |
+
β βββ ref_3.jpg
|
| 110 |
+
β βββ ref_4.jpg
|
| 111 |
+
β βββ meta.json
|
| 112 |
+
β
|
| 113 |
+
βββ id2/
|
| 114 |
+
β βββ out.jpg
|
| 115 |
+
β βββ ori.jpg
|
| 116 |
+
β βββ ref_1.jpg
|
| 117 |
+
β βββ ref_2.jpg
|
| 118 |
+
β βββ ref_3.jpg
|
| 119 |
+
β βββ ref_4.jpg
|
| 120 |
+
β βββ meta.json
|
| 121 |
+
β
|
| 122 |
+
βββ ...
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
Or you can manually download the data by
|
| 126 |
+
```
|
| 127 |
+
huggingface-cli download WithAnyone/MultiID-Bench --repo-type dataset --local-dir <root directory to save the data>
|
| 128 |
+
```
|
| 129 |
+
and arrange the files:
|
| 130 |
+
```
|
| 131 |
+
python hf2bench.py --dataset <root directory to save the data> --output <root directory to save the data>
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
If you run the `infer_withanyone.py` script in this repository, the output directory will be in the correct format.
|
| 135 |
+
|
| 136 |
+
The `meta.json` file should contain the prompt used to generate the image, in the following format:
|
| 137 |
+
|
| 138 |
+
```json
|
| 139 |
+
{
|
| 140 |
+
"prompt": "a photo of a person with blue hair and glasses"
|
| 141 |
+
}
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
### Run Evaluation
|
| 145 |
+
|
| 146 |
+
You can run the evaluation script as follows:
|
| 147 |
+
|
| 148 |
+
```python
|
| 149 |
+
from eval import BenchEval_Geo
|
| 150 |
+
|
| 151 |
+
def run():
|
| 152 |
+
evaler = BenchEval_Geo(
|
| 153 |
+
target_dir=<root directory mentioned above>,
|
| 154 |
+
output_dir=<output directory to save the evaluation results>,
|
| 155 |
+
ori_file_name="ori.jpg", # the name of the ground truth image file
|
| 156 |
+
output_file_name="out.jpg", # the name of the generated image file
|
| 157 |
+
ref_1_file_name="ref_1.jpg", # the name of the first reference image file
|
| 158 |
+
ref_2_file_name="ref_2.jpg", # the name of the second reference image file
|
| 159 |
+
# ref_2_file_name=None, # if you only have one reference image, set ref_2_file_name to None
|
| 160 |
+
# ref_3_file_name="ref_3.jpg", # the name of the third reference
|
| 161 |
+
# ref_4_file_name="ref_4.jpg", # the name of the fourth reference,
|
| 162 |
+
caption_keyword="prompt", # the keyword to extract the prompt from meta.json
|
| 163 |
+
names_keyword=None
|
| 164 |
+
)
|
| 165 |
+
evaler()
|
| 166 |
+
if __name__ == "__main__":
|
| 167 |
+
run()
|
| 168 |
+
```
|
| 169 |
|
|
|