Spaces:
Sleeping
Sleeping
Delete README.md
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137:tada: Good News: our work has been accepted by **IEEE Transactions on Pattern Analysis and Machine Intelligence (PAMI)!** :tada:
[](https://colab.research.google.com/drive/1-U642OoCyb8OSM8nx9lme49dmWa_aUcU?usp=sharing)# RelTR: Relation Transformer for Scene Graph Generation
We now provide [[Colab](https://colab.research.google.com/drive/1-U642OoCyb8OSM8nx9lme49dmWa_aUcU?usp=sharing)] Demo!
PyTorch Implementation of the Paper [**RelTR: Relation Transformer for Scene Graph Generation**](https://arxiv.org/abs/2201.11460v3)
Different from most existing advanced approaches that infer the **dense** relationships between all entity proposals, our one-stage method can directly generate a **sparse** scene graph by decoding the visual appearance. If our work is helpful for your research, please cite our publication:```@article{cong2023reltr, title={Reltr: Relation transformer for scene graph generation}, author={Cong, Yuren and Yang, Michael Ying and Rosenhahn, Bodo}, journal={IEEE Transactions on Pattern Analysis and Machine Intelligence}, year={2023}, publisher={IEEE}}```
<p align="center"> <img src="demo/demo.png"></p>
# 0. Checklist
- [x] Inference Code :tada:- [x] Training Code for Visual Genome :tada:- [x] Evaluation Code for Visual Genome :tada:- [x] Colab Demo :tada:- [x] Training Code for OpenImages V6 :tada:- [x] Evaluation Code for OpenImages V6 :tada:- [ ] Cleaner Evaluation Code :clock9:- [ ] Post Processing :clock9:
# 1. InstallationDownload **RelTR Repo** with:```git clone https://github.com/yrcong/RelTR.gitcd RelTR```
## For Inference:smile: It is super easy to configure the RelTR environment.
If you want to **infer an image**, only python=3.6, PyTorch=1.6 and matplotlib are required!You can configure the environment as follows:```# create a conda environment conda create -n reltr python=3.6conda activate reltr
# install packagesconda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 -c pytorchconda install matplotlib```
## Training/Evaluation on Visual Genome or Open Images V6If you want to **train/evaluate** RelTR on Visual Genome, you need a little more preparation:
a) Scipy (we used 1.5.2) and pycocotools are required. ```conda install scipypip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'```b) Follow [README](https://github.com/yrcong/RelTR/blob/main/data/README.md) in the data directory to prepare the datasets.
c) Some widely-used evaluation code (**IoU**) need to be compiled... We will replace it with Pytorch code.```# compile the code computing box intersectioncd lib/fpnsh make.sh```
The directory structure looks like:```RelTR| βββββdataβ ββββvgβ β rel.jsonβ β test.jsonβ | train.json| | val.json| | imagesβ ββββoiβ β rel.jsonβ β test.jsonβ | train.json| | val.json| | imagesββββdatasets ... ```
# 2. Usage
## Inferencea) Download our [RelTR model](https://drive.google.com/file/d/1id6oD_iwiNDD6HyCn2ORgRTIKkPD3tUD/view) pretrained on the Visual Genome dataset and put it under ```ckpt/checkpoint0149.pth```b) Infer the relationships in an image with the command:```python inference.py --img_path $IMAGE_PATH --resume $MODEL_PATH```We attached 5 images from **VG** dataset and 1 image from **internet**. You can also test with your customized image. The result should look like:<p align="center"> <img src="demo/vg1_pred.png"></p>
## Traininga) Train RelTR on Visual Genome on a single node with 8 GPUs (2 images per GPU):```python -m torch.distributed.launch --nproc_per_node=8 --use_env main.py --dataset vg --img_folder data/vg/images/ --ann_path data/vg/ --batch_size 2 --output_dir ckpt```b) Train RelTR on Open Images V6 on a single node with 8 GPUs (2 images per GPU):```python -m torch.distributed.launch --nproc_per_node=8 --use_env main.py --dataset oi --img_folder data/oi/images/ --ann_path data/oi/ --batch_size 2 --output_dir ckpt```
## Evaluationa) Evaluate the pretrained [RelTR](https://drive.google.com/file/d/1id6oD_iwiNDD6HyCn2ORgRTIKkPD3tUD/view) on Visual Genome with a single GPU (1 image per GPU):```python main.py --dataset vg --img_folder data/vg/images/ --ann_path data/vg/ --eval --batch_size 1 --resume ckpt/checkpoint0149.pth```
b) Evaluate the pretrained [RelTR](https://drive.google.com/file/d/1pcoUnR0XWsvM9lJZ5f93N5TKHkLdjtnb/view?usp=share_link) on Open Images V6 with a single GPU (1 image per GPU):```python main.py --dataset oi --img_folder data/oi/images/ --ann_path data/oi/ --eval --batch_size 1 --resume ckpt/checkpoint0149_oi.pth```
# 3. QuestionsSince the code is cleaned up from the draft, there may be some errors.If you meet any problem when running our code, please let me know! (It's better open an issue so that anyone can see it)README.mdDeleted-137