This a official repository for FragFake: A Dataset for Fine-Grained Detection of Edited Images with Vision Language Models
This repository contains several key Python scripts for working with the FragFake dataset:
- clean_instruction_create_format.py: Processes the raw data to generate conversation format for training and testing
- test_gemma.py: Evaluation script for Gemma models
- test_result_llava_1_5.py: Evaluation script for LLaVA models
- test_result_qwen2.py: Evaluation script for Qwen2 models
- test_result_qwen2_5.py: Evaluation script for Qwen2.5 models
- create_instruction_easy_and_hard.py: Instructions creation
The clean_instruction_create_format.py script processes raw data from the FragFake dataset to create conversation pairs for both training and testing:
python clean_instruction_create_format.pyThis script:
- Extracts objects from symbolic modifications
- Removes duplicates in the conversations
- Generates conversation pairs for original and modified images
- Splits the data into training and testing sets
We provide evaluation scripts for multiple VLM architectures. Each script loads a fine-tuned model, runs inference on the test dataset, and saves the evaluation results.
python test_gemma.pypython test_result_llava_1_5.py --model_id "/path/to/model" --input_path "/path/to/test_data.json" --output_path "/path/to/save/results.json"python test_result_qwen2.pypython test_result_qwen2_5.pypython generate_instructions.py \
--api-key YOUR_GPT4O_API_KEY \
--base-dir /fdata/FragFake/coco_train_sample_3_25 \
--output-json /fdata/FragFake/finished_file/easy_instructions.json \
--modification-goals "object addition" "object replacement" \
--temperature 1.0
--api-key (required): your GPT-4o API key
--api-url: (optional) the API endpoint; defaults to the HKUST-GZ URL
--base-dir (required): path to COCO image root directory (organized by category)
--output-json (required): path where the result JSON will be saved
--modification-goals: (optional) space-separated list of goals; defaults to object addition object replacement
--temperature: (optional) sampling temperature (0.0–2.0), default 1.0
--skip-second-pass: (optional) if set, only the first pass runs, which is Easy version (no deduplication)- GoT: https://github.com/rongyaofang/GoT
- Magic Brush: https://github.com/OSU-NLP-Group/MagicBrush
- UltraEdit: https://github.com/HaozheZhao/UltraEdit
- Gemini-IG: You can access the API in https://ai.google.dev/gemini-api/docs/models
All model fine-tuning in this repository is performed using LLaMA-Factory, a comprehensive framework for fine-tuning large language models. Please refer to the LLaMA-Factory documentation for detailed instructions on setting up and running the fine-tuning process.