Image-Text-to-Text
PEFT
Safetensors
qwen3-vl
vision-language
portrait-aesthetics
aesthetics-evaluation
lora
llama-factory
Instructions to use Artoria0429/code_portrait_track_1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Artoria0429/code_portrait_track_1 with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Add Track 1 solution description
Browse files- Track_1_SOLUTION_DESCRIPTION.md +183 -0
Track_1_SOLUTION_DESCRIPTION.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Portrait Composition Aesthetics Evaluation Solution
|
| 2 |
+
|
| 3 |
+
## 1. Data Construction
|
| 4 |
+
|
| 5 |
+
The original training and validation sets are organized in ShareGPT format. Each sample contains a user prompt, an assistant annotation, and an image path. The annotation includes scores for 13 aesthetic criteria and `total_score`.
|
| 6 |
+
|
| 7 |
+
The data processing script is `prepare_dataset.py`. It generates three types of training data:
|
| 8 |
+
|
| 9 |
+
- `score_v2`: keeps only each criterion `score` and `total_score`; used for first-stage score learning.
|
| 10 |
+
- `multitask_v2`: keeps each criterion `score`, `level`, and `total_score`; used for multitask learning.
|
| 11 |
+
- `balanced_v2`: performs resampling on top of `multitask_v2`; used for second-stage reinforced training.
|
| 12 |
+
|
| 13 |
+
Criterion levels are mapped from scores as follows:
|
| 14 |
+
|
| 15 |
+
- `A`: score < 5
|
| 16 |
+
- `B`: 5 <= score < 7
|
| 17 |
+
- `C`: score >= 7
|
| 18 |
+
|
| 19 |
+
Boundary samples are identified by whether their scores are close to the level thresholds 5 and 7. Rare-level samples and boundary samples receive higher duplication weights to reduce class imbalance and improve level-boundary stability.
|
| 20 |
+
|
| 21 |
+
## 2. Two-Stage Training
|
| 22 |
+
|
| 23 |
+
The base model is `Qwen3-VL-8B-Instruct`, and the fine-tuning method is LoRA.
|
| 24 |
+
|
| 25 |
+
Stage1 uses `score_v2` data. Its goal is to let the model learn stable scores for the 13 criteria and the overall score. This stage produces one Stage1 adapter, which is used as the initialization for subsequent training.
|
| 26 |
+
|
| 27 |
+
Stage2 continues training from the Stage1 adapter and uses the resampled `balanced_v2` data. This stage jointly learns criterion scores, level labels, and the overall score, with emphasis on boundary samples and minority classes.
|
| 28 |
+
|
| 29 |
+
To reduce the impact of training randomness, Stage2 is trained with two different random seeds, producing two Stage2 adapters. The final prediction stage mainly uses these two second-stage adapters.
|
| 30 |
+
|
| 31 |
+
Stage1 training prompt example:
|
| 32 |
+
|
| 33 |
+
```text
|
| 34 |
+
You are an aesthetics expert. Evaluate the image on the following 13 criteria:
|
| 35 |
+
Color Harmony, Visual Style Consistency, Sharpness, Light and Shadow Modeling,
|
| 36 |
+
Creativity and Originality, Exposure Control, Application of Classical Composition Principles,
|
| 37 |
+
Depth of Field and Layering, Visual Center Stability, Visual Flow Guidance,
|
| 38 |
+
Structural Support Stability, Appropriateness of Negative Space, Subject Integrity.
|
| 39 |
+
|
| 40 |
+
For each criterion, output a numeric score in [0.0, 10.0].
|
| 41 |
+
Then output total_score as an integer in [0, 100].
|
| 42 |
+
Return STRICT JSON only.
|
| 43 |
+
|
| 44 |
+
JSON format:
|
| 45 |
+
{
|
| 46 |
+
"criteria": {
|
| 47 |
+
"Color Harmony": {"score": 0.0}
|
| 48 |
+
},
|
| 49 |
+
"total_score": 0
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
<image>
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
Stage2 training prompt example:
|
| 56 |
+
|
| 57 |
+
```text
|
| 58 |
+
You are an aesthetics expert. Evaluate the image on the following 13 criteria:
|
| 59 |
+
Color Harmony, Visual Style Consistency, Sharpness, Light and Shadow Modeling,
|
| 60 |
+
Creativity and Originality, Exposure Control, Application of Classical Composition Principles,
|
| 61 |
+
Depth of Field and Layering, Visual Center Stability, Visual Flow Guidance,
|
| 62 |
+
Structural Support Stability, Appropriateness of Negative Space, Subject Integrity.
|
| 63 |
+
|
| 64 |
+
For each criterion, output:
|
| 65 |
+
1) score in [0.0, 10.0]
|
| 66 |
+
2) level in {A,B,C} where A:<5, B:[5,7), C:>=7
|
| 67 |
+
Then output total_score as an integer in [0, 100].
|
| 68 |
+
Return STRICT JSON only.
|
| 69 |
+
|
| 70 |
+
JSON format:
|
| 71 |
+
{
|
| 72 |
+
"criteria": {
|
| 73 |
+
"Color Harmony": {"score": 0.0, "level": "A|B|C"}
|
| 74 |
+
},
|
| 75 |
+
"total_score": 0
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
<image>
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
## 3. Multi-Prompt Prediction
|
| 82 |
+
|
| 83 |
+
The test data is converted into LLaMA-Factory prediction format by `prepare_test_prompt_v2.py`. For the same test sample, the script constructs multiple prompt variants. Different variants emphasize different evaluation aspects, including technical quality, composition and lighting, defect sensitivity, and ranking stability.
|
| 84 |
+
|
| 85 |
+
All prompt variants keep the same output structure and require the model to output strict JSON containing:
|
| 86 |
+
|
| 87 |
+
- `score` for the 13 criteria
|
| 88 |
+
- `total_score`
|
| 89 |
+
- final `answer`
|
| 90 |
+
|
| 91 |
+
Prompt example:
|
| 92 |
+
|
| 93 |
+
```text
|
| 94 |
+
You are a strict cross-image ranking evaluator for portrait aesthetics.
|
| 95 |
+
|
| 96 |
+
Hard rules:
|
| 97 |
+
1) criteria scores in [0.0, 10.0]
|
| 98 |
+
2) total_score integer in [0, 100]
|
| 99 |
+
3) answer exactly A/B/C/D
|
| 100 |
+
4) strict JSON only
|
| 101 |
+
5) no level/reason/x and no extra keys
|
| 102 |
+
|
| 103 |
+
Scoring guidance:
|
| 104 |
+
- Avoid score collapse around the middle range.
|
| 105 |
+
- Penalize visible defects by the affected criteria.
|
| 106 |
+
- Keep total_score coherent with overall perceptual quality.
|
| 107 |
+
|
| 108 |
+
Return exactly this schema:
|
| 109 |
+
{
|
| 110 |
+
"criteria": {
|
| 111 |
+
"Color Harmony": {"score": 0.0},
|
| 112 |
+
"Visual Style Consistency": {"score": 0.0},
|
| 113 |
+
"Sharpness": {"score": 0.0},
|
| 114 |
+
"Light and Shadow Modeling": {"score": 0.0},
|
| 115 |
+
"Creativity and Originality": {"score": 0.0},
|
| 116 |
+
"Exposure Control": {"score": 0.0},
|
| 117 |
+
"Application of Classical Composition Principles": {"score": 0.0},
|
| 118 |
+
"Depth of Field and Layering": {"score": 0.0},
|
| 119 |
+
"Visual Center Stability": {"score": 0.0},
|
| 120 |
+
"Visual Flow Guidance": {"score": 0.0},
|
| 121 |
+
"Structural Support Stability": {"score": 0.0},
|
| 122 |
+
"Appropriateness of Negative Space": {"score": 0.0},
|
| 123 |
+
"Subject Integrity": {"score": 0.0}
|
| 124 |
+
},
|
| 125 |
+
"total_score": 0,
|
| 126 |
+
"answer": "A|B|C|D"
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
Question: __QUESTION__
|
| 130 |
+
Options:
|
| 131 |
+
A: __OPT_A__
|
| 132 |
+
B: __OPT_B__
|
| 133 |
+
C: __OPT_C__
|
| 134 |
+
D: __OPT_D__
|
| 135 |
+
|
| 136 |
+
<image>
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
Multi-prompt prediction constrains model outputs from different evaluation perspectives and reduces scoring bias caused by a single prompt.
|
| 140 |
+
|
| 141 |
+
## 4. Multi-Path Result Fusion
|
| 142 |
+
|
| 143 |
+
Prediction results are fused by `convert_to_answer.py`. The fusion inputs include outputs from different Stage2 adapters and different prompt variants.
|
| 144 |
+
|
| 145 |
+
The fusion strategy is as follows:
|
| 146 |
+
|
| 147 |
+
- `criteria.level`: majority voting is used first; if votes are tied, the mean `score` from multiple paths is mapped back to a level.
|
| 148 |
+
- `total_score`: the mean or trimmed mean of multiple `total_score` values is used to reduce single-run fluctuation.
|
| 149 |
+
- `answer`: weighted voting is used; if a tie remains, the specified priority model or a stable alphabetical fallback is used.
|
| 150 |
+
|
| 151 |
+
This fusion method combines multiple weights, multiple prompts, and multiple prediction results to reduce systematic bias on local samples.
|
| 152 |
+
|
| 153 |
+
## 5. Final Output
|
| 154 |
+
|
| 155 |
+
The final output is `track_1_test.json`, which follows the competition submission format. The file preserves the official template structure and fills in the fused criterion levels, overall score, and answer.
|
| 156 |
+
|
| 157 |
+
The overall process is:
|
| 158 |
+
|
| 159 |
+
1. Build score-only, multitask, and resampled training data.
|
| 160 |
+
2. Train the Stage1 adapter with score-only data.
|
| 161 |
+
3. Train two Stage2 adapters from Stage1 using resampled multitask data.
|
| 162 |
+
4. Use the final Stage2 adapters for multi-prompt prediction.
|
| 163 |
+
5. Fuse multi-path prediction results and generate the final submission file.
|
| 164 |
+
|
| 165 |
+
This solution improves robustness and consistency through boundary-sample reinforcement at the data level, two-stage transfer at the training level, multi-prompt ensembling at the prediction level, and multi-path fusion at the post-processing level.
|
| 166 |
+
|
| 167 |
+
## 6. Overall Training Workflow
|
| 168 |
+
|
| 169 |
+
The complete training and inference workflow consists of data files, processing scripts, training configurations, and adapter artifacts.
|
| 170 |
+
|
| 171 |
+

|
| 172 |
+
|
| 173 |
+
| Stage | Files Used | Purpose | Main Artifacts |
|
| 174 |
+
| --- | --- | --- | --- |
|
| 175 |
+
| Raw data input | `codabench_portrait_train.json`, `codabench_portrait_val.json` | Provides training and validation samples, including image paths, 13 criterion scores, and `total_score` | Raw ShareGPT-format annotation data |
|
| 176 |
+
| Data reconstruction | `prepare_dataset.py` | Parses raw annotations and generates score-only, multitask, and resampled training data | `codabench_portrait_train_score_v2.json`, `codabench_portrait_train_multitask_v2.json`, `codabench_portrait_train_balanced_v2.json`, `codabench_portrait_val_score_v2.json`, `codabench_portrait_val_multitask_v2.json` |
|
| 177 |
+
| Stage1 training | `train_track1_stage1_qwen3vl8b_v1.yaml` | Configures first-stage LoRA training with score-only data to learn criterion scores and overall score | Stage1 adapter `r1_stage1` |
|
| 178 |
+
| Stage2 training | `train_track1_stage2_qwen3vl8b_v1.yaml` | Continues training from Stage1 with resampled multitask data to learn `score`, `level`, and `total_score` | Two Stage2 adapters: `seed20260511_stage2`, `seed20260512_stage2` |
|
| 179 |
+
| Test set construction | `prepare_test_prompt_v2.py` | Converts the official test set into multi-prompt prediction data with different evaluation emphases | Multi-version test prediction inputs |
|
| 180 |
+
| Multi-path prediction | Two Stage2 adapters and multi-version test prompts | Generates multiple prediction paths using different weights and prompt variants | Multiple `generated_predictions.jsonl` files |
|
| 181 |
+
| Result fusion | `convert_to_answer.py` | Fuses criterion levels, overall scores, and answers from multiple prediction paths | Final submission file `track_1_test.json` |
|
| 182 |
+
|
| 183 |
+
The main training flow is: first construct training data with `prepare_dataset.py`, then train the base scoring adapter using the Stage1 configuration, and then train two Stage2 multitask adapters initialized from Stage1. During inference, the two Stage2 adapters are used with multiple prompt variants to generate predictions. The final submission is produced by the fusion script.
|