Add model card
#1
by
nielsr
HF Staff
- opened
README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pipeline_tag: text-to-image
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# Taming Generative Synthetic Data for X-ray Prohibited Item Detection
|
| 6 |
+
|
| 7 |
+
This repository contains the Xsyn model, a one-stage X-ray security image synthesis pipeline based on text-to-image generation. Proposed in the paper [Taming Generative Synthetic Data for X-ray Prohibited Item Detection](https://huggingface.co/papers/2511.15299), Xsyn addresses data insufficiency for prohibited item detection by incorporating two effective strategies: Cross-Attention Refinement (CAR) for refining bounding box annotations and Background Occlusion Modeling (BOM) for enhancing imaging complexity. It aims to achieve high-quality X-ray security image synthesis without incurring additional labor-intensive foreground preparation.
|
| 8 |
+
|
| 9 |
+
Code repository: [https://github.com/pILLOW-1/Xsyn/](https://github.com/pILLOW-1/Xsyn/)
|
| 10 |
+
|
| 11 |
+
<figure style="display:block; text-align:center; margin:0 auto;">
|
| 12 |
+
<img src="https://github.com/pILLOW-1/Xsyn/raw/main/figures/analysis.jpg"
|
| 13 |
+
alt="Analysis of existing X-ray image synthesis methods"
|
| 14 |
+
style="width:90%; max-width:600px; margin:0 auto; display:block;">
|
| 15 |
+
</figure>
|
| 16 |
+
|
| 17 |
+
## Download Xsyn models
|
| 18 |
+
|
| 19 |
+
Checkpoints for different datasets are available. All models here are based on GLIGEN.
|
| 20 |
+
| Dataset | Mode | Download |
|
| 21 |
+
|------------|----------------|----------------------------------------------------------------------------------------------------------------|
|
| 22 |
+
| PIDray | text-grounded inpainting | [HF Hub](https://huggingface.co/Pillow-1/Xsyn) |
|
| 23 |
+
| OPIXray | text-grounded inpainting | [HF Hub](https://huggingface.co/Pillow-1/Xsyn) |
|
| 24 |
+
| HiXray | text-grounded inpainting | [HF Hub](https://huggingface.co/Pillow-1/Xsyn) |
|
| 25 |
+
|
| 26 |
+
## Inference
|
| 27 |
+
|
| 28 |
+
We provide one script to generate x-ray security images and construct their annotations. First download models and put them in `--ckpt_path`. Then run:
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
python gligen_inference.py
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
Details of some important args:
|
| 35 |
+
|
| 36 |
+
- `--output_path`: the path to save your generated x-ray security images
|
| 37 |
+
- `--annotation_path`: the path to save the refined annotation (stored in txt format)
|
| 38 |
+
- `--vis_path`: the path to save visualization compared with gt
|
| 39 |
+
- `--ca_vis_path`: the path to save cross-attention maps
|
| 40 |
+
- `--image_path`: the path to load images you want to inpaint
|
| 41 |
+
- `--ckpt_path`: the generation model checkpoint path
|
| 42 |
+
- `--gligen_caption_pt`: the file to prepare your training/test data in [GLIGEN](https://github.com/gligen/GLIGEN) format
|
| 43 |
+
- `--gen_method`: set to 1 for Xsyn-M and 3 for Xsyn-A
|
| 44 |
+
- `--refine_anno`: set to True for `CAR`
|
| 45 |
+
- `--latent_redist`: set to True for `BOM`
|
| 46 |
+
|
| 47 |
+
After inference, you can use `downstream_test.sh` to test the performance of our synthetic data. Our downstream detection environment is [mmdetection](https://github.com/open-mmlab/mmdetection).
|