Downloads · 30 days
0
adaviraokulkarni06/lpcv-track3-pipeline
lpcv-track3-pipeline is a machine learning model from adaviraokulkarni06. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Task: AI-generated Image Detection with Structured 8-Criteria Evaluation Model: Qwen2.5-VL-3B-Instruct (3B params, mobile-optimized) Method: 2-Stage LoRA SFT based on Forensic-Chat
Downloads · 30 days
0
Access
Public
Updated Apr 23, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py46.1 KB · 81%
From the Hugging Face model README
Task: AI-generated Image Detection with Structured 8-Criteria Evaluation
Model: Qwen2.5-VL-3B-Instruct (3B params, mobile-optimized)
Method: 2-Stage LoRA SFT based on Forensic-Chat
| Stage | Task | LoRA Rank | What to Train | Epochs |
|---|---|---|---|---|
| 1 | Visual Enhancement (binary: real vs AI) | r=16 | ViT/vision encoder | 2 |
| 2 | Reasoning + JSON (8-criteria analysis) | r=128 | LLM reasoning | 3 |
| 3 | Final Merge | — | Full model | — |
| 4 | Quantize → QNN | — | Qualcomm AI Hub | — |
Based on SOTA research (Forensic-Chat, AIGI-Holmes):
export HF_USERNAME=your_username
python prepare_dataset.py
bash run_pipeline.sh your_username
Or run steps manually:
# Stage 1: Train ViT for artifact detection
python train_stage1.py \
--base_model Qwen/Qwen2.5-VL-3B-Instruct \
--dataset $HF_USERNAME/lpcv-track3-stage1 \
--hub_model_id $HF_USERNAME/lpcv-track3-stage1-lora
# Merge Stage 1 adapters
python merge_stage1.py \
--base_model Qwen/Qwen2.5-VL-3B-Instruct \
--adapter ./stage1_output/final \
--output_dir ./stage1_merged
# Stage 2: Train LLM for JSON reasoning
python train_stage2.py \
--merged_model ./stage1_merged \
--dataset $HF_USERNAME/lpcv-track3-stage2 \
--hub_model_id $HF_USERNAME/lpcv-track3-stage2-lora
# Final merge
python merge_final.py \
--stage1_merged ./stage1_merged \
--stage2_adapter ./stage2_output/final \
--output_dir ./final_model \
--hub_model_id $HF_USERNAME/lpcv-track3-final
python inference.py \
--model ./final_model \
--image sample.jpg \
--output prediction.json
python evaluate.py \
--predictions predictions.jsonl \
--ground_truth gt.jsonl \
--output results.json
python quantize_for_qnn.py \
--model ./final_model \
--output_dir ./qnn_export
# Then compile via Qualcomm AI Hub:
bash ./qnn_export/compile_via_aihub.sh
| Image Type | Score Formula |
|---|---|
| Real | 1.0 × DetectionScore |
| AI-Generated | 0.5 × DetectionScore + 0.5 × ExplanationScore |
Where:
overall_likelihood (Real vs AI-Generated)0.5 × CriterionScore + 0.5 × EvidenceScore| Dataset | Source | Size | Format |
|---|---|---|---|
| SID_Set_description | saberzl/SID_Set_description | ~2K train / ~200 val | Image + free-text description |
| GenImage | blorg469/genimage | 1M+ | Image + label |
| SynthScars | khr0516/SynthScars | 12K | Image only |
Custom data recommended: Generate additional training data by:
| Model | Params | VRAM for Training | Inference Speed | Recommendation |
|---|---|---|---|---|
| Qwen2.5-VL-3B | 3B | ~16GB (LoRA) | Fast ✅ | Primary choice for >15 TPS |
| Qwen2.5-VL-7B | 7B | ~24GB (LoRA) | Medium | Better accuracy, risk of TPS limit |
For competition: Use Qwen2.5-VL-3B-Instruct to stay well above 15 TPS threshold.
| Stage | GPU | VRAM | Time |
|---|---|---|---|
| Stage 1 (3B, r=16) | A100 / A10G / RTX 4090 | 16GB | ~2-3 hours |
| Stage 2 (3B, r=128) | A100 / A10G / RTX 4090 | 16-20GB | ~4-6 hours |
| Merge | Any GPU | 12GB | ~30 min |
| Parameter | Stage 1 | Stage 2 |
|---|---|---|
| LoRA rank | 16 | 128 |
| LoRA alpha | 32 | 256 |
| Learning rate | 1e-4 | 5e-5 |
| Epochs | 2 | 3 |
| Batch size | 4 | 2 |
| Grad accum | 4 | 8 |
| Effective batch | 16 | 16 |
| LR schedule | Cosine | Cosine |
| Warmup | 10% | 10% |
| Target modules | q,k,v,o_proj | All linear |
Apache-2.0 (matching base model and datasets)