Comments (2)
+1
from reltr.
We create the .json files in COCO format.
You can refer to the code we used:
from dataloaders.visual_genome_coco import VGDataLoader, VG
import numpy as np
from torch import optim
import torch
from PIL import Image
import time
import json
train, val, test = VG.splits(num_val_im=5000, filter_duplicate_rels=True,
use_proposals=False,
filter_non_overlap=True)
rel_categories = train.ind_to_predicates
counter = 0
images = []
annotations = []
categories = []
train_rel = {}
for idx, i in enumerate(train.ind_to_classes):
if idx == 0:
continue
else:
category = {'supercategory': i, 'id': idx, 'name': i}
categories.append(category)
train_triplets = np.zeros([151,151,51]) #sub obj rel
for idx, i in enumerate(train.filenames):
file_name = i.split('/')[-1]
w, h = Image.open(i).size
image_id = int(i.split('/')[-1].split('.')[0])
image = {'file_name': file_name,
'height': h,
'width': w,
'id': image_id}
images.append(image)
train_rel[image_id] = [triplet.tolist() for triplet in np.unique(train.relationships[idx],axis=0)]
for idx2, j in enumerate(train.gt_boxes[idx]):
j = j*max(w, h)/1024
bbox = [int(j[0]), int(j[1]), int(j[2] - j[0] + 1), int(j[3] - j[1] + 1)]
area = int((j[3] - j[1] + 1) * (j[2] - j[0] + 1))
anno_id = counter
counter = counter + 1
annotation = {'segmentation': None,
'area': area,
'bbox': bbox,
'iscrowd': 0,
'image_id': image_id,
'id': anno_id,
'category_id': int(train.gt_classes[idx][idx2])}
annotations.append(annotation)
for relation in train_rel[image_id]:
train_triplets[train.gt_classes[idx][relation[0]], train.gt_classes[idx][relation[1]], relation[2]] += 1
train_database = {'images': images,
'annotations': annotations,
'categories': categories}
from reltr.
Related Issues (20)
- Model not getting trained on single GPU HOT 4
- Evaluation on VRD dataset HOT 1
- Hi, the training results are lower than reported results. HOT 4
- Inquiry about code behavior in relation to constraints of evaluation metrics HOT 1
- About training strategy HOT 1
- Can ur work train on VidOR? HOT 1
- Some questions about evaluation HOT 2
- RuntimeError: CUDA error: device-side assert triggered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1. Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions. HOT 4
- About evaluate_rel_batch() function HOT 7
- name 'train_stats' is not defined HOT 2
- convert the reltr model to onnx forma
- about Predcls HOT 1
- Evaluation HOT 3
- checkpoint should be updated with enhanced version HOT 1
- Some misunderstanding about the heat map using to predict Relationship HOT 2
- Error during training in bbox.pyx : ValueError: Buffer dtype mismatch, expected 'DTYPE_t' but got 'double' HOT 1
- 请问如何将inference.py得到的场景图保存成一个json文件呢 HOT 1
- What happens when there are no relations in a sample? HOT 2
- When I was training data, I encountered an error HOT 1
- About OpenV6 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reltr.