Spaces:
Runtime error
Runtime error
File size: 1,690 Bytes
0c8d55e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
The original code is from [GEdit-Bench](https://github.com/stepfun-ai/Step1X-Edit/blob/main/GEdit-Bench/EVAL.md).
## Requirements and Installation
```
pip install megfile openai
```
## Prepare Source Images
Prepare the original image and metadata json following the example code in `step0_generate_image_example.py`
```bash
GEDIT_ASSET="/path/to/gedit_asset"
python step0_prepare_gedit.py --save_path ${GEDIT_ASSET} --json_file_path gedit_edit.json
```
The file directory structure of the original imageοΌ
```folder
${GEDIT_ASSET}/
β βββ fullset/
β βββ edit_task/
β βββ cn/ # Chinese instructions
β β βββ key1.png
β β βββ key2.png
β β βββ ...
β βββ en/ # English instructions
β βββ key1.png
β βββ key2.png
β βββ ...
```
## Eval
### Generate samples
```bash
# switch to univa env
MODEL_PATH='path/to/model'
OUTPUT_DIR='path/to/eval_output/gedit'
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 torchrun \
--nproc_per_node 8 \
-m step1_gen_samples \
gedit.yaml \
--pretrained_lvlm_name_or_path ${MODEL_PATH} \
--output_dir ${OUTPUT_DIR}
```
### Evaluation
Write your gpt-api-key to `secret_t2.env`.
```bash
IMAGE_DIR=${OUTPUT_DIR}
python step2_gedit_bench.py \
--model_name UniWorld \
--save_path ${IMAGE_DIR} \
--backbone gpt4o \
--source_path ${GEDIT_ASSET}
```
### Summary
```bash
python step3_calculate_statistics.py \
--model_name UniWorld \
--save_path ${IMAGE_DIR} \
--backbone gpt4o \
--language en > ${IMAGE_DIR}.txt
cat ${IMAGE_DIR}.txt
```
|