Showing preview only (1,091K chars total). Download the full file or copy to clipboard to get everything.
Repository: rowanz/neural-motifs
Branch: master
Commit: d05a251b705c
Files: 98
Total size: 1.0 MB
Directory structure:
gitextract_tbpjfk2p/
├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── config.py
├── data/
│ └── stanford_filtered/
│ └── README.md
├── dataloaders/
│ ├── __init__.py
│ ├── blob.py
│ ├── image_transforms.py
│ ├── mscoco.py
│ └── visual_genome.py
├── docs/
│ ├── LICENSE.md
│ ├── _config.yaml
│ ├── _includes/
│ │ └── image.html
│ ├── _layouts/
│ │ └── default.html
│ ├── index.md
│ └── upload.sh
├── lib/
│ ├── __init__.py
│ ├── draw_rectangles/
│ │ ├── draw_rectangles.c
│ │ ├── draw_rectangles.pyx
│ │ └── setup.py
│ ├── evaluation/
│ │ ├── __init__.py
│ │ ├── sg_eval.py
│ │ ├── sg_eval_all_rel_cates.py
│ │ ├── sg_eval_slow.py
│ │ └── test_sg_eval.py
│ ├── fpn/
│ │ ├── anchor_targets.py
│ │ ├── box_intersections_cpu/
│ │ │ ├── bbox.c
│ │ │ ├── bbox.pyx
│ │ │ └── setup.py
│ │ ├── box_utils.py
│ │ ├── generate_anchors.py
│ │ ├── make.sh
│ │ ├── nms/
│ │ │ ├── Makefile
│ │ │ ├── build.py
│ │ │ ├── functions/
│ │ │ │ └── nms.py
│ │ │ └── src/
│ │ │ ├── cuda/
│ │ │ │ ├── Makefile
│ │ │ │ ├── nms_kernel.cu
│ │ │ │ └── nms_kernel.h
│ │ │ ├── nms_cuda.c
│ │ │ └── nms_cuda.h
│ │ ├── proposal_assignments/
│ │ │ ├── proposal_assignments_det.py
│ │ │ ├── proposal_assignments_gtbox.py
│ │ │ ├── proposal_assignments_postnms.py
│ │ │ ├── proposal_assignments_rel.py
│ │ │ └── rel_assignments.py
│ │ └── roi_align/
│ │ ├── Makefile
│ │ ├── __init__.py
│ │ ├── _ext/
│ │ │ ├── __init__.py
│ │ │ └── roi_align/
│ │ │ └── __init__.py
│ │ ├── build.py
│ │ ├── functions/
│ │ │ ├── __init__.py
│ │ │ └── roi_align.py
│ │ ├── modules/
│ │ │ ├── __init__.py
│ │ │ └── roi_align.py
│ │ └── src/
│ │ ├── cuda/
│ │ │ ├── Makefile
│ │ │ ├── roi_align_kernel.cu
│ │ │ └── roi_align_kernel.h
│ │ ├── roi_align_cuda.c
│ │ └── roi_align_cuda.h
│ ├── get_dataset_counts.py
│ ├── get_union_boxes.py
│ ├── lstm/
│ │ ├── __init__.py
│ │ ├── decoder_rnn.py
│ │ └── highway_lstm_cuda/
│ │ ├── __init__.py
│ │ ├── _ext/
│ │ │ ├── __init__.py
│ │ │ └── highway_lstm_layer/
│ │ │ └── __init__.py
│ │ ├── alternating_highway_lstm.py
│ │ ├── build.py
│ │ ├── make.sh
│ │ └── src/
│ │ ├── highway_lstm_cuda.c
│ │ ├── highway_lstm_cuda.h
│ │ ├── highway_lstm_kernel.cu
│ │ └── highway_lstm_kernel.h
│ ├── object_detector.py
│ ├── pytorch_misc.py
│ ├── rel_model.py
│ ├── rel_model_stanford.py
│ ├── resnet.py
│ ├── sparse_targets.py
│ ├── surgery.py
│ └── word_vectors.py
├── misc/
│ ├── __init__.py
│ ├── motifs.py
│ ├── object_types.txt
│ └── relation_types.txt
├── models/
│ ├── _visualize.py
│ ├── eval_rel_count.py
│ ├── eval_rels.py
│ ├── train_detector.py
│ └── train_rels.py
└── scripts/
├── eval_models_sgcls.sh
├── eval_models_sgdet.sh
├── pretrain_detector.sh
├── refine_for_detection.sh
├── train_models_sgcls.sh
├── train_motifnet.sh
└── train_stanford.sh
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2018 Rowan Zellers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: Makefile
================================================
export PATH := /usr/local/cuda-9.1/bin:$(PATH)
all: draw_rectangles box_intersections nms roi_align lstm
draw_rectangles:
cd lib/draw_rectangles; python setup.py build_ext --inplace
box_intersections:
cd lib/fpn/box_intersections_cpu; python setup.py build_ext --inplace
nms:
cd lib/fpn/nms; make
roi_align:
cd lib/fpn/roi_align; make
lstm:
cd lib/lstm/highway_lstm_cuda; ./make.sh
================================================
FILE: README.md
================================================
# neural-motifs
### Like this work, or scene understanding in general? You might be interested in checking out my brand new dataset VCR: Visual Commonsense Reasoning, at [visualcommonsense.com](https://visualcommonsense.com)!
This repository contains data and code for the paper [Neural Motifs: Scene Graph Parsing with Global Context (CVPR 2018)](https://arxiv.org/abs/1711.06640v2) For the project page (as well as links to the baseline checkpoints), check out [rowanzellers.com/neuralmotifs](https://rowanzellers.com/neuralmotifs). If the paper significantly inspires you, we request that you cite our work:
### Bibtex
```
@inproceedings{zellers2018scenegraphs,
title={Neural Motifs: Scene Graph Parsing with Global Context},
author={Zellers, Rowan and Yatskar, Mark and Thomson, Sam and Choi, Yejin},
booktitle = "Conference on Computer Vision and Pattern Recognition",
year={2018}
}
```
# Setup
0. Install python3.6 and pytorch 3. I recommend the [Anaconda distribution](https://repo.continuum.io/archive/). To install PyTorch if you haven't already, use
```conda install pytorch=0.3.0 torchvision=0.2.0 cuda90 -c pytorch```.
1. Update the config file with the dataset paths. Specifically:
- Visual Genome (the VG_100K folder, image_data.json, VG-SGG.h5, and VG-SGG-dicts.json). See data/stanford_filtered/README.md for the steps I used to download these.
- You'll also need to fix your PYTHONPATH: ```export PYTHONPATH=/home/rowan/code/scene-graph```
2. Compile everything. run ```make``` in the main directory: this compiles the Bilinear Interpolation operation for the RoIs as well as the Highway LSTM.
3. Pretrain VG detection. The old version involved pretraining COCO as well, but we got rid of that for simplicity. Run ./scripts/pretrain_detector.sh
Note: You might have to modify the learning rate and batch size, particularly if you don't have 3 Titan X GPUs (which is what I used). [You can also download the pretrained detector checkpoint here.](https://drive.google.com/open?id=11zKRr2OF5oclFL47kjFYBOxScotQzArX)
4. Train VG scene graph classification: run ./scripts/train_models_sgcls.sh 2 (will run on GPU 2). OR, download the MotifNet-cls checkpoint here: [Motifnet-SGCls/PredCls](https://drive.google.com/open?id=12qziGKYjFD3LAnoy4zDT3bcg5QLC0qN6).
5. Refine for detection: run ./scripts/refine_for_detection.sh 2 or download the [Motifnet-SGDet](https://drive.google.com/open?id=1thd_5uSamJQaXAPVGVOUZGAOfGCYZYmb) checkpoint.
6. Evaluate: Refer to the scripts ./scripts/eval_models_sg[cls/det].sh.
# help
Feel free to open an issue if you encounter trouble getting it to work!
================================================
FILE: config.py
================================================
"""
Configuration file!
"""
import os
from argparse import ArgumentParser
import numpy as np
ROOT_PATH = os.path.dirname(os.path.realpath(__file__))
DATA_PATH = os.path.join(ROOT_PATH, 'data')
def path(fn):
return os.path.join(DATA_PATH, fn)
def stanford_path(fn):
return os.path.join(DATA_PATH, 'stanford_filtered', fn)
# =============================================================================
# Update these with where your data is stored ~~~~~~~~~~~~~~~~~~~~~~~~~
VG_IMAGES = '/home/rowan/datasets2/VG_100K_2/VG_100K'
RCNN_CHECKPOINT_FN = path('faster_rcnn_500k.h5')
IM_DATA_FN = stanford_path('image_data.json')
VG_SGG_FN = stanford_path('VG-SGG.h5')
VG_SGG_DICT_FN = stanford_path('VG-SGG-dicts.json')
PROPOSAL_FN = stanford_path('proposals.h5')
COCO_PATH = '/home/rowan/datasets/mscoco'
# =============================================================================
# =============================================================================
MODES = ('sgdet', 'sgcls', 'predcls')
BOX_SCALE = 1024 # Scale at which we have the boxes
IM_SCALE = 592 # Our images will be resized to this res without padding
# Proposal assignments
BG_THRESH_HI = 0.5
BG_THRESH_LO = 0.0
RPN_POSITIVE_OVERLAP = 0.7
# IOU < thresh: negative example
RPN_NEGATIVE_OVERLAP = 0.3
# Max number of foreground examples
RPN_FG_FRACTION = 0.5
FG_FRACTION = 0.25
# Total number of examples
RPN_BATCHSIZE = 256
ROIS_PER_IMG = 256
REL_FG_FRACTION = 0.25
RELS_PER_IMG = 256
RELS_PER_IMG_REFINE = 64
BATCHNORM_MOMENTUM = 0.01
ANCHOR_SIZE = 16
ANCHOR_RATIOS = (0.23232838, 0.63365731, 1.28478321, 3.15089189) #(0.5, 1, 2)
ANCHOR_SCALES = (2.22152954, 4.12315647, 7.21692515, 12.60263013, 22.7102731) #(4, 8, 16, 32)
class ModelConfig(object):
"""Wrapper class for model hyperparameters."""
def __init__(self):
"""
Defaults
"""
self.coco = None
self.ckpt = None
self.save_dir = None
self.lr = None
self.batch_size = None
self.val_size = None
self.l2 = None
self.clip = None
self.num_gpus = None
self.num_workers = None
self.print_interval = None
self.gt_box = None
self.mode = None
self.refine = None
self.ad3 = False
self.test = False
self.adam = False
self.multi_pred=False
self.cache = None
self.model = None
self.use_proposals=False
self.use_resnet=False
self.use_tanh=False
self.use_bias = False
self.limit_vision=False
self.num_epochs=None
self.old_feats=False
self.order=None
self.det_ckpt=None
self.nl_edge=None
self.nl_obj=None
self.hidden_dim=None
self.pass_in_obj_feats_to_decoder = None
self.pass_in_obj_feats_to_edge = None
self.pooling_dim = None
self.rec_dropout = None
self.parser = self.setup_parser()
self.args = vars(self.parser.parse_args())
print("~~~~~~~~ Hyperparameters used: ~~~~~~~")
for x, y in self.args.items():
print("{} : {}".format(x, y))
self.__dict__.update(self.args)
if len(self.ckpt) != 0:
self.ckpt = os.path.join(ROOT_PATH, self.ckpt)
else:
self.ckpt = None
if len(self.cache) != 0:
self.cache = os.path.join(ROOT_PATH, self.cache)
else:
self.cache = None
if len(self.save_dir) == 0:
self.save_dir = None
else:
self.save_dir = os.path.join(ROOT_PATH, self.save_dir)
if not os.path.exists(self.save_dir):
os.mkdir(self.save_dir)
assert self.val_size >= 0
if self.mode not in MODES:
raise ValueError("Invalid mode: mode must be in {}".format(MODES))
if self.model not in ('motifnet', 'stanford'):
raise ValueError("Invalid model {}".format(self.model))
if self.ckpt is not None and not os.path.exists(self.ckpt):
raise ValueError("Ckpt file ({}) doesnt exist".format(self.ckpt))
def setup_parser(self):
"""
Sets up an argument parser
:return:
"""
parser = ArgumentParser(description='training code')
# Options to deprecate
parser.add_argument('-coco', dest='coco', help='Use COCO (default to VG)', action='store_true')
parser.add_argument('-ckpt', dest='ckpt', help='Filename to load from', type=str, default='')
parser.add_argument('-det_ckpt', dest='det_ckpt', help='Filename to load detection parameters from', type=str, default='')
parser.add_argument('-save_dir', dest='save_dir',
help='Directory to save things to, such as checkpoints/save', default='', type=str)
parser.add_argument('-ngpu', dest='num_gpus', help='cuantos GPUs tienes', type=int, default=3)
parser.add_argument('-nwork', dest='num_workers', help='num processes to use as workers', type=int, default=1)
parser.add_argument('-lr', dest='lr', help='learning rate', type=float, default=1e-3)
parser.add_argument('-b', dest='batch_size', help='batch size per GPU',type=int, default=2)
parser.add_argument('-val_size', dest='val_size', help='val size to use (if 0 we wont use val)', type=int, default=5000)
parser.add_argument('-l2', dest='l2', help='weight decay', type=float, default=1e-4)
parser.add_argument('-clip', dest='clip', help='gradients will be clipped to have norm less than this', type=float, default=5.0)
parser.add_argument('-p', dest='print_interval', help='print during training', type=int,
default=100)
parser.add_argument('-m', dest='mode', help='mode \in {sgdet, sgcls, predcls}', type=str,
default='sgdet')
parser.add_argument('-model', dest='model', help='which model to use? (motifnet, stanford). If you want to use the baseline (NoContext) model, then pass in motifnet here, and nl_obj, nl_edge=0', type=str,
default='motifnet')
parser.add_argument('-old_feats', dest='old_feats', help='Use the original image features for the edges', action='store_true')
parser.add_argument('-order', dest='order', help='Linearization order for Rois (confidence -default, size, random)',
type=str, default='confidence')
parser.add_argument('-cache', dest='cache', help='where should we cache predictions', type=str,
default='')
parser.add_argument('-gt_box', dest='gt_box', help='use gt boxes during training', action='store_true')
parser.add_argument('-adam', dest='adam', help='use adam. Not recommended', action='store_true')
parser.add_argument('-test', dest='test', help='test set', action='store_true')
parser.add_argument('-multipred', dest='multi_pred', help='Allow multiple predicates per pair of box0, box1.', action='store_true')
parser.add_argument('-nepoch', dest='num_epochs', help='Number of epochs to train the model for',type=int, default=25)
parser.add_argument('-resnet', dest='use_resnet', help='use resnet instead of VGG', action='store_true')
parser.add_argument('-proposals', dest='use_proposals', help='Use Xu et als proposals', action='store_true')
parser.add_argument('-nl_obj', dest='nl_obj', help='Num object layers', type=int, default=1)
parser.add_argument('-nl_edge', dest='nl_edge', help='Num edge layers', type=int, default=2)
parser.add_argument('-hidden_dim', dest='hidden_dim', help='Num edge layers', type=int, default=256)
parser.add_argument('-pooling_dim', dest='pooling_dim', help='Dimension of pooling', type=int, default=4096)
parser.add_argument('-pass_in_obj_feats_to_decoder', dest='pass_in_obj_feats_to_decoder', action='store_true')
parser.add_argument('-pass_in_obj_feats_to_edge', dest='pass_in_obj_feats_to_edge', action='store_true')
parser.add_argument('-rec_dropout', dest='rec_dropout', help='recurrent dropout to add', type=float, default=0.1)
parser.add_argument('-use_bias', dest='use_bias', action='store_true')
parser.add_argument('-use_tanh', dest='use_tanh', action='store_true')
parser.add_argument('-limit_vision', dest='limit_vision', action='store_true')
return parser
================================================
FILE: data/stanford_filtered/README.md
================================================
# Filtered data
Adapted from [Danfei Xu](https://github.com/danfeiX/scene-graph-TF-release/blob/master/data_tools/README.md).
Follow the folling steps to get the dataset set up.
1. Download the VG images [part1](https://cs.stanford.edu/people/rak248/VG_100K_2/images.zip) [part2](https://cs.stanford.edu/people/rak248/VG_100K_2/images2.zip). Extract these images to a file and link to them in `config.py` (eg. currently I have `VG_IMAGES=data/visual_genome/VG_100K`).
2. Download the [VG metadata](http://cvgl.stanford.edu/scene-graph/VG/image_data.json). I recommend extracting it to this directory (e.g. `data/stanford_filtered/image_data.json`), or you can edit the path in `config.py`.
3. Download the [scene graphs](http://cvgl.stanford.edu/scene-graph/dataset/VG-SGG.h5) and extract them to `data/stanford_filtered/VG-SGG.h5`
4. Download the [scene graph dataset metadata](http://cvgl.stanford.edu/scene-graph/dataset/VG-SGG-dicts.json) and extract it to `data/stanford_filtered/VG-SGG-dicts.json`
================================================
FILE: dataloaders/__init__.py
================================================
================================================
FILE: dataloaders/blob.py
================================================
"""
Data blob, hopefully to make collating less painful and MGPU training possible
"""
from lib.fpn.anchor_targets import anchor_target_layer
import numpy as np
import torch
from torch.autograd import Variable
class Blob(object):
def __init__(self, mode='det', is_train=False, num_gpus=1, primary_gpu=0, batch_size_per_gpu=3):
"""
Initializes an empty Blob object.
:param mode: 'det' for detection and 'rel' for det+relationship
:param is_train: True if it's training
"""
assert mode in ('det', 'rel')
assert num_gpus >= 1
self.mode = mode
self.is_train = is_train
self.num_gpus = num_gpus
self.batch_size_per_gpu = batch_size_per_gpu
self.primary_gpu = primary_gpu
self.imgs = [] # [num_images, 3, IM_SCALE, IM_SCALE] array
self.im_sizes = [] # [num_images, 4] array of (h, w, scale, num_valid_anchors)
self.all_anchor_inds = [] # [all_anchors, 2] array of (img_ind, anchor_idx). Only has valid
# boxes (meaning some are gonna get cut out)
self.all_anchors = [] # [num_im, IM_SCALE/4, IM_SCALE/4, num_anchors, 4] shapes. Anchors outside get squashed
# to 0
self.gt_boxes = [] # [num_gt, 4] boxes
self.gt_classes = [] # [num_gt,2] array of img_ind, class
self.gt_rels = [] # [num_rels, 3]. Each row is (gtbox0, gtbox1, rel).
self.gt_sents = []
self.gt_nodes = []
self.sent_lengths = []
self.train_anchor_labels = [] # [train_anchors, 5] array of (img_ind, h, w, A, labels)
self.train_anchors = [] # [train_anchors, 8] shapes with anchor, target
self.train_anchor_inds = None # This will be split into GPUs, just (img_ind, h, w, A).
self.batch_size = None
self.gt_box_chunks = None
self.anchor_chunks = None
self.train_chunks = None
self.proposal_chunks = None
self.proposals = []
@property
def is_flickr(self):
return self.mode == 'flickr'
@property
def is_rel(self):
return self.mode == 'rel'
@property
def volatile(self):
return not self.is_train
def append(self, d):
"""
Adds a single image to the blob
:param datom:
:return:
"""
i = len(self.imgs)
self.imgs.append(d['img'])
h, w, scale = d['img_size']
# all anchors
self.im_sizes.append((h, w, scale))
gt_boxes_ = d['gt_boxes'].astype(np.float32) * d['scale']
self.gt_boxes.append(gt_boxes_)
self.gt_classes.append(np.column_stack((
i * np.ones(d['gt_classes'].shape[0], dtype=np.int64),
d['gt_classes'],
)))
# Add relationship info
if self.is_rel:
self.gt_rels.append(np.column_stack((
i * np.ones(d['gt_relations'].shape[0], dtype=np.int64),
d['gt_relations'])))
# Augment with anchor targets
if self.is_train:
train_anchors_, train_anchor_inds_, train_anchor_targets_, train_anchor_labels_ = \
anchor_target_layer(gt_boxes_, (h, w))
self.train_anchors.append(np.hstack((train_anchors_, train_anchor_targets_)))
self.train_anchor_labels.append(np.column_stack((
i * np.ones(train_anchor_inds_.shape[0], dtype=np.int64),
train_anchor_inds_,
train_anchor_labels_,
)))
if 'proposals' in d:
self.proposals.append(np.column_stack((i * np.ones(d['proposals'].shape[0], dtype=np.float32),
d['scale'] * d['proposals'].astype(np.float32))))
def _chunkize(self, datom, tensor=torch.LongTensor):
"""
Turn data list into chunks, one per GPU
:param datom: List of lists of numpy arrays that will be concatenated.
:return:
"""
chunk_sizes = [0] * self.num_gpus
for i in range(self.num_gpus):
for j in range(self.batch_size_per_gpu):
chunk_sizes[i] += datom[i * self.batch_size_per_gpu + j].shape[0]
return Variable(tensor(np.concatenate(datom, 0)), volatile=self.volatile), chunk_sizes
def reduce(self):
""" Merges all the detections into flat lists + numbers of how many are in each"""
if len(self.imgs) != self.batch_size_per_gpu * self.num_gpus:
raise ValueError("Wrong batch size? imgs len {} bsize/gpu {} numgpus {}".format(
len(self.imgs), self.batch_size_per_gpu, self.num_gpus
))
self.imgs = Variable(torch.stack(self.imgs, 0), volatile=self.volatile)
self.im_sizes = np.stack(self.im_sizes).reshape(
(self.num_gpus, self.batch_size_per_gpu, 3))
if self.is_rel:
self.gt_rels, self.gt_rel_chunks = self._chunkize(self.gt_rels)
self.gt_boxes, self.gt_box_chunks = self._chunkize(self.gt_boxes, tensor=torch.FloatTensor)
self.gt_classes, _ = self._chunkize(self.gt_classes)
if self.is_train:
self.train_anchor_labels, self.train_chunks = self._chunkize(self.train_anchor_labels)
self.train_anchors, _ = self._chunkize(self.train_anchors, tensor=torch.FloatTensor)
self.train_anchor_inds = self.train_anchor_labels[:, :-1].contiguous()
if len(self.proposals) != 0:
self.proposals, self.proposal_chunks = self._chunkize(self.proposals, tensor=torch.FloatTensor)
def _scatter(self, x, chunk_sizes, dim=0):
""" Helper function"""
if self.num_gpus == 1:
return x.cuda(self.primary_gpu, async=True)
return torch.nn.parallel.scatter_gather.Scatter.apply(
list(range(self.num_gpus)), chunk_sizes, dim, x)
def scatter(self):
""" Assigns everything to the GPUs"""
self.imgs = self._scatter(self.imgs, [self.batch_size_per_gpu] * self.num_gpus)
self.gt_classes_primary = self.gt_classes.cuda(self.primary_gpu, async=True)
self.gt_boxes_primary = self.gt_boxes.cuda(self.primary_gpu, async=True)
# Predcls might need these
self.gt_classes = self._scatter(self.gt_classes, self.gt_box_chunks)
self.gt_boxes = self._scatter(self.gt_boxes, self.gt_box_chunks)
if self.is_train:
self.train_anchor_inds = self._scatter(self.train_anchor_inds,
self.train_chunks)
self.train_anchor_labels = self.train_anchor_labels.cuda(self.primary_gpu, async=True)
self.train_anchors = self.train_anchors.cuda(self.primary_gpu, async=True)
if self.is_rel:
self.gt_rels = self._scatter(self.gt_rels, self.gt_rel_chunks)
else:
if self.is_rel:
self.gt_rels = self.gt_rels.cuda(self.primary_gpu, async=True)
if self.proposal_chunks is not None:
self.proposals = self._scatter(self.proposals, self.proposal_chunks)
def __getitem__(self, index):
"""
Returns a tuple containing data
:param index: Which GPU we're on, or 0 if no GPUs
:return: If training:
(image, im_size, img_start_ind, anchor_inds, anchors, gt_boxes, gt_classes,
train_anchor_inds)
test:
(image, im_size, img_start_ind, anchor_inds, anchors)
"""
if index not in list(range(self.num_gpus)):
raise ValueError("Out of bounds with index {} and {} gpus".format(index, self.num_gpus))
if self.is_rel:
rels = self.gt_rels
if index > 0 or self.num_gpus != 1:
rels_i = rels[index] if self.is_rel else None
elif self.is_flickr:
rels = (self.gt_sents, self.gt_nodes)
if index > 0 or self.num_gpus != 1:
rels_i = (self.gt_sents[index], self.gt_nodes[index])
else:
rels = None
rels_i = None
if self.proposal_chunks is None:
proposals = None
else:
proposals = self.proposals
if index == 0 and self.num_gpus == 1:
image_offset = 0
if self.is_train:
return (self.imgs, self.im_sizes[0], image_offset,
self.gt_boxes, self.gt_classes, rels, proposals, self.train_anchor_inds)
return self.imgs, self.im_sizes[0], image_offset, self.gt_boxes, self.gt_classes, rels, proposals
# Otherwise proposals is None
assert proposals is None
image_offset = self.batch_size_per_gpu * index
# TODO: Return a namedtuple
if self.is_train:
return (
self.imgs[index], self.im_sizes[index], image_offset,
self.gt_boxes[index], self.gt_classes[index], rels_i, None, self.train_anchor_inds[index])
return (self.imgs[index], self.im_sizes[index], image_offset,
self.gt_boxes[index], self.gt_classes[index], rels_i, None)
================================================
FILE: dataloaders/image_transforms.py
================================================
# Some image transforms
from PIL import Image, ImageOps, ImageFilter, ImageEnhance
import numpy as np
from random import randint
# All of these need to be called on PIL imagez
class SquarePad(object):
def __call__(self, img):
w, h = img.size
img_padded = ImageOps.expand(img, border=(0, 0, max(h - w, 0), max(w - h, 0)),
fill=(int(0.485 * 256), int(0.456 * 256), int(0.406 * 256)))
return img_padded
class Grayscale(object):
"""
Converts to grayscale (not always, sometimes).
"""
def __call__(self, img):
factor = np.sqrt(np.sqrt(np.random.rand(1)))
# print("gray {}".format(factor))
enhancer = ImageEnhance.Color(img)
return enhancer.enhance(factor)
class Brightness(object):
"""
Converts to grayscale (not always, sometimes).
"""
def __call__(self, img):
factor = np.random.randn(1)/6+1
factor = min(max(factor, 0.5), 1.5)
# print("brightness {}".format(factor))
enhancer = ImageEnhance.Brightness(img)
return enhancer.enhance(factor)
class Contrast(object):
"""
Converts to grayscale (not always, sometimes).
"""
def __call__(self, img):
factor = np.random.randn(1)/8+1.0
factor = min(max(factor, 0.5), 1.5)
# print("contrast {}".format(factor))
enhancer = ImageEnhance.Contrast(img)
return enhancer.enhance(factor)
class Hue(object):
"""
Converts to grayscale
"""
def __call__(self, img):
# 30 seems good
factor = int(np.random.randn(1)*8)
factor = min(max(factor, -30), 30)
factor = np.array(factor, dtype=np.uint8)
hsv = np.array(img.convert('HSV'))
hsv[:,:,0] += factor
new_img = Image.fromarray(hsv, 'HSV').convert('RGB')
return new_img
class Sharpness(object):
"""
Converts to grayscale
"""
def __call__(self, img):
factor = 1.0 + np.random.randn(1)/5
# print("sharpness {}".format(factor))
enhancer = ImageEnhance.Sharpness(img)
return enhancer.enhance(factor)
def random_crop(img, boxes, box_scale, round_boxes=True, max_crop_fraction=0.1):
"""
Randomly crops the image
:param img: PIL image
:param boxes: Ground truth boxes
:param box_scale: This is the scale that the boxes are at (e.g. 1024 wide). We'll preserve that ratio
:param round_boxes: Set this to true if we're going to round the boxes to ints
:return: Cropped image, new boxes
"""
w, h = img.size
max_crop_w = int(w*max_crop_fraction)
max_crop_h = int(h*max_crop_fraction)
boxes_scaled = boxes * max(w,h) / box_scale
max_to_crop_top = min(int(boxes_scaled[:, 1].min()), max_crop_h)
max_to_crop_left = min(int(boxes_scaled[:, 0].min()), max_crop_w)
max_to_crop_right = min(int(w - boxes_scaled[:, 2].max()), max_crop_w)
max_to_crop_bottom = min(int(h - boxes_scaled[:, 3].max()), max_crop_h)
crop_top = randint(0, max(max_to_crop_top, 0))
crop_left = randint(0, max(max_to_crop_left, 0))
crop_right = randint(0, max(max_to_crop_right, 0))
crop_bottom = randint(0, max(max_to_crop_bottom, 0))
img_cropped = img.crop((crop_left, crop_top, w - crop_right, h - crop_bottom))
new_boxes = box_scale / max(img_cropped.size) * np.column_stack(
(boxes_scaled[:,0]-crop_left, boxes_scaled[:,1]-crop_top, boxes_scaled[:,2]-crop_left, boxes_scaled[:,3]-crop_top))
if round_boxes:
new_boxes = np.round(new_boxes).astype(np.int32)
return img_cropped, new_boxes
class RandomOrder(object):
""" Composes several transforms together in random order - or not at all!
"""
def __init__(self, transforms):
self.transforms = transforms
def __call__(self, img):
if self.transforms is None:
return img
num_to_pick = np.random.choice(len(self.transforms))
if num_to_pick == 0:
return img
order = np.random.choice(len(self.transforms), size=num_to_pick, replace=False)
for i in order:
img = self.transforms[i](img)
return img
================================================
FILE: dataloaders/mscoco.py
================================================
from config import COCO_PATH, IM_SCALE, BOX_SCALE
import os
from torch.utils.data import Dataset
from pycocotools.coco import COCO
from PIL import Image
from lib.fpn.anchor_targets import anchor_target_layer
from torchvision.transforms import Resize, Compose, ToTensor, Normalize
from dataloaders.image_transforms import SquarePad, Grayscale, Brightness, Sharpness, Contrast, RandomOrder, Hue, random_crop
import numpy as np
from dataloaders.blob import Blob
import torch
class CocoDetection(Dataset):
"""
Adapted from the torchvision code
"""
def __init__(self, mode):
"""
:param mode: train2014 or val2014
"""
self.mode = mode
self.root = os.path.join(COCO_PATH, mode)
self.ann_file = os.path.join(COCO_PATH, 'annotations', 'instances_{}.json'.format(mode))
self.coco = COCO(self.ann_file)
self.ids = [k for k in self.coco.imgs.keys() if len(self.coco.imgToAnns[k]) > 0]
tform = []
if self.is_train:
tform.append(RandomOrder([
Grayscale(),
Brightness(),
Contrast(),
Sharpness(),
Hue(),
]))
tform += [
SquarePad(),
Resize(IM_SCALE),
ToTensor(),
Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
]
self.transform_pipeline = Compose(tform)
self.ind_to_classes = ['__background__'] + [v['name'] for k, v in self.coco.cats.items()]
# COCO inds are weird (84 inds in total but a bunch of numbers are skipped)
self.id_to_ind = {coco_id:(ind+1) for ind, coco_id in enumerate(self.coco.cats.keys())}
self.id_to_ind[0] = 0
self.ind_to_id = {x:y for y,x in self.id_to_ind.items()}
@property
def is_train(self):
return self.mode.startswith('train')
def __getitem__(self, index):
"""
Args:
index (int): Index
Returns: entry dict
"""
img_id = self.ids[index]
path = self.coco.loadImgs(img_id)[0]['file_name']
image_unpadded = Image.open(os.path.join(self.root, path)).convert('RGB')
ann_ids = self.coco.getAnnIds(imgIds=img_id)
anns = self.coco.loadAnns(ann_ids)
gt_classes = np.array([self.id_to_ind[x['category_id']] for x in anns], dtype=np.int64)
if np.any(gt_classes >= len(self.ind_to_classes)):
raise ValueError("OH NO {}".format(index))
if len(anns) == 0:
raise ValueError("Annotations should not be empty")
# gt_boxes = np.array((0, 4), dtype=np.float32)
# else:
gt_boxes = np.array([x['bbox'] for x in anns], dtype=np.float32)
if np.any(gt_boxes[:, [0,1]] < 0):
raise ValueError("GT boxes empty columns")
if np.any(gt_boxes[:, [2,3]] < 0):
raise ValueError("GT boxes empty h/w")
gt_boxes[:, [2, 3]] += gt_boxes[:, [0, 1]]
# Rescale so that the boxes are at BOX_SCALE
if self.is_train:
image_unpadded, gt_boxes = random_crop(image_unpadded,
gt_boxes * BOX_SCALE / max(image_unpadded.size),
BOX_SCALE,
round_boxes=False,
)
else:
# Seems a bit silly because we won't be using GT boxes then but whatever
gt_boxes = gt_boxes * BOX_SCALE / max(image_unpadded.size)
w, h = image_unpadded.size
box_scale_factor = BOX_SCALE / max(w, h)
# Optionally flip the image if we're doing training
flipped = self.is_train and np.random.random() > 0.5
if flipped:
scaled_w = int(box_scale_factor * float(w))
image_unpadded = image_unpadded.transpose(Image.FLIP_LEFT_RIGHT)
gt_boxes[:, [0, 2]] = scaled_w - gt_boxes[:, [2, 0]]
img_scale_factor = IM_SCALE / max(w, h)
if h > w:
im_size = (IM_SCALE, int(w*img_scale_factor), img_scale_factor)
elif h < w:
im_size = (int(h*img_scale_factor), IM_SCALE, img_scale_factor)
else:
im_size = (IM_SCALE, IM_SCALE, img_scale_factor)
entry = {
'img': self.transform_pipeline(image_unpadded),
'img_size': im_size,
'gt_boxes': gt_boxes,
'gt_classes': gt_classes,
'scale': IM_SCALE / BOX_SCALE,
'index': index,
'image_id': img_id,
'flipped': flipped,
'fn': path,
}
return entry
@classmethod
def splits(cls, *args, **kwargs):
""" Helper method to generate splits of the dataset"""
train = cls('train2014', *args, **kwargs)
val = cls('val2014', *args, **kwargs)
return train, val
def __len__(self):
return len(self.ids)
def coco_collate(data, num_gpus=3, is_train=False):
blob = Blob(mode='det', is_train=is_train, num_gpus=num_gpus,
batch_size_per_gpu=len(data) // num_gpus)
for d in data:
blob.append(d)
blob.reduce()
return blob
class CocoDataLoader(torch.utils.data.DataLoader):
"""
Iterates through the data, filtering out None,
but also loads everything as a (cuda) variable
"""
# def __iter__(self):
# for x in super(CocoDataLoader, self).__iter__():
# if isinstance(x, tuple) or isinstance(x, list):
# yield tuple(y.cuda(async=True) if hasattr(y, 'cuda') else y for y in x)
# else:
# yield x.cuda(async=True)
@classmethod
def splits(cls, train_data, val_data, batch_size=3, num_workers=1, num_gpus=3, **kwargs):
train_load = cls(
dataset=train_data,
batch_size=batch_size*num_gpus,
shuffle=True,
num_workers=num_workers,
collate_fn=lambda x: coco_collate(x, num_gpus=num_gpus, is_train=True),
drop_last=True,
# pin_memory=True,
**kwargs,
)
val_load = cls(
dataset=val_data,
batch_size=batch_size*num_gpus,
shuffle=False,
num_workers=num_workers,
collate_fn=lambda x: coco_collate(x, num_gpus=num_gpus, is_train=False),
drop_last=True,
# pin_memory=True,
**kwargs,
)
return train_load, val_load
if __name__ == '__main__':
train, val = CocoDetection.splits()
gtbox = train[0]['gt_boxes']
img_size = train[0]['img_size']
anchor_strides, labels, bbox_targets = anchor_target_layer(gtbox, img_size)
================================================
FILE: dataloaders/visual_genome.py
================================================
"""
File that involves dataloaders for the Visual Genome dataset.
"""
import json
import os
import h5py
import numpy as np
import torch
from PIL import Image
from torch.utils.data import Dataset
from torchvision.transforms import Resize, Compose, ToTensor, Normalize
from dataloaders.blob import Blob
from lib.fpn.box_intersections_cpu.bbox import bbox_overlaps
from config import VG_IMAGES, IM_DATA_FN, VG_SGG_FN, VG_SGG_DICT_FN, BOX_SCALE, IM_SCALE, PROPOSAL_FN
from dataloaders.image_transforms import SquarePad, Grayscale, Brightness, Sharpness, Contrast, \
RandomOrder, Hue, random_crop
from collections import defaultdict
from pycocotools.coco import COCO
class VG(Dataset):
def __init__(self, mode, roidb_file=VG_SGG_FN, dict_file=VG_SGG_DICT_FN,
image_file=IM_DATA_FN, filter_empty_rels=True, num_im=-1, num_val_im=5000,
filter_duplicate_rels=True, filter_non_overlap=True,
use_proposals=False):
"""
Torch dataset for VisualGenome
:param mode: Must be train, test, or val
:param roidb_file: HDF5 containing the GT boxes, classes, and relationships
:param dict_file: JSON Contains mapping of classes/relationships to words
:param image_file: HDF5 containing image filenames
:param filter_empty_rels: True if we filter out images without relationships between
boxes. One might want to set this to false if training a detector.
:param filter_duplicate_rels: Whenever we see a duplicate relationship we'll sample instead
:param num_im: Number of images in the entire dataset. -1 for all images.
:param num_val_im: Number of images in the validation set (must be less than num_im
unless num_im is -1.)
:param proposal_file: If None, we don't provide proposals. Otherwise file for where we get RPN
proposals
"""
if mode not in ('test', 'train', 'val'):
raise ValueError("Mode must be in test, train, or val. Supplied {}".format(mode))
self.mode = mode
# Initialize
self.roidb_file = roidb_file
self.dict_file = dict_file
self.image_file = image_file
self.filter_non_overlap = filter_non_overlap
self.filter_duplicate_rels = filter_duplicate_rels and self.mode == 'train'
self.split_mask, self.gt_boxes, self.gt_classes, self.relationships = load_graphs(
self.roidb_file, self.mode, num_im, num_val_im=num_val_im,
filter_empty_rels=filter_empty_rels,
filter_non_overlap=self.filter_non_overlap and self.is_train,
)
self.filenames = load_image_filenames(image_file)
self.filenames = [self.filenames[i] for i in np.where(self.split_mask)[0]]
self.ind_to_classes, self.ind_to_predicates = load_info(dict_file)
if use_proposals:
print("Loading proposals", flush=True)
p_h5 = h5py.File(PROPOSAL_FN, 'r')
rpn_rois = p_h5['rpn_rois']
rpn_scores = p_h5['rpn_scores']
rpn_im_to_roi_idx = np.array(p_h5['im_to_roi_idx'][self.split_mask])
rpn_num_rois = np.array(p_h5['num_rois'][self.split_mask])
self.rpn_rois = []
for i in range(len(self.filenames)):
rpn_i = np.column_stack((
rpn_scores[rpn_im_to_roi_idx[i]:rpn_im_to_roi_idx[i] + rpn_num_rois[i]],
rpn_rois[rpn_im_to_roi_idx[i]:rpn_im_to_roi_idx[i] + rpn_num_rois[i]],
))
self.rpn_rois.append(rpn_i)
else:
self.rpn_rois = None
# You could add data augmentation here. But we didn't.
# tform = []
# if self.is_train:
# tform.append(RandomOrder([
# Grayscale(),
# Brightness(),
# Contrast(),
# Sharpness(),
# Hue(),
# ]))
tform = [
SquarePad(),
Resize(IM_SCALE),
ToTensor(),
Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
]
self.transform_pipeline = Compose(tform)
@property
def coco(self):
"""
:return: a Coco-like object that we can use to evaluate detection!
"""
anns = []
for i, (cls_array, box_array) in enumerate(zip(self.gt_classes, self.gt_boxes)):
for cls, box in zip(cls_array.tolist(), box_array.tolist()):
anns.append({
'area': (box[3] - box[1] + 1) * (box[2] - box[0] + 1),
'bbox': [box[0], box[1], box[2] - box[0] + 1, box[3] - box[1] + 1],
'category_id': cls,
'id': len(anns),
'image_id': i,
'iscrowd': 0,
})
fauxcoco = COCO()
fauxcoco.dataset = {
'info': {'description': 'ayy lmao'},
'images': [{'id': i} for i in range(self.__len__())],
'categories': [{'supercategory': 'person',
'id': i, 'name': name} for i, name in enumerate(self.ind_to_classes) if name != '__background__'],
'annotations': anns,
}
fauxcoco.createIndex()
return fauxcoco
@property
def is_train(self):
return self.mode.startswith('train')
@classmethod
def splits(cls, *args, **kwargs):
""" Helper method to generate splits of the dataset"""
train = cls('train', *args, **kwargs)
val = cls('val', *args, **kwargs)
test = cls('test', *args, **kwargs)
return train, val, test
def __getitem__(self, index):
image_unpadded = Image.open(self.filenames[index]).convert('RGB')
# Optionally flip the image if we're doing training
flipped = self.is_train and np.random.random() > 0.5
gt_boxes = self.gt_boxes[index].copy()
# Boxes are already at BOX_SCALE
if self.is_train:
# crop boxes that are too large. This seems to be only a problem for image heights, but whatevs
gt_boxes[:, [1, 3]] = gt_boxes[:, [1, 3]].clip(
None, BOX_SCALE / max(image_unpadded.size) * image_unpadded.size[1])
gt_boxes[:, [0, 2]] = gt_boxes[:, [0, 2]].clip(
None, BOX_SCALE / max(image_unpadded.size) * image_unpadded.size[0])
# # crop the image for data augmentation
# image_unpadded, gt_boxes = random_crop(image_unpadded, gt_boxes, BOX_SCALE, round_boxes=True)
w, h = image_unpadded.size
box_scale_factor = BOX_SCALE / max(w, h)
if flipped:
scaled_w = int(box_scale_factor * float(w))
# print("Scaled w is {}".format(scaled_w))
image_unpadded = image_unpadded.transpose(Image.FLIP_LEFT_RIGHT)
gt_boxes[:, [0, 2]] = scaled_w - gt_boxes[:, [2, 0]]
img_scale_factor = IM_SCALE / max(w, h)
if h > w:
im_size = (IM_SCALE, int(w * img_scale_factor), img_scale_factor)
elif h < w:
im_size = (int(h * img_scale_factor), IM_SCALE, img_scale_factor)
else:
im_size = (IM_SCALE, IM_SCALE, img_scale_factor)
gt_rels = self.relationships[index].copy()
if self.filter_duplicate_rels:
# Filter out dupes!
assert self.mode == 'train'
old_size = gt_rels.shape[0]
all_rel_sets = defaultdict(list)
for (o0, o1, r) in gt_rels:
all_rel_sets[(o0, o1)].append(r)
gt_rels = [(k[0], k[1], np.random.choice(v)) for k,v in all_rel_sets.items()]
gt_rels = np.array(gt_rels)
entry = {
'img': self.transform_pipeline(image_unpadded),
'img_size': im_size,
'gt_boxes': gt_boxes,
'gt_classes': self.gt_classes[index].copy(),
'gt_relations': gt_rels,
'scale': IM_SCALE / BOX_SCALE, # Multiply the boxes by this.
'index': index,
'flipped': flipped,
'fn': self.filenames[index],
}
if self.rpn_rois is not None:
entry['proposals'] = self.rpn_rois[index]
assertion_checks(entry)
return entry
def __len__(self):
return len(self.filenames)
@property
def num_predicates(self):
return len(self.ind_to_predicates)
@property
def num_classes(self):
return len(self.ind_to_classes)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# MISC. HELPER FUNCTIONS ~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def assertion_checks(entry):
im_size = tuple(entry['img'].size())
if len(im_size) != 3:
raise ValueError("Img must be dim-3")
c, h, w = entry['img'].size()
if c != 3:
raise ValueError("Must have 3 color channels")
num_gt = entry['gt_boxes'].shape[0]
if entry['gt_classes'].shape[0] != num_gt:
raise ValueError("GT classes and GT boxes must have same number of examples")
assert (entry['gt_boxes'][:, 2] >= entry['gt_boxes'][:, 0]).all()
assert (entry['gt_boxes'] >= -1).all()
def load_image_filenames(image_file, image_dir=VG_IMAGES):
"""
Loads the image filenames from visual genome from the JSON file that contains them.
This matches the preprocessing in scene-graph-TF-release/data_tools/vg_to_imdb.py.
:param image_file: JSON file. Elements contain the param "image_id".
:param image_dir: directory where the VisualGenome images are located
:return: List of filenames corresponding to the good images
"""
with open(image_file, 'r') as f:
im_data = json.load(f)
corrupted_ims = ['1592.jpg', '1722.jpg', '4616.jpg', '4617.jpg']
fns = []
for i, img in enumerate(im_data):
basename = '{}.jpg'.format(img['image_id'])
if basename in corrupted_ims:
continue
filename = os.path.join(image_dir, basename)
if os.path.exists(filename):
fns.append(filename)
assert len(fns) == 108073
return fns
def load_graphs(graphs_file, mode='train', num_im=-1, num_val_im=0, filter_empty_rels=True,
filter_non_overlap=False):
"""
Load the file containing the GT boxes and relations, as well as the dataset split
:param graphs_file: HDF5
:param mode: (train, val, or test)
:param num_im: Number of images we want
:param num_val_im: Number of validation images
:param filter_empty_rels: (will be filtered otherwise.)
:param filter_non_overlap: If training, filter images that dont overlap.
:return: image_index: numpy array corresponding to the index of images we're using
boxes: List where each element is a [num_gt, 4] array of ground
truth boxes (x1, y1, x2, y2)
gt_classes: List where each element is a [num_gt] array of classes
relationships: List where each element is a [num_r, 3] array of
(box_ind_1, box_ind_2, predicate) relationships
"""
if mode not in ('train', 'val', 'test'):
raise ValueError('{} invalid'.format(mode))
roi_h5 = h5py.File(graphs_file, 'r')
data_split = roi_h5['split'][:]
split = 2 if mode == 'test' else 0
split_mask = data_split == split
# Filter out images without bounding boxes
split_mask &= roi_h5['img_to_first_box'][:] >= 0
if filter_empty_rels:
split_mask &= roi_h5['img_to_first_rel'][:] >= 0
image_index = np.where(split_mask)[0]
if num_im > -1:
image_index = image_index[:num_im]
if num_val_im > 0:
if mode == 'val':
image_index = image_index[:num_val_im]
elif mode == 'train':
image_index = image_index[num_val_im:]
split_mask = np.zeros_like(data_split).astype(bool)
split_mask[image_index] = True
# Get box information
all_labels = roi_h5['labels'][:, 0]
all_boxes = roi_h5['boxes_{}'.format(BOX_SCALE)][:] # will index later
assert np.all(all_boxes[:, :2] >= 0) # sanity check
assert np.all(all_boxes[:, 2:] > 0) # no empty box
# convert from xc, yc, w, h to x1, y1, x2, y2
all_boxes[:, :2] = all_boxes[:, :2] - all_boxes[:, 2:] / 2
all_boxes[:, 2:] = all_boxes[:, :2] + all_boxes[:, 2:]
im_to_first_box = roi_h5['img_to_first_box'][split_mask]
im_to_last_box = roi_h5['img_to_last_box'][split_mask]
im_to_first_rel = roi_h5['img_to_first_rel'][split_mask]
im_to_last_rel = roi_h5['img_to_last_rel'][split_mask]
# load relation labels
_relations = roi_h5['relationships'][:]
_relation_predicates = roi_h5['predicates'][:, 0]
assert (im_to_first_rel.shape[0] == im_to_last_rel.shape[0])
assert (_relations.shape[0] == _relation_predicates.shape[0]) # sanity check
# Get everything by image.
boxes = []
gt_classes = []
relationships = []
for i in range(len(image_index)):
boxes_i = all_boxes[im_to_first_box[i]:im_to_last_box[i] + 1, :]
gt_classes_i = all_labels[im_to_first_box[i]:im_to_last_box[i] + 1]
if im_to_first_rel[i] >= 0:
predicates = _relation_predicates[im_to_first_rel[i]:im_to_last_rel[i] + 1]
obj_idx = _relations[im_to_first_rel[i]:im_to_last_rel[i] + 1] - im_to_first_box[i]
assert np.all(obj_idx >= 0)
assert np.all(obj_idx < boxes_i.shape[0])
rels = np.column_stack((obj_idx, predicates))
else:
assert not filter_empty_rels
rels = np.zeros((0, 3), dtype=np.int32)
if filter_non_overlap:
assert mode == 'train'
inters = bbox_overlaps(boxes_i, boxes_i)
rel_overs = inters[rels[:, 0], rels[:, 1]]
inc = np.where(rel_overs > 0.0)[0]
if inc.size > 0:
rels = rels[inc]
else:
split_mask[image_index[i]] = 0
continue
boxes.append(boxes_i)
gt_classes.append(gt_classes_i)
relationships.append(rels)
return split_mask, boxes, gt_classes, relationships
def load_info(info_file):
"""
Loads the file containing the visual genome label meanings
:param info_file: JSON
:return: ind_to_classes: sorted list of classes
ind_to_predicates: sorted list of predicates
"""
info = json.load(open(info_file, 'r'))
info['label_to_idx']['__background__'] = 0
info['predicate_to_idx']['__background__'] = 0
class_to_ind = info['label_to_idx']
predicate_to_ind = info['predicate_to_idx']
ind_to_classes = sorted(class_to_ind, key=lambda k: class_to_ind[k])
ind_to_predicates = sorted(predicate_to_ind, key=lambda k: predicate_to_ind[k])
return ind_to_classes, ind_to_predicates
def vg_collate(data, num_gpus=3, is_train=False, mode='det'):
assert mode in ('det', 'rel')
blob = Blob(mode=mode, is_train=is_train, num_gpus=num_gpus,
batch_size_per_gpu=len(data) // num_gpus)
for d in data:
blob.append(d)
blob.reduce()
return blob
class VGDataLoader(torch.utils.data.DataLoader):
"""
Iterates through the data, filtering out None,
but also loads everything as a (cuda) variable
"""
@classmethod
def splits(cls, train_data, val_data, batch_size=3, num_workers=1, num_gpus=3, mode='det',
**kwargs):
assert mode in ('det', 'rel')
train_load = cls(
dataset=train_data,
batch_size=batch_size * num_gpus,
shuffle=True,
num_workers=num_workers,
collate_fn=lambda x: vg_collate(x, mode=mode, num_gpus=num_gpus, is_train=True),
drop_last=True,
# pin_memory=True,
**kwargs,
)
val_load = cls(
dataset=val_data,
batch_size=batch_size * num_gpus if mode=='det' else num_gpus,
shuffle=False,
num_workers=num_workers,
collate_fn=lambda x: vg_collate(x, mode=mode, num_gpus=num_gpus, is_train=False),
drop_last=True,
# pin_memory=True,
**kwargs,
)
return train_load, val_load
================================================
FILE: docs/LICENSE.md
================================================
MIT License
Copyright (c) 2017 Heiswayi Nrird
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: docs/_config.yaml
================================================
exclude: [README.md, LICENSE.md]
defaults:
- values:
layout: default
================================================
FILE: docs/_includes/image.html
================================================
<div class="image-wrapper">
<img src="{{ include.url }}" alt="{{ include.description }}" />
</div>
================================================
FILE: docs/_layouts/default.html
================================================
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>{{ page.title }}</title>
<meta name="author" content="{{ page.author }}">
<meta name="description" content="{{ page.description }}">
<meta name="keywords" content="{{ page.keywords }}">
<link href="https://fonts.googleapis.com/css?family=Bungee+Shade|Droid+Sans" rel="stylesheet">
<style type="text/css">
a {
color: #357edd;
}
a:hover {
color: #e7040f;
}
body {
font-size: 1.1em;
line-height: 1.2em;
margin: auto;
max-width: 700px;
width: 90%;
font-family: 'Droid Sans', sans-serif;
}
h1,
h2 {
letter-spacing: -.028em;
margin-top: 1em;
line-height: 2em;
}
pre,
code {
font-size: .9em;
font-family: Monaco, 'Lucida Console', monospace;
color: #f14e32;
}
pre {
overflow-x: auto;
margin: 0 0 2em 0;
}
.image-wrapper{
max-width:90%;
height:auto;
position: relative;
display:block;
margin:0 auto;
}
.image-wrapper img{
max-width:100% !important;
height:auto;
display:block;
}
/*.site-title {*/
/*font-family: 'Bungee Shade', cursive;*/
/*}*/
</style>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ page.google_analytics_id }}']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<!--<h1 class="site-title">{{ page.title }}</h1>-->
{{ content }}
</body>
</html>
================================================
FILE: docs/index.md
================================================
---
permalink: /
title: Neural Motifs
author: Rowan Zellers
description: Scene Graph Parsing with Global Context (CVPR 2018)
google_analytics_id: UA-84290243-3
---
# Neural Motifs: Scene Graph Parsing with Global Context (CVPR 2018)
### by [Rowan Zellers](https://rowanzellers.com), [Mark Yatskar](https://homes.cs.washington.edu/~my89/), [Sam Thomson](https://http://samthomson.com/), [Yejin Choi](https://homes.cs.washington.edu/~yejin/)
{% include image.html url="teaser.png" description="teaser" %}
# Overview
* In this work, we investigate the problem of producing structured graph representations of visual scenes. Similar to object detection, we must predict a box around each object. Here, we also need to predict an edge (with one of several labels, possibly `background`) between every ordered pair of boxes, producing a directed graph where the edges hopefully represent the semantics and interactions present in the scene.
* We present an analysis of the [Visual Genome Scene Graphs dataset](http://visualgenome.org/). In particular:
* Object labels (e.g. person, shirt) are highly predictive of edge labels (e.g. wearing), but **not vice versa**.
* Over 90% of the edges in the dataset are non-semantic.
* There is a significant amount of structure in the dataset, in the form of graph motifs (regularly appearing substructures).
* Motivated by our analysis, we present a simple baseline that outperforms previous approaches.
* We introduce Stacked Motif Networks (MotifNet), which is a novel architecture that is designed to capture higher order motifs in scene graphs. In doing so, it achieves a sizeable performance gain over prior state-of-the-art.
# Read the paper!
The old version of the paper is available at [arxiv link](https://arxiv.org/abs/1711.06640) - camera ready version coming soon!
# Bibtex
```
@inproceedings{zellers2018scenegraphs,
title={Neural Motifs: Scene Graph Parsing with Global Context},
author={Zellers, Rowan and Yatskar, Mark and Thomson, Sam and Choi, Yejin},
booktitle = "Conference on Computer Vision and Pattern Recognition",
year={2018}
}
```
# View some examples!
Check out [this tool](https://rowanzellers.com/scenegraph2/) I made to visualize the scene graph predictions. Disclaimer: the predictions are from an earlier version of the model, but hopefully they're still helpful!
# Code
Visit the [`neural-motifs` GitHub repository](https://github.com/rowanz/neural-motifs) for our reference implementation and instructions for running our code.
It is released under the MIT license.
# Checkpoints available for download
* [Pretrained Detector](https://drive.google.com/open?id=11zKRr2OF5oclFL47kjFYBOxScotQzArX)
* [Motifnet-SGDet](https://drive.google.com/open?id=1thd_5uSamJQaXAPVGVOUZGAOfGCYZYmb)
* [Motifnet-SGCls/PredCls](https://drive.google.com/open?id=12qziGKYjFD3LAnoy4zDT3bcg5QLC0qN6)
# questions?
Feel free to get in touch! My main website is at [rowanzellers.com](https://rowanzellers.com)
================================================
FILE: docs/upload.sh
================================================
#!/usr/bin/env bash
scp -r _site/* USERNAME@SITE:~/rowanzellers.com/neuralmotifs
================================================
FILE: lib/__init__.py
================================================
================================================
FILE: lib/draw_rectangles/draw_rectangles.c
================================================
/* Generated by Cython 0.25.2 */
/* BEGIN: Cython Metadata
{
"distutils": {
"depends": []
},
"module_name": "draw_rectangles"
}
END: Cython Metadata */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
#error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
#error Cython requires Python 2.6+ or Python 3.2+.
#else
#define CYTHON_ABI "0_25_2"
#include <stddef.h>
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
#ifndef __stdcall
#define __stdcall
#endif
#ifndef __cdecl
#define __cdecl
#endif
#ifndef __fastcall
#define __fastcall
#endif
#endif
#ifndef DL_IMPORT
#define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
#define DL_EXPORT(t) t
#endif
#ifndef HAVE_LONG_LONG
#if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000)
#define HAVE_LONG_LONG
#endif
#endif
#ifndef PY_LONG_LONG
#define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
#define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_PYSTON 0
#define CYTHON_COMPILING_IN_CPYTHON 0
#undef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 0
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0
#undef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 0
#undef CYTHON_USE_UNICODE_WRITER
#define CYTHON_USE_UNICODE_WRITER 0
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#undef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 1
#undef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 0
#undef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 0
#undef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 0
#undef CYTHON_FAST_PYCALL
#define CYTHON_FAST_PYCALL 0
#elif defined(PYSTON_VERSION)
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_PYSTON 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#ifndef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 1
#endif
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0
#ifndef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 1
#endif
#undef CYTHON_USE_UNICODE_WRITER
#define CYTHON_USE_UNICODE_WRITER 0
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#ifndef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 0
#endif
#ifndef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 1
#endif
#ifndef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 1
#endif
#undef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 0
#undef CYTHON_FAST_PYCALL
#define CYTHON_FAST_PYCALL 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_PYSTON 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#ifndef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 1
#endif
#if PY_MAJOR_VERSION < 3
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
#define CYTHON_USE_ASYNC_SLOTS 1
#endif
#if PY_VERSION_HEX < 0x02070000
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#elif !defined(CYTHON_USE_PYLONG_INTERNALS)
#define CYTHON_USE_PYLONG_INTERNALS 1
#endif
#ifndef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 1
#endif
#ifndef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 1
#endif
#if PY_VERSION_HEX < 0x030300F0
#undef CYTHON_USE_UNICODE_WRITER
#define CYTHON_USE_UNICODE_WRITER 0
#elif !defined(CYTHON_USE_UNICODE_WRITER)
#define CYTHON_USE_UNICODE_WRITER 1
#endif
#ifndef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 0
#endif
#ifndef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 1
#endif
#ifndef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 1
#endif
#ifndef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 1
#endif
#ifndef CYTHON_FAST_PYCALL
#define CYTHON_FAST_PYCALL 1
#endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#undef SHIFT
#undef BASE
#undef MASK
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
#define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#define __Pyx_DefaultClassType PyClass_Type
#else
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
#define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
#define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
#define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_FASTCALL
#define METH_FASTCALL 0x80
typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args,
Py_ssize_t nargs, PyObject *kwnames);
#else
#define __Pyx_PyCFunctionFast _PyCFunctionFast
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
#define CYTHON_PEP393_ENABLED 1
#define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
0 : _PyUnicode_Ready((PyObject *)(op)))
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
#define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
#define CYTHON_PEP393_ENABLED 0
#define PyUnicode_1BYTE_KIND 1
#define PyUnicode_2BYTE_KIND 2
#define PyUnicode_4BYTE_KIND 4
#define __Pyx_PyUnicode_READY(op) (0)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
#define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
#define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
#define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
#define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
#else
#define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
#define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
#define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
#define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
#define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
#define PyObject_Malloc(s) PyMem_Malloc(s)
#define PyObject_Free(p) PyMem_Free(p)
#define PyObject_Realloc(p) PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
#define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
#endif
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
#else
#define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
#define PyObject_ASCII(o) PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
#define PyBaseString_Type PyUnicode_Type
#define PyStringObject PyUnicodeObject
#define PyString_Type PyUnicode_Type
#define PyString_Check PyUnicode_Check
#define PyString_CheckExact PyUnicode_CheckExact
#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
#define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
#define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
#define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
#if PY_MAJOR_VERSION >= 3
#define PyIntObject PyLongObject
#define PyInt_Type PyLong_Type
#define PyInt_Check(op) PyLong_Check(op)
#define PyInt_CheckExact(op) PyLong_CheckExact(op)
#define PyInt_FromString PyLong_FromString
#define PyInt_FromUnicode PyLong_FromUnicode
#define PyInt_FromLong PyLong_FromLong
#define PyInt_FromSize_t PyLong_FromSize_t
#define PyInt_FromSsize_t PyLong_FromSsize_t
#define PyInt_AsLong PyLong_AsLong
#define PyInt_AS_LONG PyLong_AS_LONG
#define PyInt_AsSsize_t PyLong_AsSsize_t
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#define PyNumber_Int PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
#define PyBoolObject PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
#ifndef PyUnicode_InternFromString
#define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
#endif
#endif
#if PY_VERSION_HEX < 0x030200A4
typedef long Py_hash_t;
#define __Pyx_PyInt_FromHash_t PyInt_FromLong
#define __Pyx_PyInt_AsHash_t PyInt_AsLong
#else
#define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
#define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#else
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#else
typedef struct {
unaryfunc am_await;
unaryfunc am_aiter;
unaryfunc am_anext;
} __Pyx_PyAsyncMethodsStruct;
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#endif
#else
#define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef CYTHON_RESTRICT
#if defined(__GNUC__)
#define CYTHON_RESTRICT __restrict__
#elif defined(_MSC_VER) && _MSC_VER >= 1400
#define CYTHON_RESTRICT __restrict
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define CYTHON_RESTRICT restrict
#else
#define CYTHON_RESTRICT
#endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
# if defined(__cplusplus)
template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
# else
# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
# endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
# define CYTHON_NCP_UNUSED
# else
# define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifndef CYTHON_INLINE
#if defined(__clang__)
#define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
#elif defined(__GNUC__)
#define CYTHON_INLINE __inline__
#elif defined(_MSC_VER)
#define CYTHON_INLINE __inline
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define CYTHON_INLINE inline
#else
#define CYTHON_INLINE
#endif
#endif
#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
float value;
memset(&value, 0xFF, sizeof(value));
return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif
#define __PYX_ERR(f_index, lineno, Ln_error) \
{ \
__pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
}
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
#else
#define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
#endif
#ifndef __PYX_EXTERN_C
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#endif
#define __PYX_HAVE__draw_rectangles
#define __PYX_HAVE_API__draw_rectangles
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */
#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif
typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
(sizeof(type) < sizeof(Py_ssize_t)) ||\
(sizeof(type) > sizeof(Py_ssize_t) &&\
likely(v < (type)PY_SSIZE_T_MAX ||\
v == (type)PY_SSIZE_T_MAX) &&\
(!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
v == (type)PY_SSIZE_T_MIN))) ||\
(sizeof(type) == sizeof(Py_ssize_t) &&\
(is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
v == (type)PY_SSIZE_T_MAX))) )
#if defined (__cplusplus) && __cplusplus >= 201103L
#include <cstdlib>
#define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
#define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
#define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER) && defined (_M_X64)
#define __Pyx_sst_abs(value) _abs64(value)
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
#define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
#define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
#define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
const Py_UNICODE *u_end = u;
while (*u_end++) ;
return (size_t)(u_end - u - 1);
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
PyObject* sys;
PyObject* default_encoding = NULL;
PyObject* ascii_chars_u = NULL;
PyObject* ascii_chars_b = NULL;
const char* default_encoding_c;
sys = PyImport_ImportModule("sys");
if (!sys) goto bad;
default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
Py_DECREF(sys);
if (!default_encoding) goto bad;
default_encoding_c = PyBytes_AsString(default_encoding);
if (!default_encoding_c) goto bad;
if (strcmp(default_encoding_c, "ascii") == 0) {
__Pyx_sys_getdefaultencoding_not_ascii = 0;
} else {
char ascii_chars[128];
int c;
for (c = 0; c < 128; c++) {
ascii_chars[c] = c;
}
__Pyx_sys_getdefaultencoding_not_ascii = 1;
ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
if (!ascii_chars_u) goto bad;
ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
PyErr_Format(
PyExc_ValueError,
"This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
default_encoding_c);
goto bad;
}
Py_DECREF(ascii_chars_u);
Py_DECREF(ascii_chars_b);
}
Py_DECREF(default_encoding);
return 0;
bad:
Py_XDECREF(default_encoding);
Py_XDECREF(ascii_chars_u);
Py_XDECREF(ascii_chars_b);
return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
PyObject* sys;
PyObject* default_encoding = NULL;
char* default_encoding_c;
sys = PyImport_ImportModule("sys");
if (!sys) goto bad;
default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
Py_DECREF(sys);
if (!default_encoding) goto bad;
default_encoding_c = PyBytes_AsString(default_encoding);
if (!default_encoding_c) goto bad;
__PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
Py_DECREF(default_encoding);
return 0;
bad:
Py_XDECREF(default_encoding);
return -1;
}
#endif
#endif
/* Test for GCC > 2.95 */
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
#define likely(x) (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;
/* Header.proto */
#if !defined(CYTHON_CCOMPLEX)
#if defined(__cplusplus)
#define CYTHON_CCOMPLEX 1
#elif defined(_Complex_I)
#define CYTHON_CCOMPLEX 1
#else
#define CYTHON_CCOMPLEX 0
#endif
#endif
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
#include <complex>
#else
#include <complex.h>
#endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
#undef _Complex_I
#define _Complex_I 1.0fj
#endif
static const char *__pyx_f[] = {
"draw_rectangles.pyx",
"__init__.pxd",
"type.pxd",
};
/* BufferFormatStructs.proto */
#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
const char* name;
struct __Pyx_StructField_* fields;
size_t size;
size_t arraysize[8];
int ndim;
char typegroup;
char is_unsigned;
int flags;
} __Pyx_TypeInfo;
typedef struct __Pyx_StructField_ {
__Pyx_TypeInfo* type;
const char* name;
size_t offset;
} __Pyx_StructField;
typedef struct {
__Pyx_StructField* field;
size_t parent_offset;
} __Pyx_BufFmt_StackElem;
typedef struct {
__Pyx_StructField root;
__Pyx_BufFmt_StackElem* head;
size_t fmt_offset;
size_t new_count, enc_count;
size_t struct_alignment;
int is_complex;
char enc_type;
char new_packmode;
char enc_packmode;
char is_valid_array;
} __Pyx_BufFmt_Context;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":725
* # in Cython to enable them only on the right systems.
*
* ctypedef npy_int8 int8_t # <<<<<<<<<<<<<<
* ctypedef npy_int16 int16_t
* ctypedef npy_int32 int32_t
*/
typedef npy_int8 __pyx_t_5numpy_int8_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":726
*
* ctypedef npy_int8 int8_t
* ctypedef npy_int16 int16_t # <<<<<<<<<<<<<<
* ctypedef npy_int32 int32_t
* ctypedef npy_int64 int64_t
*/
typedef npy_int16 __pyx_t_5numpy_int16_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":727
* ctypedef npy_int8 int8_t
* ctypedef npy_int16 int16_t
* ctypedef npy_int32 int32_t # <<<<<<<<<<<<<<
* ctypedef npy_int64 int64_t
* #ctypedef npy_int96 int96_t
*/
typedef npy_int32 __pyx_t_5numpy_int32_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":728
* ctypedef npy_int16 int16_t
* ctypedef npy_int32 int32_t
* ctypedef npy_int64 int64_t # <<<<<<<<<<<<<<
* #ctypedef npy_int96 int96_t
* #ctypedef npy_int128 int128_t
*/
typedef npy_int64 __pyx_t_5numpy_int64_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":732
* #ctypedef npy_int128 int128_t
*
* ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<<
* ctypedef npy_uint16 uint16_t
* ctypedef npy_uint32 uint32_t
*/
typedef npy_uint8 __pyx_t_5numpy_uint8_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":733
*
* ctypedef npy_uint8 uint8_t
* ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<<
* ctypedef npy_uint32 uint32_t
* ctypedef npy_uint64 uint64_t
*/
typedef npy_uint16 __pyx_t_5numpy_uint16_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":734
* ctypedef npy_uint8 uint8_t
* ctypedef npy_uint16 uint16_t
* ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<<
* ctypedef npy_uint64 uint64_t
* #ctypedef npy_uint96 uint96_t
*/
typedef npy_uint32 __pyx_t_5numpy_uint32_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":735
* ctypedef npy_uint16 uint16_t
* ctypedef npy_uint32 uint32_t
* ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<<
* #ctypedef npy_uint96 uint96_t
* #ctypedef npy_uint128 uint128_t
*/
typedef npy_uint64 __pyx_t_5numpy_uint64_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":739
* #ctypedef npy_uint128 uint128_t
*
* ctypedef npy_float32 float32_t # <<<<<<<<<<<<<<
* ctypedef npy_float64 float64_t
* #ctypedef npy_float80 float80_t
*/
typedef npy_float32 __pyx_t_5numpy_float32_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":740
*
* ctypedef npy_float32 float32_t
* ctypedef npy_float64 float64_t # <<<<<<<<<<<<<<
* #ctypedef npy_float80 float80_t
* #ctypedef npy_float128 float128_t
*/
typedef npy_float64 __pyx_t_5numpy_float64_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":749
* # The int types are mapped a bit surprising --
* # numpy.int corresponds to 'l' and numpy.long to 'q'
* ctypedef npy_long int_t # <<<<<<<<<<<<<<
* ctypedef npy_longlong long_t
* ctypedef npy_longlong longlong_t
*/
typedef npy_long __pyx_t_5numpy_int_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":750
* # numpy.int corresponds to 'l' and numpy.long to 'q'
* ctypedef npy_long int_t
* ctypedef npy_longlong long_t # <<<<<<<<<<<<<<
* ctypedef npy_longlong longlong_t
*
*/
typedef npy_longlong __pyx_t_5numpy_long_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":751
* ctypedef npy_long int_t
* ctypedef npy_longlong long_t
* ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<<
*
* ctypedef npy_ulong uint_t
*/
typedef npy_longlong __pyx_t_5numpy_longlong_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":753
* ctypedef npy_longlong longlong_t
*
* ctypedef npy_ulong uint_t # <<<<<<<<<<<<<<
* ctypedef npy_ulonglong ulong_t
* ctypedef npy_ulonglong ulonglong_t
*/
typedef npy_ulong __pyx_t_5numpy_uint_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":754
*
* ctypedef npy_ulong uint_t
* ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<<
* ctypedef npy_ulonglong ulonglong_t
*
*/
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":755
* ctypedef npy_ulong uint_t
* ctypedef npy_ulonglong ulong_t
* ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<<
*
* ctypedef npy_intp intp_t
*/
typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":757
* ctypedef npy_ulonglong ulonglong_t
*
* ctypedef npy_intp intp_t # <<<<<<<<<<<<<<
* ctypedef npy_uintp uintp_t
*
*/
typedef npy_intp __pyx_t_5numpy_intp_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":758
*
* ctypedef npy_intp intp_t
* ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<<
*
* ctypedef npy_double float_t
*/
typedef npy_uintp __pyx_t_5numpy_uintp_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":760
* ctypedef npy_uintp uintp_t
*
* ctypedef npy_double float_t # <<<<<<<<<<<<<<
* ctypedef npy_double double_t
* ctypedef npy_longdouble longdouble_t
*/
typedef npy_double __pyx_t_5numpy_float_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":761
*
* ctypedef npy_double float_t
* ctypedef npy_double double_t # <<<<<<<<<<<<<<
* ctypedef npy_longdouble longdouble_t
*
*/
typedef npy_double __pyx_t_5numpy_double_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":762
* ctypedef npy_double float_t
* ctypedef npy_double double_t
* ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<<
*
* ctypedef npy_cfloat cfloat_t
*/
typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
/* "draw_rectangles.pyx":10
*
* DTYPE = np.float32
* ctypedef np.float32_t DTYPE_t # <<<<<<<<<<<<<<
*
* def draw_union_boxes(bbox_pairs, pooling_size, padding=0):
*/
typedef __pyx_t_5numpy_float32_t __pyx_t_15draw_rectangles_DTYPE_t;
/* Declarations.proto */
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
typedef ::std::complex< float > __pyx_t_float_complex;
#else
typedef float _Complex __pyx_t_float_complex;
#endif
#else
typedef struct { float real, imag; } __pyx_t_float_complex;
#endif
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
/* Declarations.proto */
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
typedef ::std::complex< double > __pyx_t_double_complex;
#else
typedef double _Complex __pyx_t_double_complex;
#endif
#else
typedef struct { double real, imag; } __pyx_t_double_complex;
#endif
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
/*--- Type declarations ---*/
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":764
* ctypedef npy_longdouble longdouble_t
*
* ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<<
* ctypedef npy_cdouble cdouble_t
* ctypedef npy_clongdouble clongdouble_t
*/
typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":765
*
* ctypedef npy_cfloat cfloat_t
* ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<<
* ctypedef npy_clongdouble clongdouble_t
*
*/
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":766
* ctypedef npy_cfloat cfloat_t
* ctypedef npy_cdouble cdouble_t
* ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<<
*
* ctypedef npy_cdouble complex_t
*/
typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":768
* ctypedef npy_clongdouble clongdouble_t
*
* ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_MultiIterNew1(a):
*/
typedef npy_cdouble __pyx_t_5numpy_complex_t;
/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
#define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
typedef struct {
void (*INCREF)(void*, PyObject*, int);
void (*DECREF)(void*, PyObject*, int);
void (*GOTREF)(void*, PyObject*, int);
void (*GIVEREF)(void*, PyObject*, int);
void* (*SetupContext)(const char*, int, const char*);
void (*FinishContext)(void**);
} __Pyx_RefNannyAPIStruct;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
if (acquire_gil) {\
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
PyGILState_Release(__pyx_gilstate_save);\
} else {\
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
}
#else
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
#define __Pyx_RefNannyFinishContext()\
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
#define __Pyx_RefNannyDeclarations
#define __Pyx_RefNannySetupContext(name, acquire_gil)
#define __Pyx_RefNannyFinishContext()
#define __Pyx_INCREF(r) Py_INCREF(r)
#define __Pyx_DECREF(r) Py_DECREF(r)
#define __Pyx_GOTREF(r)
#define __Pyx_GIVEREF(r)
#define __Pyx_XINCREF(r) Py_XINCREF(r)
#define __Pyx_XDECREF(r) Py_XDECREF(r)
#define __Pyx_XGOTREF(r)
#define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
PyObject *tmp = (PyObject *) r;\
r = v; __Pyx_XDECREF(tmp);\
} while (0)
#define __Pyx_DECREF_SET(r, v) do {\
PyObject *tmp = (PyObject *) r;\
r = v; __Pyx_DECREF(tmp);\
} while (0)
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
PyTypeObject* tp = Py_TYPE(obj);
if (likely(tp->tp_getattro))
return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
if (likely(tp->tp_getattr))
return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
return PyObject_GetAttr(obj, attr_name);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif
/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);
/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
const char* function_name);
/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_EqObjC(op1, op2, intval, inplace)\
PyObject_RichCompare(op1, op2, Py_EQ)
#endif
/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
/* BufferFormatCheck.proto */
static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
__Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
__Pyx_BufFmt_StackElem* stack,
__Pyx_TypeInfo* type); // PROTO
/* GetModuleGlobalName.proto */
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif
/* BufferIndexError.proto */
static void __Pyx_RaiseBufferIndexError(int axis);
#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1)
#define __Pyx_BufPtrStrided4d(type, buf, i0, s0, i1, s1, i2, s2, i3, s3) (type)((char*)buf + i0 * s0 + i1 * s1 + i2 * s2 + i3 * s3)
/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET();
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#endif
/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
#endif
/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
PyObject *value;
value = PyDict_GetItemWithError(d, key);
if (unlikely(!value)) {
if (!PyErr_Occurred()) {
PyObject* args = PyTuple_Pack(1, key);
if (likely(args))
PyErr_SetObject(PyExc_KeyError, args);
Py_XDECREF(args);
}
return NULL;
}
Py_INCREF(value);
return value;
}
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif
/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
#endif
/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
#endif
/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif
/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
/* CodeObjectCache.proto */
typedef struct {
PyCodeObject* code_object;
int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
int count;
int max_count;
__Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
int py_line, const char *filename);
/* BufferStructDeclare.proto */
typedef struct {
Py_ssize_t shape, strides, suboffsets;
} __Pyx_Buf_DimInfo;
typedef struct {
size_t refcount;
Py_buffer pybuffer;
} __Pyx_Buffer;
typedef struct {
__Pyx_Buffer *rcbuffer;
char *data;
__Pyx_Buf_DimInfo diminfo[8];
} __Pyx_LocalBuf_ND;
#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
#define __Pyx_GetBuffer PyObject_GetBuffer
#define __Pyx_ReleaseBuffer PyBuffer_Release
#endif
/* None.proto */
static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0};
static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1};
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
/* RealImag.proto */
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
#define __Pyx_CREAL(z) ((z).real())
#define __Pyx_CIMAG(z) ((z).imag())
#else
#define __Pyx_CREAL(z) (__real__(z))
#define __Pyx_CIMAG(z) (__imag__(z))
#endif
#else
#define __Pyx_CREAL(z) ((z).real)
#define __Pyx_CIMAG(z) ((z).imag)
#endif
#if defined(__cplusplus) && CYTHON_CCOMPLEX\
&& (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
#define __Pyx_SET_CREAL(z,x) ((z).real(x))
#define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
#define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
#define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif
/* Arithmetic.proto */
#if CYTHON_CCOMPLEX
#define __Pyx_c_eq_float(a, b) ((a)==(b))
#define __Pyx_c_sum_float(a, b) ((a)+(b))
#define __Pyx_c_diff_float(a, b) ((a)-(b))
#define __Pyx_c_prod_float(a, b) ((a)*(b))
#define __Pyx_c_quot_float(a, b) ((a)/(b))
#define __Pyx_c_neg_float(a) (-(a))
#ifdef __cplusplus
#define __Pyx_c_is_zero_float(z) ((z)==(float)0)
#define __Pyx_c_conj_float(z) (::std::conj(z))
#if 1
#define __Pyx_c_abs_float(z) (::std::abs(z))
#define __Pyx_c_pow_float(a, b) (::std::pow(a, b))
#endif
#else
#define __Pyx_c_is_zero_float(z) ((z)==0)
#define __Pyx_c_conj_float(z) (conjf(z))
#if 1
#define __Pyx_c_abs_float(z) (cabsf(z))
#define __Pyx_c_pow_float(a, b) (cpowf(a, b))
#endif
#endif
#else
static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
#if 1
static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
#endif
#endif
/* Arithmetic.proto */
#if CYTHON_CCOMPLEX
#define __Pyx_c_eq_double(a, b) ((a)==(b))
#define __Pyx_c_sum_double(a, b) ((a)+(b))
#define __Pyx_c_diff_double(a, b) ((a)-(b))
#define __Pyx_c_prod_double(a, b) ((a)*(b))
#define __Pyx_c_quot_double(a, b) ((a)/(b))
#define __Pyx_c_neg_double(a) (-(a))
#ifdef __cplusplus
#define __Pyx_c_is_zero_double(z) ((z)==(double)0)
#define __Pyx_c_conj_double(z) (::std::conj(z))
#if 1
#define __Pyx_c_abs_double(z) (::std::abs(z))
#define __Pyx_c_pow_double(a, b) (::std::pow(a, b))
#endif
#else
#define __Pyx_c_is_zero_double(z) ((z)==0)
#define __Pyx_c_conj_double(z) (conj(z))
#if 1
#define __Pyx_c_abs_double(z) (cabs(z))
#define __Pyx_c_pow_double(a, b) (cpow(a, b))
#endif
#endif
#else
static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
#if 1
static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
#endif
#endif
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value);
/* CIntFromPy.proto */
static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *);
/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);
/* PyIdentifierFromString.proto */
#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif
/* ModuleImport.proto */
static PyObject *__Pyx_ImportModule(const char *name);
/* TypeImport.proto */
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
/* Module declarations from 'cython' */
/* Module declarations from 'cpython.buffer' */
/* Module declarations from 'libc.string' */
/* Module declarations from 'libc.stdio' */
/* Module declarations from '__builtin__' */
/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
/* Module declarations from 'cpython' */
/* Module declarations from 'cpython.object' */
/* Module declarations from 'cpython.ref' */
/* Module declarations from 'libc.stdlib' */
/* Module declarations from 'numpy' */
/* Module declarations from 'numpy' */
static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/
/* Module declarations from 'draw_rectangles' */
static __pyx_t_15draw_rectangles_DTYPE_t __pyx_f_15draw_rectangles_minmax(__pyx_t_15draw_rectangles_DTYPE_t); /*proto*/
static PyArrayObject *__pyx_f_15draw_rectangles_draw_union_boxes_c(PyArrayObject *, unsigned int); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_15draw_rectangles_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_15draw_rectangles_DTYPE_t), { 0 }, 0, 'R', 0, 0 };
#define __Pyx_MODULE_NAME "draw_rectangles"
int __pyx_module_is_main_draw_rectangles = 0;
/* Implementation of 'draw_rectangles' */
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_ImportError;
static const char __pyx_k_np[] = "np";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_DTYPE[] = "DTYPE";
static const char __pyx_k_dtype[] = "dtype";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_zeros[] = "zeros";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_float32[] = "float32";
static const char __pyx_k_padding[] = "padding";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_bbox_pairs[] = "bbox_pairs";
static const char __pyx_k_ImportError[] = "ImportError";
static const char __pyx_k_RuntimeError[] = "RuntimeError";
static const char __pyx_k_pooling_size[] = "pooling_size";
static const char __pyx_k_draw_rectangles[] = "draw_rectangles";
static const char __pyx_k_draw_union_boxes[] = "draw_union_boxes";
static const char __pyx_k_Padding_0_not_supported_yet[] = "Padding>0 not supported yet";
static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous";
static const char __pyx_k_Users_rowanz_code_scene_graph_l[] = "/Users/rowanz/code/scene-graph/lib/draw_rectangles/draw_rectangles.pyx";
static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)";
static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd";
static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported";
static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous";
static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short.";
static PyObject *__pyx_n_s_DTYPE;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2;
static PyObject *__pyx_n_s_ImportError;
static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor;
static PyObject *__pyx_kp_s_Padding_0_not_supported_yet;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_kp_s_Users_rowanz_code_scene_graph_l;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_s_bbox_pairs;
static PyObject *__pyx_n_s_draw_rectangles;
static PyObject *__pyx_n_s_draw_union_boxes;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_float32;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous;
static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou;
static PyObject *__pyx_n_s_np;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to;
static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor;
static PyObject *__pyx_n_s_padding;
static PyObject *__pyx_n_s_pooling_size;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd;
static PyObject *__pyx_n_s_zeros;
static PyObject *__pyx_pf_15draw_rectangles_draw_union_boxes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_bbox_pairs, PyObject *__pyx_v_pooling_size, PyObject *__pyx_v_padding); /* proto */
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_2;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_codeobj__11;
/* "draw_rectangles.pyx":12
* ctypedef np.float32_t DTYPE_t
*
* def draw_union_boxes(bbox_pairs, pooling_size, padding=0): # <<<<<<<<<<<<<<
* """
* Draws union boxes for the image.
*/
/* Python wrapper */
static PyObject *__pyx_pw_15draw_rectangles_1draw_union_boxes(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_15draw_rectangles_draw_union_boxes[] = "\n Draws union boxes for the image.\n :param box_pairs: [num_pairs, 8]\n :param fmap_size: Size of the original feature map\n :param stride: ratio between fmap size and original img (<1)\n :param pooling_size: resize everything to this size\n :return: [num_pairs, 2, pooling_size, pooling_size arr\n ";
static PyMethodDef __pyx_mdef_15draw_rectangles_1draw_union_boxes = {"draw_union_boxes", (PyCFunction)__pyx_pw_15draw_rectangles_1draw_union_boxes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_15draw_rectangles_draw_union_boxes};
static PyObject *__pyx_pw_15draw_rectangles_1draw_union_boxes(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_bbox_pairs = 0;
PyObject *__pyx_v_pooling_size = 0;
PyObject *__pyx_v_padding = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("draw_union_boxes (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bbox_pairs,&__pyx_n_s_pooling_size,&__pyx_n_s_padding,0};
PyObject* values[3] = {0,0,0};
values[2] = ((PyObject *)__pyx_int_0);
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bbox_pairs)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pooling_size)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("draw_union_boxes", 0, 2, 3, 1); __PYX_ERR(0, 12, __pyx_L3_error)
}
case 2:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_padding);
if (value) { values[2] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "draw_union_boxes") < 0)) __PYX_ERR(0, 12, __pyx_L3_error)
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_bbox_pairs = values[0];
__pyx_v_pooling_size = values[1];
__pyx_v_padding = values[2];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("draw_union_boxes", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 12, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("draw_rectangles.draw_union_boxes", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_15draw_rectangles_draw_union_boxes(__pyx_self, __pyx_v_bbox_pairs, __pyx_v_pooling_size, __pyx_v_padding);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15draw_rectangles_draw_union_boxes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_bbox_pairs, PyObject *__pyx_v_pooling_size, PyObject *__pyx_v_padding) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
unsigned int __pyx_t_3;
__Pyx_RefNannySetupContext("draw_union_boxes", 0);
/* "draw_rectangles.pyx":21
* :return: [num_pairs, 2, pooling_size, pooling_size arr
* """
* assert padding == 0, "Padding>0 not supported yet" # <<<<<<<<<<<<<<
* return draw_union_boxes_c(bbox_pairs, pooling_size)
*
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_padding, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 21, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_2)) {
PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Padding_0_not_supported_yet);
__PYX_ERR(0, 21, __pyx_L1_error)
}
}
#endif
/* "draw_rectangles.pyx":22
* """
* assert padding == 0, "Padding>0 not supported yet"
* return draw_union_boxes_c(bbox_pairs, pooling_size) # <<<<<<<<<<<<<<
*
* cdef DTYPE_t minmax(DTYPE_t x):
*/
__Pyx_XDECREF(__pyx_r);
if (!(likely(((__pyx_v_bbox_pairs) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_bbox_pairs, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 22, __pyx_L1_error)
__pyx_t_3 = __Pyx_PyInt_As_unsigned_int(__pyx_v_pooling_size); if (unlikely((__pyx_t_3 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 22, __pyx_L1_error)
__pyx_t_1 = ((PyObject *)__pyx_f_15draw_rectangles_draw_union_boxes_c(((PyArrayObject *)__pyx_v_bbox_pairs), __pyx_t_3)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "draw_rectangles.pyx":12
* ctypedef np.float32_t DTYPE_t
*
* def draw_union_boxes(bbox_pairs, pooling_size, padding=0): # <<<<<<<<<<<<<<
* """
* Draws union boxes for the image.
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("draw_rectangles.draw_union_boxes", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "draw_rectangles.pyx":24
* return draw_union_boxes_c(bbox_pairs, pooling_size)
*
* cdef DTYPE_t minmax(DTYPE_t x): # <<<<<<<<<<<<<<
* return min(max(x, 0), 1)
*
*/
static __pyx_t_15draw_rectangles_DTYPE_t __pyx_f_15draw_rectangles_minmax(__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_x) {
__pyx_t_15draw_rectangles_DTYPE_t __pyx_r;
__Pyx_RefNannyDeclarations
long __pyx_t_1;
long __pyx_t_2;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_t_3;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_t_4;
__Pyx_RefNannySetupContext("minmax", 0);
/* "draw_rectangles.pyx":25
*
* cdef DTYPE_t minmax(DTYPE_t x):
* return min(max(x, 0), 1) # <<<<<<<<<<<<<<
*
* cdef np.ndarray[DTYPE_t, ndim=4] draw_union_boxes_c(
*/
__pyx_t_1 = 1;
__pyx_t_2 = 0;
__pyx_t_3 = __pyx_v_x;
if (((__pyx_t_2 > __pyx_t_3) != 0)) {
__pyx_t_4 = __pyx_t_2;
} else {
__pyx_t_4 = __pyx_t_3;
}
__pyx_t_3 = __pyx_t_4;
if (((__pyx_t_1 < __pyx_t_3) != 0)) {
__pyx_t_4 = __pyx_t_1;
} else {
__pyx_t_4 = __pyx_t_3;
}
__pyx_r = __pyx_t_4;
goto __pyx_L0;
/* "draw_rectangles.pyx":24
* return draw_union_boxes_c(bbox_pairs, pooling_size)
*
* cdef DTYPE_t minmax(DTYPE_t x): # <<<<<<<<<<<<<<
* return min(max(x, 0), 1)
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "draw_rectangles.pyx":27
* return min(max(x, 0), 1)
*
* cdef np.ndarray[DTYPE_t, ndim=4] draw_union_boxes_c( # <<<<<<<<<<<<<<
* np.ndarray[DTYPE_t, ndim=2] box_pairs, unsigned int pooling_size):
* """
*/
static PyArrayObject *__pyx_f_15draw_rectangles_draw_union_boxes_c(PyArrayObject *__pyx_v_box_pairs, unsigned int __pyx_v_pooling_size) {
unsigned int __pyx_v_N;
PyArrayObject *__pyx_v_uboxes = 0;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_x1_union;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_y1_union;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_x2_union;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_y2_union;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_w;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_h;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_x1_box;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_y1_box;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_x2_box;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_y2_box;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_y_contrib;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_v_x_contrib;
unsigned int __pyx_v_n;
unsigned int __pyx_v_i;
unsigned int __pyx_v_j;
unsigned int __pyx_v_k;
__Pyx_LocalBuf_ND __pyx_pybuffernd_box_pairs;
__Pyx_Buffer __pyx_pybuffer_box_pairs;
__Pyx_LocalBuf_ND __pyx_pybuffernd_uboxes;
__Pyx_Buffer __pyx_pybuffer_uboxes;
PyArrayObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyArrayObject *__pyx_t_6 = NULL;
unsigned int __pyx_t_7;
unsigned int __pyx_t_8;
size_t __pyx_t_9;
Py_ssize_t __pyx_t_10;
int __pyx_t_11;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_t_12;
size_t __pyx_t_13;
Py_ssize_t __pyx_t_14;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_t_15;
__pyx_t_15draw_rectangles_DTYPE_t __pyx_t_16;
size_t __pyx_t_17;
Py_ssize_t __pyx_t_18;
size_t __pyx_t_19;
Py_ssize_t __pyx_t_20;
size_t __pyx_t_21;
Py_ssize_t __pyx_t_22;
size_t __pyx_t_23;
Py_ssize_t __pyx_t_24;
size_t __pyx_t_25;
Py_ssize_t __pyx_t_26;
size_t __pyx_t_27;
Py_ssize_t __pyx_t_28;
unsigned int __pyx_t_29;
size_t __pyx_t_30;
Py_ssize_t __pyx_t_31;
size_t __pyx_t_32;
Py_ssize_t __pyx_t_33;
size_t __pyx_t_34;
Py_ssize_t __pyx_t_35;
size_t __pyx_t_36;
Py_ssize_t __pyx_t_37;
unsigned int __pyx_t_38;
unsigned int __pyx_t_39;
unsigned int __pyx_t_40;
unsigned int __pyx_t_41;
size_t __pyx_t_42;
size_t __pyx_t_43;
size_t __pyx_t_44;
size_t __pyx_t_45;
__Pyx_RefNannySetupContext("draw_union_boxes_c", 0);
__pyx_pybuffer_uboxes.pybuffer.buf = NULL;
__pyx_pybuffer_uboxes.refcount = 0;
__pyx_pybuffernd_uboxes.data = NULL;
__pyx_pybuffernd_uboxes.rcbuffer = &__pyx_pybuffer_uboxes;
__pyx_pybuffer_box_pairs.pybuffer.buf = NULL;
__pyx_pybuffer_box_pairs.refcount = 0;
__pyx_pybuffernd_box_pairs.data = NULL;
__pyx_pybuffernd_box_pairs.rcbuffer = &__pyx_pybuffer_box_pairs;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_box_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_box_pairs, &__Pyx_TypeInfo_nn___pyx_t_15draw_rectangles_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 27, __pyx_L1_error)
}
__pyx_pybuffernd_box_pairs.diminfo[0].strides = __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_box_pairs.diminfo[0].shape = __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_box_pairs.diminfo[1].strides = __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_box_pairs.diminfo[1].shape = __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.shape[1];
/* "draw_rectangles.pyx":38
* overlaps: (N, K) ndarray of overlap between boxes and query_boxes
* """
* cdef unsigned int N = box_pairs.shape[0] # <<<<<<<<<<<<<<
*
* cdef np.ndarray[DTYPE_t, ndim = 4] uboxes = np.zeros(
*/
__pyx_v_N = (__pyx_v_box_pairs->dimensions[0]);
/* "draw_rectangles.pyx":40
* cdef unsigned int N = box_pairs.shape[0]
*
* cdef np.ndarray[DTYPE_t, ndim = 4] uboxes = np.zeros( # <<<<<<<<<<<<<<
* (N, 2, pooling_size, pooling_size), dtype=DTYPE)
* cdef DTYPE_t x1_union, y1_union, x2_union, y2_union, w, h, x1_box, y1_box, x2_box, y2_box, y_contrib, x_contrib
*/
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "draw_rectangles.pyx":41
*
* cdef np.ndarray[DTYPE_t, ndim = 4] uboxes = np.zeros(
* (N, 2, pooling_size, pooling_size), dtype=DTYPE) # <<<<<<<<<<<<<<
* cdef DTYPE_t x1_union, y1_union, x2_union, y2_union, w, h, x1_box, y1_box, x2_box, y2_box, y_contrib, x_contrib
* cdef unsigned int n, i, j, k
*/
__pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_N); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_pooling_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 41, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __Pyx_PyInt_From_unsigned_int(__pyx_v_pooling_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 41, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 41, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
__Pyx_INCREF(__pyx_int_2);
__Pyx_GIVEREF(__pyx_int_2);
PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_2);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
__pyx_t_1 = 0;
__pyx_t_3 = 0;
__pyx_t_4 = 0;
/* "draw_rectangles.pyx":40
* cdef unsigned int N = box_pairs.shape[0]
*
* cdef np.ndarray[DTYPE_t, ndim = 4] uboxes = np.zeros( # <<<<<<<<<<<<<<
* (N, 2, pooling_size, pooling_size), dtype=DTYPE)
* cdef DTYPE_t x1_union, y1_union, x2_union, y2_union, w, h, x1_box, y1_box, x2_box, y2_box, y_contrib, x_contrib
*/
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 40, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
__pyx_t_5 = 0;
/* "draw_rectangles.pyx":41
*
* cdef np.ndarray[DTYPE_t, ndim = 4] uboxes = np.zeros(
* (N, 2, pooling_size, pooling_size), dtype=DTYPE) # <<<<<<<<<<<<<<
* cdef DTYPE_t x1_union, y1_union, x2_union, y2_union, w, h, x1_box, y1_box, x2_box, y2_box, y_contrib, x_contrib
* cdef unsigned int n, i, j, k
*/
__pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 41, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 41, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "draw_rectangles.pyx":40
* cdef unsigned int N = box_pairs.shape[0]
*
* cdef np.ndarray[DTYPE_t, ndim = 4] uboxes = np.zeros( # <<<<<<<<<<<<<<
* (N, 2, pooling_size, pooling_size), dtype=DTYPE)
* cdef DTYPE_t x1_union, y1_union, x2_union, y2_union, w, h, x1_box, y1_box, x2_box, y2_box, y_contrib, x_contrib
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 40, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 40, __pyx_L1_error)
__pyx_t_6 = ((PyArrayObject *)__pyx_t_3);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_uboxes.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_15draw_rectangles_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 4, 0, __pyx_stack) == -1)) {
__pyx_v_uboxes = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_uboxes.rcbuffer->pybuffer.buf = NULL;
__PYX_ERR(0, 40, __pyx_L1_error)
} else {__pyx_pybuffernd_uboxes.diminfo[0].strides = __pyx_pybuffernd_uboxes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_uboxes.diminfo[0].shape = __pyx_pybuffernd_uboxes.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_uboxes.diminfo[1].strides = __pyx_pybuffernd_uboxes.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_uboxes.diminfo[1].shape = __pyx_pybuffernd_uboxes.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_uboxes.diminfo[2].strides = __pyx_pybuffernd_uboxes.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_uboxes.diminfo[2].shape = __pyx_pybuffernd_uboxes.rcbuffer->pybuffer.shape[2]; __pyx_pybuffernd_uboxes.diminfo[3].strides = __pyx_pybuffernd_uboxes.rcbuffer->pybuffer.strides[3]; __pyx_pybuffernd_uboxes.diminfo[3].shape = __pyx_pybuffernd_uboxes.rcbuffer->pybuffer.shape[3];
}
}
__pyx_t_6 = 0;
__pyx_v_uboxes = ((PyArrayObject *)__pyx_t_3);
__pyx_t_3 = 0;
/* "draw_rectangles.pyx":45
* cdef unsigned int n, i, j, k
*
* for n in range(N): # <<<<<<<<<<<<<<
* x1_union = min(box_pairs[n, 0], box_pairs[n, 4])
* y1_union = min(box_pairs[n, 1], box_pairs[n, 5])
*/
__pyx_t_7 = __pyx_v_N;
for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
__pyx_v_n = __pyx_t_8;
/* "draw_rectangles.pyx":46
*
* for n in range(N):
* x1_union = min(box_pairs[n, 0], box_pairs[n, 4]) # <<<<<<<<<<<<<<
* y1_union = min(box_pairs[n, 1], box_pairs[n, 5])
* x2_union = max(box_pairs[n, 2], box_pairs[n, 6])
*/
__pyx_t_9 = __pyx_v_n;
__pyx_t_10 = 4;
__pyx_t_11 = -1;
if (unlikely(__pyx_t_9 >= (size_t)__pyx_pybuffernd_box_pairs.diminfo[0].shape)) __pyx_t_11 = 0;
if (__pyx_t_10 < 0) {
__pyx_t_10 += __pyx_pybuffernd_box_pairs.diminfo[1].shape;
if (unlikely(__pyx_t_10 < 0)) __pyx_t_11 = 1;
} else if (unlikely(__pyx_t_10 >= __pyx_pybuffernd_box_pairs.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 46, __pyx_L1_error)
}
__pyx_t_12 = (*__Pyx_BufPtrStrided2d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_box_pairs.diminfo[0].strides, __pyx_t_10, __pyx_pybuffernd_box_pairs.diminfo[1].strides));
__pyx_t_13 = __pyx_v_n;
__pyx_t_14 = 0;
__pyx_t_11 = -1;
if (unlikely(__pyx_t_13 >= (size_t)__pyx_pybuffernd_box_pairs.diminfo[0].shape)) __pyx_t_11 = 0;
if (__pyx_t_14 < 0) {
__pyx_t_14 += __pyx_pybuffernd_box_pairs.diminfo[1].shape;
if (unlikely(__pyx_t_14 < 0)) __pyx_t_11 = 1;
} else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_box_pairs.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 46, __pyx_L1_error)
}
__pyx_t_15 = (*__Pyx_BufPtrStrided2d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_box_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_box_pairs.diminfo[1].strides));
if (((__pyx_t_12 < __pyx_t_15) != 0)) {
__pyx_t_16 = __pyx_t_12;
} else {
__pyx_t_16 = __pyx_t_15;
}
__pyx_v_x1_union = __pyx_t_16;
/* "draw_rectangles.pyx":47
* for n in range(N):
* x1_union = min(box_pairs[n, 0], box_pairs[n, 4])
* y1_union = min(box_pairs[n, 1], box_pairs[n, 5]) # <<<<<<<<<<<<<<
* x2_union = max(box_pairs[n, 2], box_pairs[n, 6])
* y2_union = max(box_pairs[n, 3], box_pairs[n, 7])
*/
__pyx_t_17 = __pyx_v_n;
__pyx_t_18 = 5;
__pyx_t_11 = -1;
if (unlikely(__pyx_t_17 >= (size_t)__pyx_pybuffernd_box_pairs.diminfo[0].shape)) __pyx_t_11 = 0;
if (__pyx_t_18 < 0) {
__pyx_t_18 += __pyx_pybuffernd_box_pairs.diminfo[1].shape;
if (unlikely(__pyx_t_18 < 0)) __pyx_t_11 = 1;
} else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_box_pairs.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 47, __pyx_L1_error)
}
__pyx_t_16 = (*__Pyx_BufPtrStrided2d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_box_pairs.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_box_pairs.diminfo[1].strides));
__pyx_t_19 = __pyx_v_n;
__pyx_t_20 = 1;
__pyx_t_11 = -1;
if (unlikely(__pyx_t_19 >= (size_t)__pyx_pybuffernd_box_pairs.diminfo[0].shape)) __pyx_t_11 = 0;
if (__pyx_t_20 < 0) {
__pyx_t_20 += __pyx_pybuffernd_box_pairs.diminfo[1].shape;
if (unlikely(__pyx_t_20 < 0)) __pyx_t_11 = 1;
} else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_box_pairs.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 47, __pyx_L1_error)
}
__pyx_t_12 = (*__Pyx_BufPtrStrided2d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_box_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_box_pairs.diminfo[1].strides));
if (((__pyx_t_16 < __pyx_t_12) != 0)) {
__pyx_t_15 = __pyx_t_16;
} else {
__pyx_t_15 = __pyx_t_12;
}
__pyx_v_y1_union = __pyx_t_15;
/* "draw_rectangles.pyx":48
* x1_union = min(box_pairs[n, 0], box_pairs[n, 4])
* y1_union = min(box_pairs[n, 1], box_pairs[n, 5])
* x2_union = max(box_pairs[n, 2], box_pairs[n, 6]) # <<<<<<<<<<<<<<
* y2_union = max(box_pairs[n, 3], box_pairs[n, 7])
*
*/
__pyx_t_21 = __pyx_v_n;
__pyx_t_22 = 6;
__pyx_t_11 = -1;
if (unlikely(__pyx_t_21 >= (size_t)__pyx_pybuffernd_box_pairs.diminfo[0].shape)) __pyx_t_11 = 0;
if (__pyx_t_22 < 0) {
__pyx_t_22 += __pyx_pybuffernd_box_pairs.diminfo[1].shape;
if (unlikely(__pyx_t_22 < 0)) __pyx_t_11 = 1;
} else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_box_pairs.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 48, __pyx_L1_error)
}
__pyx_t_15 = (*__Pyx_BufPtrStrided2d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_box_pairs.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_box_pairs.diminfo[1].strides));
__pyx_t_23 = __pyx_v_n;
__pyx_t_24 = 2;
__pyx_t_11 = -1;
if (unlikely(__pyx_t_23 >= (size_t)__pyx_pybuffernd_box_pairs.diminfo[0].shape)) __pyx_t_11 = 0;
if (__pyx_t_24 < 0) {
__pyx_t_24 += __pyx_pybuffernd_box_pairs.diminfo[1].shape;
if (unlikely(__pyx_t_24 < 0)) __pyx_t_11 = 1;
} else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_box_pairs.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 48, __pyx_L1_error)
}
__pyx_t_16 = (*__Pyx_BufPtrStrided2d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_box_pairs.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_box_pairs.diminfo[1].strides));
if (((__pyx_t_15 > __pyx_t_16) != 0)) {
__pyx_t_12 = __pyx_t_15;
} else {
__pyx_t_12 = __pyx_t_16;
}
__pyx_v_x2_union = __pyx_t_12;
/* "draw_rectangles.pyx":49
* y1_union = min(box_pairs[n, 1], box_pairs[n, 5])
* x2_union = max(box_pairs[n, 2], box_pairs[n, 6])
* y2_union = max(box_pairs[n, 3], box_pairs[n, 7]) # <<<<<<<<<<<<<<
*
* w = x2_union - x1_union
*/
__pyx_t_25 = __pyx_v_n;
__pyx_t_26 = 7;
__pyx_t_11 = -1;
if (unlikely(__pyx_t_25 >= (size_t)__pyx_pybuffernd_box_pairs.diminfo[0].shape)) __pyx_t_11 = 0;
if (__pyx_t_26 < 0) {
__pyx_t_26 += __pyx_pybuffernd_box_pairs.diminfo[1].shape;
if (unlikely(__pyx_t_26 < 0)) __pyx_t_11 = 1;
} else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_box_pairs.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 49, __pyx_L1_error)
}
__pyx_t_12 = (*__Pyx_BufPtrStrided2d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_box_pairs.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_box_pairs.diminfo[1].strides));
__pyx_t_27 = __pyx_v_n;
__pyx_t_28 = 3;
__pyx_t_11 = -1;
if (unlikely(__pyx_t_27 >= (size_t)__pyx_pybuffernd_box_pairs.diminfo[0].shape)) __pyx_t_11 = 0;
if (__pyx_t_28 < 0) {
__pyx_t_28 += __pyx_pybuffernd_box_pairs.diminfo[1].shape;
if (unlikely(__pyx_t_28 < 0)) __pyx_t_11 = 1;
} else if (unlikely(__pyx_t_28 >= __pyx_pybuffernd_box_pairs.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 49, __pyx_L1_error)
}
__pyx_t_15 = (*__Pyx_BufPtrStrided2d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_box_pairs.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_box_pairs.diminfo[1].strides));
if (((__pyx_t_12 > __pyx_t_15) != 0)) {
__pyx_t_16 = __pyx_t_12;
} else {
__pyx_t_16 = __pyx_t_15;
}
__pyx_v_y2_union = __pyx_t_16;
/* "draw_rectangles.pyx":51
* y2_union = max(box_pairs[n, 3], box_pairs[n, 7])
*
* w = x2_union - x1_union # <<<<<<<<<<<<<<
* h = y2_union - y1_union
*
*/
__pyx_v_w = (__pyx_v_x2_union - __pyx_v_x1_union);
/* "draw_rectangles.pyx":52
*
* w = x2_union - x1_union
* h = y2_union - y1_union # <<<<<<<<<<<<<<
*
* for i in range(2):
*/
__pyx_v_h = (__pyx_v_y2_union - __pyx_v_y1_union);
/* "draw_rectangles.pyx":54
* h = y2_union - y1_union
*
* for i in range(2): # <<<<<<<<<<<<<<
* # Now everything is in the range [0, pooling_size].
* x1_box = (box_pairs[n, 0+4*i] - x1_union)*pooling_size / w
*/
for (__pyx_t_29 = 0; __pyx_t_29 < 2; __pyx_t_29+=1) {
__pyx_v_i = __pyx_t_29;
/* "draw_rectangles.pyx":56
* for i in range(2):
* # Now everything is in the range [0, pooling_size].
* x1_box = (box_pairs[n, 0+4*i] - x1_union)*pooling_size / w # <<<<<<<<<<<<<<
* y1_box = (box_pairs[n, 1+4*i] - y1_union)*pooling_size / h
* x2_box = (box_pairs[n, 2+4*i] - x1_union)*pooling_size / w
*/
__pyx_t_30 = __pyx_v_n;
__pyx_t_31 = (0 + (4 * __pyx_v_i));
__pyx_t_11 = -1;
if (unlikely(__pyx_t_30 >= (size_t)__pyx_pybuffernd_box_pairs.diminfo[0].shape)) __pyx_t_11 = 0;
if (__pyx_t_31 < 0) {
__pyx_t_31 += __pyx_pybuffernd_box_pairs.diminfo[1].shape;
if (unlikely(__pyx_t_31 < 0)) __pyx_t_11 = 1;
} else if (unlikely(__pyx_t_31 >= __pyx_pybuffernd_box_pairs.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 56, __pyx_L1_error)
}
__pyx_t_16 = (((*__Pyx_BufPtrStrided2d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_box_pairs.diminfo[0].strides, __pyx_t_31, __pyx_pybuffernd_box_pairs.diminfo[1].strides)) - __pyx_v_x1_union) * __pyx_v_pooling_size);
if (unlikely(__pyx_v_w == 0)) {
PyErr_SetString(PyExc_ZeroDivisionError, "float division");
__PYX_ERR(0, 56, __pyx_L1_error)
}
__pyx_v_x1_box = (__pyx_t_16 / __pyx_v_w);
/* "draw_rectangles.pyx":57
* # Now everything is in the range [0, pooling_size].
* x1_box = (box_pairs[n, 0+4*i] - x1_union)*pooling_size / w
* y1_box = (box_pairs[n, 1+4*i] - y1_union)*pooling_size / h # <<<<<<<<<<<<<<
* x2_box = (box_pairs[n, 2+4*i] - x1_union)*pooling_size / w
* y2_box = (box_pairs[n, 3+4*i] - y1_union)*pooling_size / h
*/
__pyx_t_32 = __pyx_v_n;
__pyx_t_33 = (1 + (4 * __pyx_v_i));
__pyx_t_11 = -1;
if (unlikely(__pyx_t_32 >= (size_t)__pyx_pybuffernd_box_pairs.diminfo[0].shape)) __pyx_t_11 = 0;
if (__pyx_t_33 < 0) {
__pyx_t_33 += __pyx_pybuffernd_box_pairs.diminfo[1].shape;
if (unlikely(__pyx_t_33 < 0)) __pyx_t_11 = 1;
} else if (unlikely(__pyx_t_33 >= __pyx_pybuffernd_box_pairs.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 57, __pyx_L1_error)
}
__pyx_t_16 = (((*__Pyx_BufPtrStrided2d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_box_pairs.diminfo[0].strides, __pyx_t_33, __pyx_pybuffernd_box_pairs.diminfo[1].strides)) - __pyx_v_y1_union) * __pyx_v_pooling_size);
if (unlikely(__pyx_v_h == 0)) {
PyErr_SetString(PyExc_ZeroDivisionError, "float division");
__PYX_ERR(0, 57, __pyx_L1_error)
}
__pyx_v_y1_box = (__pyx_t_16 / __pyx_v_h);
/* "draw_rectangles.pyx":58
* x1_box = (box_pairs[n, 0+4*i] - x1_union)*pooling_size / w
* y1_box = (box_pairs[n, 1+4*i] - y1_union)*pooling_size / h
* x2_box = (box_pairs[n, 2+4*i] - x1_union)*pooling_size / w # <<<<<<<<<<<<<<
* y2_box = (box_pairs[n, 3+4*i] - y1_union)*pooling_size / h
* # print("{:.3f}, {:.3f}, {:.3f}, {:.3f}".format(x1_box, y1_box, x2_box, y2_box))
*/
__pyx_t_34 = __pyx_v_n;
__pyx_t_35 = (2 + (4 * __pyx_v_i));
__pyx_t_11 = -1;
if (unlikely(__pyx_t_34 >= (size_t)__pyx_pybuffernd_box_pairs.diminfo[0].shape)) __pyx_t_11 = 0;
if (__pyx_t_35 < 0) {
__pyx_t_35 += __pyx_pybuffernd_box_pairs.diminfo[1].shape;
if (unlikely(__pyx_t_35 < 0)) __pyx_t_11 = 1;
} else if (unlikely(__pyx_t_35 >= __pyx_pybuffernd_box_pairs.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 58, __pyx_L1_error)
}
__pyx_t_16 = (((*__Pyx_BufPtrStrided2d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_box_pairs.diminfo[0].strides, __pyx_t_35, __pyx_pybuffernd_box_pairs.diminfo[1].strides)) - __pyx_v_x1_union) * __pyx_v_pooling_size);
if (unlikely(__pyx_v_w == 0)) {
PyErr_SetString(PyExc_ZeroDivisionError, "float division");
__PYX_ERR(0, 58, __pyx_L1_error)
}
__pyx_v_x2_box = (__pyx_t_16 / __pyx_v_w);
/* "draw_rectangles.pyx":59
* y1_box = (box_pairs[n, 1+4*i] - y1_union)*pooling_size / h
* x2_box = (box_pairs[n, 2+4*i] - x1_union)*pooling_size / w
* y2_box = (box_pairs[n, 3+4*i] - y1_union)*pooling_size / h # <<<<<<<<<<<<<<
* # print("{:.3f}, {:.3f}, {:.3f}, {:.3f}".format(x1_box, y1_box, x2_box, y2_box))
* for j in range(pooling_size):
*/
__pyx_t_36 = __pyx_v_n;
__pyx_t_37 = (3 + (4 * __pyx_v_i));
__pyx_t_11 = -1;
if (unlikely(__pyx_t_36 >= (size_t)__pyx_pybuffernd_box_pairs.diminfo[0].shape)) __pyx_t_11 = 0;
if (__pyx_t_37 < 0) {
__pyx_t_37 += __pyx_pybuffernd_box_pairs.diminfo[1].shape;
if (unlikely(__pyx_t_37 < 0)) __pyx_t_11 = 1;
} else if (unlikely(__pyx_t_37 >= __pyx_pybuffernd_box_pairs.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 59, __pyx_L1_error)
}
__pyx_t_16 = (((*__Pyx_BufPtrStrided2d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_box_pairs.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_box_pairs.diminfo[0].strides, __pyx_t_37, __pyx_pybuffernd_box_pairs.diminfo[1].strides)) - __pyx_v_y1_union) * __pyx_v_pooling_size);
if (unlikely(__pyx_v_h == 0)) {
PyErr_SetString(PyExc_ZeroDivisionError, "float division");
__PYX_ERR(0, 59, __pyx_L1_error)
}
__pyx_v_y2_box = (__pyx_t_16 / __pyx_v_h);
/* "draw_rectangles.pyx":61
* y2_box = (box_pairs[n, 3+4*i] - y1_union)*pooling_size / h
* # print("{:.3f}, {:.3f}, {:.3f}, {:.3f}".format(x1_box, y1_box, x2_box, y2_box))
* for j in range(pooling_size): # <<<<<<<<<<<<<<
* y_contrib = minmax(j+1-y1_box)*minmax(y2_box-j)
* for k in range(pooling_size):
*/
__pyx_t_38 = __pyx_v_pooling_size;
for (__pyx_t_39 = 0; __pyx_t_39 < __pyx_t_38; __pyx_t_39+=1) {
__pyx_v_j = __pyx_t_39;
/* "draw_rectangles.pyx":62
* # print("{:.3f}, {:.3f}, {:.3f}, {:.3f}".format(x1_box, y1_box, x2_box, y2_box))
* for j in range(pooling_size):
* y_contrib = minmax(j+1-y1_box)*minmax(y2_box-j) # <<<<<<<<<<<<<<
* for k in range(pooling_size):
* x_contrib = minmax(k+1-x1_box)*minmax(x2_box-k)
*/
__pyx_v_y_contrib = (__pyx_f_15draw_rectangles_minmax(((__pyx_v_j + 1) - __pyx_v_y1_box)) * __pyx_f_15draw_rectangles_minmax((__pyx_v_y2_box - __pyx_v_j)));
/* "draw_rectangles.pyx":63
* for j in range(pooling_size):
* y_contrib = minmax(j+1-y1_box)*minmax(y2_box-j)
* for k in range(pooling_size): # <<<<<<<<<<<<<<
* x_contrib = minmax(k+1-x1_box)*minmax(x2_box-k)
* # print("j {} yc {} k {} xc {}".format(j, y_contrib, k, x_contrib))
*/
__pyx_t_40 = __pyx_v_pooling_size;
for (__pyx_t_41 = 0; __pyx_t_41 < __pyx_t_40; __pyx_t_41+=1) {
__pyx_v_k = __pyx_t_41;
/* "draw_rectangles.pyx":64
* y_contrib = minmax(j+1-y1_box)*minmax(y2_box-j)
* for k in range(pooling_size):
* x_contrib = minmax(k+1-x1_box)*minmax(x2_box-k) # <<<<<<<<<<<<<<
* # print("j {} yc {} k {} xc {}".format(j, y_contrib, k, x_contrib))
* uboxes[n,i,j,k] = x_contrib*y_contrib
*/
__pyx_v_x_contrib = (__pyx_f_15draw_rectangles_minmax(((__pyx_v_k + 1) - __pyx_v_x1_box)) * __pyx_f_15draw_rectangles_minmax((__pyx_v_x2_box - __pyx_v_k)));
/* "draw_rectangles.pyx":66
* x_contrib = minmax(k+1-x1_box)*minmax(x2_box-k)
* # print("j {} yc {} k {} xc {}".format(j, y_contrib, k, x_contrib))
* uboxes[n,i,j,k] = x_contrib*y_contrib # <<<<<<<<<<<<<<
* return uboxes
*/
__pyx_t_42 = __pyx_v_n;
__pyx_t_43 = __pyx_v_i;
__pyx_t_44 = __pyx_v_j;
__pyx_t_45 = __pyx_v_k;
__pyx_t_11 = -1;
if (unlikely(__pyx_t_42 >= (size_t)__pyx_pybuffernd_uboxes.diminfo[0].shape)) __pyx_t_11 = 0;
if (unlikely(__pyx_t_43 >= (size_t)__pyx_pybuffernd_uboxes.diminfo[1].shape)) __pyx_t_11 = 1;
if (unlikely(__pyx_t_44 >= (size_t)__pyx_pybuffernd_uboxes.diminfo[2].shape)) __pyx_t_11 = 2;
if (unlikely(__pyx_t_45 >= (size_t)__pyx_pybuffernd_uboxes.diminfo[3].shape)) __pyx_t_11 = 3;
if (unlikely(__pyx_t_11 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_11);
__PYX_ERR(0, 66, __pyx_L1_error)
}
*__Pyx_BufPtrStrided4d(__pyx_t_15draw_rectangles_DTYPE_t *, __pyx_pybuffernd_uboxes.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_uboxes.diminfo[0].strides, __pyx_t_43, __pyx_pybuffernd_uboxes.diminfo[1].strides, __pyx_t_44, __pyx_pybuffernd_uboxes.diminfo[2].strides, __pyx_t_45, __pyx_pybuffernd_uboxes.diminfo[3].strides) = (__pyx_v_x_contrib * __pyx_v_y_contrib);
}
}
}
}
/* "draw_rectangles.pyx":67
* # print("j {} yc {} k {} xc {}".format(j, y_contrib, k, x_contrib))
* uboxes[n,i,j,k] = x_contrib*y_contrib
* return uboxes # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
__Pyx_INCREF(((PyObject *)__pyx_v_uboxes));
__pyx_r = ((PyArrayObject *)__pyx_v_uboxes);
goto __pyx_L0;
/* "draw_rectangles.pyx":27
* return min(max(x, 0), 1)
*
* cdef np.ndarray[DTYPE_t, ndim=4] draw_union_boxes_c( # <<<<<<<<<<<<<<
* np.ndarray[DTYPE_t, ndim=2] box_pairs, unsigned int pooling_size):
* """
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_box_pairs.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_uboxes.rcbuffer->pybuffer);
__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
__Pyx_AddTraceback("draw_rectangles.draw_union_boxes_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
goto __pyx_L2;
__pyx_L0:;
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_box_pairs.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_uboxes.rcbuffer->pybuffer);
__pyx_L2:;
__Pyx_XDECREF((PyObject *)__pyx_v_uboxes);
__Pyx_XGIVEREF((PyObject *)__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":197
* # experimental exception made for __getbuffer__ and __releasebuffer__
* # -- the details of this may change.
* def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<<
* # This implementation of getbuffer is geared towards Cython
* # requirements, and does not yet fullfill the PEP.
*/
/* Python wrapper */
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
__pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
int __pyx_v_copy_shape;
int __pyx_v_i;
int __pyx_v_ndim;
int __pyx_v_endian_detector;
int __pyx_v_little_endian;
int __pyx_v_t;
char *__pyx_v_f;
PyArray_Descr *__pyx_v_descr = 0;
int __pyx_v_offset;
int __pyx_v_hasfields;
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
int __pyx_t_5;
PyObject *__pyx_t_6 = NULL;
char *__pyx_t_7;
__Pyx_RefNannySetupContext("__getbuffer__", 0);
if (__pyx_v_info != NULL) {
__pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
__Pyx_GIVEREF(__pyx_v_info->obj);
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":203
* # of flags
*
* if info == NULL: return # <<<<<<<<<<<<<<
*
* cdef int copy_shape, i, ndim
*/
__pyx_t_1 = ((__pyx_v_info == NULL) != 0);
if (__pyx_t_1) {
__pyx_r = 0;
goto __pyx_L0;
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":206
*
* cdef int copy_shape, i, ndim
* cdef int endian_detector = 1 # <<<<<<<<<<<<<<
* cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
*
*/
__pyx_v_endian_detector = 1;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":207
* cdef int copy_shape, i, ndim
* cdef int endian_detector = 1
* cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<<
*
* ndim = PyArray_NDIM(self)
*/
__pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":209
* cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
*
* ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<<
*
* if sizeof(npy_intp) != sizeof(Py_ssize_t):
*/
__pyx_v_ndim = PyArray_NDIM(__pyx_v_self);
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":211
* ndim = PyArray_NDIM(self)
*
* if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
* copy_shape = 1
* else:
*/
__pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
if (__pyx_t_1) {
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":212
*
* if sizeof(npy_intp) != sizeof(Py_ssize_t):
* copy_shape = 1 # <<<<<<<<<<<<<<
* else:
* copy_shape = 0
*/
__pyx_v_copy_shape = 1;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":211
* ndim = PyArray_NDIM(self)
*
* if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
* copy_shape = 1
* else:
*/
goto __pyx_L4;
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":214
* copy_shape = 1
* else:
* copy_shape = 0 # <<<<<<<<<<<<<<
*
* if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
*/
/*else*/ {
__pyx_v_copy_shape = 0;
}
__pyx_L4:;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":216
* copy_shape = 0
*
* if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<<
* and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
* raise ValueError(u"ndarray is not C contiguous")
*/
__pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L6_bool_binop_done;
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":217
*
* if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
* and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<<
* raise ValueError(u"ndarray is not C contiguous")
*
*/
__pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L6_bool_binop_done:;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":216
* copy_shape = 0
*
* if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<<
* and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
* raise ValueError(u"ndarray is not C contiguous")
*/
if (__pyx_t_1) {
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":218
* if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
* and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
* raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<<
*
* if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(1, 218, __pyx_L1_error)
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":216
* copy_shape = 0
*
* if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<<
* and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
* raise ValueError(u"ndarray is not C contiguous")
*/
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":220
* raise ValueError(u"ndarray is not C contiguous")
*
* if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<<
* and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
* raise ValueError(u"ndarray is not Fortran contiguous")
*/
__pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L9_bool_binop_done;
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":221
*
* if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
* and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<<
* raise ValueError(u"ndarray is not Fortran contiguous")
*
*/
__pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L9_bool_binop_done:;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":220
* raise ValueError(u"ndarray is not C contiguous")
*
* if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<<
* and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
* raise ValueError(u"ndarray is not Fortran contiguous")
*/
if (__pyx_t_1) {
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":222
* if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
* and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
* raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<<
*
* info.buf = PyArray_DATA(self)
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(1, 222, __pyx_L1_error)
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":220
* raise ValueError(u"ndarray is not C contiguous")
*
* if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<<
* and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
* raise ValueError(u"ndarray is not Fortran contiguous")
*/
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":224
* raise ValueError(u"ndarray is not Fortran contiguous")
*
* info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<<
* info.ndim = ndim
* if copy_shape:
*/
__pyx_v_info->buf = PyArray_DATA(__pyx_v_self);
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":225
*
* info.buf = PyArray_DATA(self)
* info.ndim = ndim # <<<<<<<<<<<<<<
* if copy_shape:
* # Allocate new buffer for strides and shape info.
*/
__pyx_v_info->ndim = __pyx_v_ndim;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":226
* info.buf = PyArray_DATA(self)
* info.ndim = ndim
* if copy_shape: # <<<<<<<<<<<<<<
* # Allocate new buffer for strides and shape info.
* # This is allocated as one block, strides first.
*/
__pyx_t_1 = (__pyx_v_copy_shape != 0);
if (__pyx_t_1) {
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":229
* # Allocate new buffer for strides and shape info.
* # This is allocated as one block, strides first.
* info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2) # <<<<<<<<<<<<<<
* info.shape = info.strides + ndim
* for i in range(ndim):
*/
__pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2)));
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":230
* # This is allocated as one block, strides first.
* info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
* info.shape = info.strides + ndim # <<<<<<<<<<<<<<
* for i in range(ndim):
* info.strides[i] = PyArray_STRIDES(self)[i]
*/
__pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":231
* info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
* info.shape = info.strides + ndim
* for i in range(ndim): # <<<<<<<<<<<<<<
* info.strides[i] = PyArray_STRIDES(self)[i]
* info.shape[i] = PyArray_DIMS(self)[i]
*/
__pyx_t_4 = __pyx_v_ndim;
for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
__pyx_v_i = __pyx_t_5;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":232
* info.shape = info.strides + ndim
* for i in range(ndim):
* info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<<
* info.shape[i] = PyArray_DIMS(self)[i]
* else:
*/
(__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]);
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":233
* for i in range(ndim):
* info.strides[i] = PyArray_STRIDES(self)[i]
* info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<<
* else:
* info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
*/
(__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]);
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":226
* info.buf = PyArray_DATA(self)
* info.ndim = ndim
* if copy_shape: # <<<<<<<<<<<<<<
* # Allocate new buffer for strides and shape info.
* # This is allocated as one block, strides first.
*/
goto __pyx_L11;
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":235
* info.shape[i] = PyArray_DIMS(self)[i]
* else:
* info.strides = <Py_ssize_t*>PyArray_STRIDES(self) # <<<<<<<<<<<<<<
* info.shape = <Py_ssize_t*>PyArray_DIMS(self)
* info.suboffsets = NULL
*/
/*else*/ {
__pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self));
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":236
* else:
* info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
* info.shape = <Py_ssize_t*>PyArray_DIMS(self) # <<<<<<<<<<<<<<
* info.suboffsets = NULL
* info.itemsize = PyArray_ITEMSIZE(self)
*/
__pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self));
}
__pyx_L11:;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":237
* info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
* info.shape = <Py_ssize_t*>PyArray_DIMS(self)
* info.suboffsets = NULL # <<<<<<<<<<<<<<
* info.itemsize = PyArray_ITEMSIZE(self)
* info.readonly = not PyArray_ISWRITEABLE(self)
*/
__pyx_v_info->suboffsets = NULL;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":238
* info.shape = <Py_ssize_t*>PyArray_DIMS(self)
* info.suboffsets = NULL
* info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<<
* info.readonly = not PyArray_ISWRITEABLE(self)
*
*/
__pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self);
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":239
* info.suboffsets = NULL
* info.itemsize = PyArray_ITEMSIZE(self)
* info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<<
*
* cdef int t
*/
__pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0));
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":242
*
* cdef int t
* cdef char* f = NULL # <<<<<<<<<<<<<<
* cdef dtype descr = self.descr
* cdef int offset
*/
__pyx_v_f = NULL;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":243
* cdef int t
* cdef char* f = NULL
* cdef dtype descr = self.descr # <<<<<<<<<<<<<<
* cdef int offset
*
*/
__pyx_t_3 = ((PyObject *)__pyx_v_self->descr);
__Pyx_INCREF(__pyx_t_3);
__pyx_v_descr = ((PyArray_Descr *)__pyx_t_3);
__pyx_t_3 = 0;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":246
* cdef int offset
*
* cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<<
*
* if not hasfields and not copy_shape:
*/
__pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":248
* cdef bint hasfields = PyDataType_HASFIELDS(descr)
*
* if not hasfields and not copy_shape: # <<<<<<<<<<<<<<
* # do not call releasebuffer
* info.obj = None
*/
__pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L15_bool_binop_done;
}
__pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L15_bool_binop_done:;
if (__pyx_t_1) {
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":250
* if not hasfields and not copy_shape:
* # do not call releasebuffer
* info.obj = None # <<<<<<<<<<<<<<
* else:
* # need to call releasebuffer
*/
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj);
__pyx_v_info->obj = Py_None;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":248
* cdef bint hasfields = PyDataType_HASFIELDS(descr)
*
* if not hasfields and not copy_shape: # <<<<<<<<<<<<<<
* # do not call releasebuffer
* info.obj = None
*/
goto __pyx_L14;
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":253
* else:
* # need to call releasebuffer
* info.obj = self # <<<<<<<<<<<<<<
*
* if not hasfields:
*/
/*else*/ {
__Pyx_INCREF(((PyObject *)__pyx_v_self));
__Pyx_GIVEREF(((PyObject *)__pyx_v_self));
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj);
__pyx_v_info->obj = ((PyObject *)__pyx_v_self);
}
__pyx_L14:;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":255
* info.obj = self
*
* if not hasfields: # <<<<<<<<<<<<<<
* t = descr.type_num
* if ((descr.byteorder == c'>' and little_endian) or
*/
__pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0);
if (__pyx_t_1) {
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":256
*
* if not hasfields:
* t = descr.type_num # <<<<<<<<<<<<<<
* if ((descr.byteorder == c'>' and little_endian) or
* (descr.byteorder == c'<' and not little_endian)):
*/
__pyx_t_4 = __pyx_v_descr->type_num;
__pyx_v_t = __pyx_t_4;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":257
* if not hasfields:
* t = descr.type_num
* if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
* (descr.byteorder == c'<' and not little_endian)):
* raise ValueError(u"Non-native byte order not supported")
*/
__pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0);
if (!__pyx_t_2) {
goto __pyx_L20_next_or;
} else {
}
__pyx_t_2 = (__pyx_v_little_endian != 0);
if (!__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L19_bool_binop_done;
}
__pyx_L20_next_or:;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":258
* t = descr.type_num
* if ((descr.byteorder == c'>' and little_endian) or
* (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<<
* raise ValueError(u"Non-native byte order not supported")
* if t == NPY_BYTE: f = "b"
*/
__pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L19_bool_binop_done;
}
__pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L19_bool_binop_done:;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":257
* if not hasfields:
* t = descr.type_num
* if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
* (descr.byteorder == c'<' and not little_endian)):
* raise ValueError(u"Non-native byte order not supported")
*/
if (__pyx_t_1) {
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":259
* if ((descr.byteorder == c'>' and little_endian) or
* (descr.byteorder == c'<' and not little_endian)):
* raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<<
* if t == NPY_BYTE: f = "b"
* elif t == NPY_UBYTE: f = "B"
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(1, 259, __pyx_L1_error)
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":257
* if not hasfields:
* t = descr.type_num
* if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
* (descr.byteorder == c'<' and not little_endian)):
* raise ValueError(u"Non-native byte order not supported")
*/
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":260
* (descr.byteorder == c'<' and not little_endian)):
* raise ValueError(u"Non-native byte order not supported")
* if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<<
* elif t == NPY_UBYTE: f = "B"
* elif t == NPY_SHORT: f = "h"
*/
switch (__pyx_v_t) {
case NPY_BYTE:
__pyx_v_f = ((char *)"b");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":261
* raise ValueError(u"Non-native byte order not supported")
* if t == NPY_BYTE: f = "b"
* elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<<
* elif t == NPY_SHORT: f = "h"
* elif t == NPY_USHORT: f = "H"
*/
case NPY_UBYTE:
__pyx_v_f = ((char *)"B");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":262
* if t == NPY_BYTE: f = "b"
* elif t == NPY_UBYTE: f = "B"
* elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<<
* elif t == NPY_USHORT: f = "H"
* elif t == NPY_INT: f = "i"
*/
case NPY_SHORT:
__pyx_v_f = ((char *)"h");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":263
* elif t == NPY_UBYTE: f = "B"
* elif t == NPY_SHORT: f = "h"
* elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<<
* elif t == NPY_INT: f = "i"
* elif t == NPY_UINT: f = "I"
*/
case NPY_USHORT:
__pyx_v_f = ((char *)"H");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":264
* elif t == NPY_SHORT: f = "h"
* elif t == NPY_USHORT: f = "H"
* elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<<
* elif t == NPY_UINT: f = "I"
* elif t == NPY_LONG: f = "l"
*/
case NPY_INT:
__pyx_v_f = ((char *)"i");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":265
* elif t == NPY_USHORT: f = "H"
* elif t == NPY_INT: f = "i"
* elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<<
* elif t == NPY_LONG: f = "l"
* elif t == NPY_ULONG: f = "L"
*/
case NPY_UINT:
__pyx_v_f = ((char *)"I");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":266
* elif t == NPY_INT: f = "i"
* elif t == NPY_UINT: f = "I"
* elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<<
* elif t == NPY_ULONG: f = "L"
* elif t == NPY_LONGLONG: f = "q"
*/
case NPY_LONG:
__pyx_v_f = ((char *)"l");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":267
* elif t == NPY_UINT: f = "I"
* elif t == NPY_LONG: f = "l"
* elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<<
* elif t == NPY_LONGLONG: f = "q"
* elif t == NPY_ULONGLONG: f = "Q"
*/
case NPY_ULONG:
__pyx_v_f = ((char *)"L");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":268
* elif t == NPY_LONG: f = "l"
* elif t == NPY_ULONG: f = "L"
* elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<<
* elif t == NPY_ULONGLONG: f = "Q"
* elif t == NPY_FLOAT: f = "f"
*/
case NPY_LONGLONG:
__pyx_v_f = ((char *)"q");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":269
* elif t == NPY_ULONG: f = "L"
* elif t == NPY_LONGLONG: f = "q"
* elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<<
* elif t == NPY_FLOAT: f = "f"
* elif t == NPY_DOUBLE: f = "d"
*/
case NPY_ULONGLONG:
__pyx_v_f = ((char *)"Q");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":270
* elif t == NPY_LONGLONG: f = "q"
* elif t == NPY_ULONGLONG: f = "Q"
* elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<<
* elif t == NPY_DOUBLE: f = "d"
* elif t == NPY_LONGDOUBLE: f = "g"
*/
case NPY_FLOAT:
__pyx_v_f = ((char *)"f");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":271
* elif t == NPY_ULONGLONG: f = "Q"
* elif t == NPY_FLOAT: f = "f"
* elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<<
* elif t == NPY_LONGDOUBLE: f = "g"
* elif t == NPY_CFLOAT: f = "Zf"
*/
case NPY_DOUBLE:
__pyx_v_f = ((char *)"d");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":272
* elif t == NPY_FLOAT: f = "f"
* elif t == NPY_DOUBLE: f = "d"
* elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<<
* elif t == NPY_CFLOAT: f = "Zf"
* elif t == NPY_CDOUBLE: f = "Zd"
*/
case NPY_LONGDOUBLE:
__pyx_v_f = ((char *)"g");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":273
* elif t == NPY_DOUBLE: f = "d"
* elif t == NPY_LONGDOUBLE: f = "g"
* elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<<
* elif t == NPY_CDOUBLE: f = "Zd"
* elif t == NPY_CLONGDOUBLE: f = "Zg"
*/
case NPY_CFLOAT:
__pyx_v_f = ((char *)"Zf");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":274
* elif t == NPY_LONGDOUBLE: f = "g"
* elif t == NPY_CFLOAT: f = "Zf"
* elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<<
* elif t == NPY_CLONGDOUBLE: f = "Zg"
* elif t == NPY_OBJECT: f = "O"
*/
case NPY_CDOUBLE:
__pyx_v_f = ((char *)"Zd");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":275
* elif t == NPY_CFLOAT: f = "Zf"
* elif t == NPY_CDOUBLE: f = "Zd"
* elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<<
* elif t == NPY_OBJECT: f = "O"
* else:
*/
case NPY_CLONGDOUBLE:
__pyx_v_f = ((char *)"Zg");
break;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":276
* elif t == NPY_CDOUBLE: f = "Zd"
* elif t == NPY_CLONGDOUBLE: f = "Zg"
* elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<<
* else:
* raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
*/
case NPY_OBJECT:
__pyx_v_f = ((char *)"O");
break;
default:
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":278
* elif t == NPY_OBJECT: f = "O"
* else:
* raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<<
* info.format = f
* return
*/
__pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
__pyx_t_6 = 0;
__pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_6, 0, 0, 0);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__PYX_ERR(1, 278, __pyx_L1_error)
break;
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":279
* else:
* raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
* info.format = f # <<<<<<<<<<<<<<
* return
* else:
*/
__pyx_v_info->format = __pyx_v_f;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":280
* raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
* info.format = f
* return # <<<<<<<<<<<<<<
* else:
* info.format = <char*>stdlib.malloc(_buffer_format_string_len)
*/
__pyx_r = 0;
goto __pyx_L0;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":255
* info.obj = self
*
* if not hasfields: # <<<<<<<<<<<<<<
* t = descr.type_num
* if ((descr.byteorder == c'>' and little_endian) or
*/
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":282
* return
* else:
* info.format = <char*>stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<<
* info.format[0] = c'^' # Native data types, manual alignment
* offset = 0
*/
/*else*/ {
__pyx_v_info->format = ((char *)malloc(0xFF));
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":283
* else:
* info.format = <char*>stdlib.malloc(_buffer_format_string_len)
* info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<<
* offset = 0
* f = _util_dtypestring(descr, info.format + 1,
*/
(__pyx_v_info->format[0]) = '^';
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":284
* info.format = <char*>stdlib.malloc(_buffer_format_string_len)
* info.format[0] = c'^' # Native data types, manual alignment
* offset = 0 # <<<<<<<<<<<<<<
* f = _util_dtypestring(descr, info.format + 1,
* info.format + _buffer_format_string_len,
*/
__pyx_v_offset = 0;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":285
* info.format[0] = c'^' # Native data types, manual alignment
* offset = 0
* f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<<
* info.format + _buffer_format_string_len,
* &offset)
*/
__pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(1, 285, __pyx_L1_error)
__pyx_v_f = __pyx_t_7;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":288
* info.format + _buffer_format_string_len,
* &offset)
* f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<<
*
* def __releasebuffer__(ndarray self, Py_buffer* info):
*/
(__pyx_v_f[0]) = '\x00';
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":197
* # experimental exception made for __getbuffer__ and __releasebuffer__
* # -- the details of this may change.
* def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<<
* # This implementation of getbuffer is geared towards Cython
* # requirements, and does not yet fullfill the PEP.
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
}
goto __pyx_L2;
__pyx_L0:;
if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
__Pyx_GOTREF(Py_None);
__Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
}
__pyx_L2:;
__Pyx_XDECREF((PyObject *)__pyx_v_descr);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":290
* f[0] = c'\0' # Terminate format string
*
* def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<<
* if PyArray_HASFIELDS(self):
* stdlib.free(info.format)
*/
/* Python wrapper */
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
__pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));
/* function exit code */
__Pyx_RefNannyFinishContext();
}
static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
__Pyx_RefNannyDeclarations
int __pyx_t_1;
__Pyx_RefNannySetupContext("__releasebuffer__", 0);
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":291
*
* def __releasebuffer__(ndarray self, Py_buffer* info):
* if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<<
* stdlib.free(info.format)
* if sizeof(npy_intp) != sizeof(Py_ssize_t):
*/
__pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0);
if (__pyx_t_1) {
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":292
* def __releasebuffer__(ndarray self, Py_buffer* info):
* if PyArray_HASFIELDS(self):
* stdlib.free(info.format) # <<<<<<<<<<<<<<
* if sizeof(npy_intp) != sizeof(Py_ssize_t):
* stdlib.free(info.strides)
*/
free(__pyx_v_info->format);
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":291
*
* def __releasebuffer__(ndarray self, Py_buffer* info):
* if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<<
* stdlib.free(info.format)
* if sizeof(npy_intp) != sizeof(Py_ssize_t):
*/
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":293
* if PyArray_HASFIELDS(self):
* stdlib.free(info.format)
* if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
* stdlib.free(info.strides)
* # info.shape was stored after info.strides in the same block
*/
__pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
if (__pyx_t_1) {
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":294
* stdlib.free(info.format)
* if sizeof(npy_intp) != sizeof(Py_ssize_t):
* stdlib.free(info.strides) # <<<<<<<<<<<<<<
* # info.shape was stored after info.strides in the same block
*
*/
free(__pyx_v_info->strides);
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":293
* if PyArray_HASFIELDS(self):
* stdlib.free(info.format)
* if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
* stdlib.free(info.strides)
* # info.shape was stored after info.strides in the same block
*/
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":290
* f[0] = c'\0' # Terminate format string
*
* def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<<
* if PyArray_HASFIELDS(self):
* stdlib.free(info.format)
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":770
* ctypedef npy_cdouble complex_t
*
* cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<<
* return PyArray_MultiIterNew(1, <void*>a)
*
*/
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":771
*
* cdef inline object PyArray_MultiIterNew1(a):
* return PyArray_MultiIterNew(1, <void*>a) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_MultiIterNew2(a, b):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 771, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":770
* ctypedef npy_cdouble complex_t
*
* cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<<
* return PyArray_MultiIterNew(1, <void*>a)
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":773
* return PyArray_MultiIterNew(1, <void*>a)
*
* cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<<
* return PyArray_MultiIterNew(2, <void*>a, <void*>b)
*
*/
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":774
*
* cdef inline object PyArray_MultiIterNew2(a, b):
* return PyArray_MultiIterNew(2, <void*>a, <void*>b) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_MultiIterNew3(a, b, c):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 774, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":773
* return PyArray_MultiIterNew(1, <void*>a)
*
* cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<<
* return PyArray_MultiIterNew(2, <void*>a, <void*>b)
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "../../../../anaconda/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":776
* return PyArray_MultiIterNew(2, <void*>a, <void
gitextract_tbpjfk2p/
├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── config.py
├── data/
│ └── stanford_filtered/
│ └── README.md
├── dataloaders/
│ ├── __init__.py
│ ├── blob.py
│ ├── image_transforms.py
│ ├── mscoco.py
│ └── visual_genome.py
├── docs/
│ ├── LICENSE.md
│ ├── _config.yaml
│ ├── _includes/
│ │ └── image.html
│ ├── _layouts/
│ │ └── default.html
│ ├── index.md
│ └── upload.sh
├── lib/
│ ├── __init__.py
│ ├── draw_rectangles/
│ │ ├── draw_rectangles.c
│ │ ├── draw_rectangles.pyx
│ │ └── setup.py
│ ├── evaluation/
│ │ ├── __init__.py
│ │ ├── sg_eval.py
│ │ ├── sg_eval_all_rel_cates.py
│ │ ├── sg_eval_slow.py
│ │ └── test_sg_eval.py
│ ├── fpn/
│ │ ├── anchor_targets.py
│ │ ├── box_intersections_cpu/
│ │ │ ├── bbox.c
│ │ │ ├── bbox.pyx
│ │ │ └── setup.py
│ │ ├── box_utils.py
│ │ ├── generate_anchors.py
│ │ ├── make.sh
│ │ ├── nms/
│ │ │ ├── Makefile
│ │ │ ├── build.py
│ │ │ ├── functions/
│ │ │ │ └── nms.py
│ │ │ └── src/
│ │ │ ├── cuda/
│ │ │ │ ├── Makefile
│ │ │ │ ├── nms_kernel.cu
│ │ │ │ └── nms_kernel.h
│ │ │ ├── nms_cuda.c
│ │ │ └── nms_cuda.h
│ │ ├── proposal_assignments/
│ │ │ ├── proposal_assignments_det.py
│ │ │ ├── proposal_assignments_gtbox.py
│ │ │ ├── proposal_assignments_postnms.py
│ │ │ ├── proposal_assignments_rel.py
│ │ │ └── rel_assignments.py
│ │ └── roi_align/
│ │ ├── Makefile
│ │ ├── __init__.py
│ │ ├── _ext/
│ │ │ ├── __init__.py
│ │ │ └── roi_align/
│ │ │ └── __init__.py
│ │ ├── build.py
│ │ ├── functions/
│ │ │ ├── __init__.py
│ │ │ └── roi_align.py
│ │ ├── modules/
│ │ │ ├── __init__.py
│ │ │ └── roi_align.py
│ │ └── src/
│ │ ├── cuda/
│ │ │ ├── Makefile
│ │ │ ├── roi_align_kernel.cu
│ │ │ └── roi_align_kernel.h
│ │ ├── roi_align_cuda.c
│ │ └── roi_align_cuda.h
│ ├── get_dataset_counts.py
│ ├── get_union_boxes.py
│ ├── lstm/
│ │ ├── __init__.py
│ │ ├── decoder_rnn.py
│ │ └── highway_lstm_cuda/
│ │ ├── __init__.py
│ │ ├── _ext/
│ │ │ ├── __init__.py
│ │ │ └── highway_lstm_layer/
│ │ │ └── __init__.py
│ │ ├── alternating_highway_lstm.py
│ │ ├── build.py
│ │ ├── make.sh
│ │ └── src/
│ │ ├── highway_lstm_cuda.c
│ │ ├── highway_lstm_cuda.h
│ │ ├── highway_lstm_kernel.cu
│ │ └── highway_lstm_kernel.h
│ ├── object_detector.py
│ ├── pytorch_misc.py
│ ├── rel_model.py
│ ├── rel_model_stanford.py
│ ├── resnet.py
│ ├── sparse_targets.py
│ ├── surgery.py
│ └── word_vectors.py
├── misc/
│ ├── __init__.py
│ ├── motifs.py
│ ├── object_types.txt
│ └── relation_types.txt
├── models/
│ ├── _visualize.py
│ ├── eval_rel_count.py
│ ├── eval_rels.py
│ ├── train_detector.py
│ └── train_rels.py
└── scripts/
├── eval_models_sgcls.sh
├── eval_models_sgdet.sh
├── pretrain_detector.sh
├── refine_for_detection.sh
├── train_models_sgcls.sh
├── train_motifnet.sh
└── train_stanford.sh
SYMBOL INDEX (639 symbols across 45 files)
FILE: config.py
function path (line 11) | def path(fn):
function stanford_path (line 14) | def stanford_path(fn):
class ModelConfig (line 63) | class ModelConfig(object):
method __init__ (line 65) | def __init__(self):
method setup_parser (line 143) | def setup_parser(self):
FILE: dataloaders/blob.py
class Blob (line 10) | class Blob(object):
method __init__ (line 11) | def __init__(self, mode='det', is_train=False, num_gpus=1, primary_gpu...
method is_flickr (line 52) | def is_flickr(self):
method is_rel (line 56) | def is_rel(self):
method volatile (line 60) | def volatile(self):
method append (line 63) | def append(self, d):
method _chunkize (line 110) | def _chunkize(self, datom, tensor=torch.LongTensor):
method reduce (line 122) | def reduce(self):
method _scatter (line 148) | def _scatter(self, x, chunk_sizes, dim=0):
method scatter (line 155) | def scatter(self):
method __getitem__ (line 182) | def __getitem__(self, index):
FILE: dataloaders/image_transforms.py
class SquarePad (line 8) | class SquarePad(object):
method __call__ (line 9) | def __call__(self, img):
class Grayscale (line 16) | class Grayscale(object):
method __call__ (line 20) | def __call__(self, img):
class Brightness (line 27) | class Brightness(object):
method __call__ (line 31) | def __call__(self, img):
class Contrast (line 40) | class Contrast(object):
method __call__ (line 44) | def __call__(self, img):
class Hue (line 53) | class Hue(object):
method __call__ (line 57) | def __call__(self, img):
class Sharpness (line 70) | class Sharpness(object):
method __call__ (line 74) | def __call__(self, img):
function random_crop (line 81) | def random_crop(img, boxes, box_scale, round_boxes=True, max_crop_fracti...
class RandomOrder (line 115) | class RandomOrder(object):
method __init__ (line 119) | def __init__(self, transforms):
method __call__ (line 122) | def __call__(self, img):
FILE: dataloaders/mscoco.py
class CocoDetection (line 13) | class CocoDetection(Dataset):
method __init__ (line 18) | def __init__(self, mode):
method is_train (line 55) | def is_train(self):
method __getitem__ (line 58) | def __getitem__(self, index):
method splits (line 130) | def splits(cls, *args, **kwargs):
method __len__ (line 136) | def __len__(self):
function coco_collate (line 140) | def coco_collate(data, num_gpus=3, is_train=False):
class CocoDataLoader (line 149) | class CocoDataLoader(torch.utils.data.DataLoader):
method splits (line 162) | def splits(cls, train_data, val_data, batch_size=3, num_workers=1, num...
FILE: dataloaders/visual_genome.py
class VG (line 23) | class VG(Dataset):
method __init__ (line 24) | def __init__(self, mode, roidb_file=VG_SGG_FN, dict_file=VG_SGG_DICT_FN,
method coco (line 103) | def coco(self):
method is_train (line 130) | def is_train(self):
method splits (line 134) | def splits(cls, *args, **kwargs):
method __getitem__ (line 141) | def __getitem__(self, index):
method __len__ (line 205) | def __len__(self):
method num_predicates (line 209) | def num_predicates(self):
method num_classes (line 213) | def num_classes(self):
function assertion_checks (line 222) | def assertion_checks(entry):
function load_image_filenames (line 239) | def load_image_filenames(image_file, image_dir=VG_IMAGES):
function load_graphs (line 264) | def load_graphs(graphs_file, mode='train', num_im=-1, num_val_im=0, filt...
function load_info (line 365) | def load_info(info_file):
function vg_collate (line 384) | def vg_collate(data, num_gpus=3, is_train=False, mode='det'):
class VGDataLoader (line 394) | class VGDataLoader(torch.utils.data.DataLoader):
method splits (line 401) | def splits(cls, train_data, val_data, batch_size=3, num_workers=1, num...
FILE: lib/draw_rectangles/draw_rectangles.c
type PyObject (line 195) | typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **a...
type Py_hash_t (line 317) | typedef long Py_hash_t;
type __Pyx_PyAsyncMethodsStruct (line 334) | typedef struct {
function CYTHON_INLINE (line 405) | static CYTHON_INLINE float __PYX_NAN() {
type __Pyx_StringTabEntry (line 454) | typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const c...
function CYTHON_INLINE (line 512) | static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
function __Pyx_init_sys_getdefaultencoding_params (line 545) | static int __Pyx_init_sys_getdefaultencoding_params(void) {
function __Pyx_init_sys_getdefaultencoding_params (line 595) | static int __Pyx_init_sys_getdefaultencoding_params(void) {
type __Pyx_StructField_ (line 669) | struct __Pyx_StructField_
type __Pyx_TypeInfo (line 671) | typedef struct {
type __Pyx_StructField (line 681) | typedef struct __Pyx_StructField_ {
type __Pyx_BufFmt_StackElem (line 686) | typedef struct {
type __Pyx_BufFmt_Context (line 690) | typedef struct {
type npy_int8 (line 711) | typedef npy_int8 __pyx_t_5numpy_int8_t;
type npy_int16 (line 720) | typedef npy_int16 __pyx_t_5numpy_int16_t;
type npy_int32 (line 729) | typedef npy_int32 __pyx_t_5numpy_int32_t;
type npy_int64 (line 738) | typedef npy_int64 __pyx_t_5numpy_int64_t;
type npy_uint8 (line 747) | typedef npy_uint8 __pyx_t_5numpy_uint8_t;
type npy_uint16 (line 756) | typedef npy_uint16 __pyx_t_5numpy_uint16_t;
type npy_uint32 (line 765) | typedef npy_uint32 __pyx_t_5numpy_uint32_t;
type npy_uint64 (line 774) | typedef npy_uint64 __pyx_t_5numpy_uint64_t;
type npy_float32 (line 783) | typedef npy_float32 __pyx_t_5numpy_float32_t;
type npy_float64 (line 792) | typedef npy_float64 __pyx_t_5numpy_float64_t;
type npy_long (line 801) | typedef npy_long __pyx_t_5numpy_int_t;
type npy_longlong (line 810) | typedef npy_longlong __pyx_t_5numpy_long_t;
type npy_longlong (line 819) | typedef npy_longlong __pyx_t_5numpy_longlong_t;
type npy_ulong (line 828) | typedef npy_ulong __pyx_t_5numpy_uint_t;
type npy_ulonglong (line 837) | typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
type npy_ulonglong (line 846) | typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
type npy_intp (line 855) | typedef npy_intp __pyx_t_5numpy_intp_t;
type npy_uintp (line 864) | typedef npy_uintp __pyx_t_5numpy_uintp_t;
type npy_double (line 873) | typedef npy_double __pyx_t_5numpy_float_t;
type npy_double (line 882) | typedef npy_double __pyx_t_5numpy_double_t;
type npy_longdouble (line 891) | typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
type __pyx_t_5numpy_float32_t (line 900) | typedef __pyx_t_5numpy_float32_t __pyx_t_15draw_rectangles_DTYPE_t;
type std (line 904) | typedef ::std::complex< float > __pyx_t_float_complex;
type __pyx_t_float_complex (line 906) | typedef float _Complex __pyx_t_float_complex;
type __pyx_t_float_complex (line 909) | typedef struct { float real, imag; } __pyx_t_float_complex;
type std (line 916) | typedef ::std::complex< double > __pyx_t_double_complex;
type __pyx_t_double_complex (line 918) | typedef double _Complex __pyx_t_double_complex;
type __pyx_t_double_complex (line 921) | typedef struct { double real, imag; } __pyx_t_double_complex;
type npy_cfloat (line 935) | typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
type npy_cdouble (line 944) | typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
type npy_clongdouble (line 953) | typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
type npy_cdouble (line 962) | typedef npy_cdouble __pyx_t_5numpy_complex_t;
type __Pyx_RefNannyAPIStruct (line 970) | typedef struct {
function CYTHON_INLINE (line 1030) | static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, ...
function PyObject (line 1123) | static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
type __Pyx_CodeObjectCacheEntry (line 1182) | typedef struct {
type __Pyx_CodeObjectCache (line 1186) | struct __Pyx_CodeObjectCache {
type __Pyx_CodeObjectCache (line 1191) | struct __Pyx_CodeObjectCache
type __Pyx_Buf_DimInfo (line 1201) | typedef struct {
type __Pyx_Buffer (line 1204) | typedef struct {
type __Pyx_LocalBuf_ND (line 1208) | typedef struct {
type NPY_TYPES (line 1332) | enum NPY_TYPES
function PyObject (line 1496) | static PyObject *__pyx_pw_15draw_rectangles_1draw_union_boxes(PyObject *...
function PyObject (line 1564) | static PyObject *__pyx_pf_15draw_rectangles_draw_union_boxes(CYTHON_UNUS...
function __pyx_t_15draw_rectangles_DTYPE_t (line 1635) | static __pyx_t_15draw_rectangles_DTYPE_t __pyx_f_15draw_rectangles_minma...
function CYTHON_UNUSED (line 2301) | static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObjec...
function __pyx_pf_5numpy_7ndarray___getbuffer__ (line 2312) | static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v...
function CYTHON_UNUSED (line 3173) | static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(Py...
function __pyx_pf_5numpy_7ndarray_2__releasebuffer__ (line 3182) | static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *_...
function CYTHON_INLINE (line 3263) | static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyOb...
function CYTHON_INLINE (line 3310) | static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyOb...
function CYTHON_INLINE (line 3357) | static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyOb...
function CYTHON_INLINE (line 3404) | static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyOb...
function CYTHON_INLINE (line 3451) | static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyOb...
function CYTHON_INLINE (line 3498) | static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Desc...
function CYTHON_INLINE (line 4253) | static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *_...
function CYTHON_INLINE (line 4349) | static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObje...
function CYTHON_INLINE (line 4423) | static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
function CYTHON_INLINE (line 4554) | static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
function CYTHON_INLINE (line 4685) | static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
type PyModuleDef (line 4810) | struct PyModuleDef
function __Pyx_InitCachedBuiltins (line 4858) | static int __Pyx_InitCachedBuiltins(void) {
function __Pyx_InitCachedConstants (line 4868) | static int __Pyx_InitCachedConstants(void) {
function __Pyx_InitGlobals (line 4987) | static int __Pyx_InitGlobals(void) {
function PyMODINIT_FUNC (line 5001) | PyMODINIT_FUNC PyInit_draw_rectangles(void)
function __Pyx_RefNannyAPIStruct (line 5184) | static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modn...
function PyObject (line 5200) | static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
function __Pyx_RaiseArgtupleInvalid (line 5214) | static void __Pyx_RaiseArgtupleInvalid(
function __Pyx_RaiseDoubleKeywordsError (line 5240) | static void __Pyx_RaiseDoubleKeywordsError(
function __Pyx_ParseOptionalKeywords (line 5254) | static int __Pyx_ParseOptionalKeywords(
function PyObject (line 5357) | static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON...
function CYTHON_INLINE (line 5441) | static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *typ...
function CYTHON_INLINE (line 5454) | static CYTHON_INLINE int __Pyx_IsLittleEndian(void) {
function __Pyx_BufFmt_Init (line 5458) | static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
function __Pyx_BufFmt_ParseNumber (line 5485) | static int __Pyx_BufFmt_ParseNumber(const char** ts) {
function __Pyx_BufFmt_ExpectNumber (line 5500) | static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
function __Pyx_BufFmt_RaiseUnexpectedChar (line 5507) | static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
function __Pyx_BufFmt_TypeCharToStandardSize (line 5535) | static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_comple...
function __Pyx_BufFmt_TypeCharToNativeSize (line 5553) | static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
type __Pyx_st_short (line 5572) | typedef struct { char c; short x; } __Pyx_st_short;
type __Pyx_st_int (line 5573) | typedef struct { char c; int x; } __Pyx_st_int;
type __Pyx_st_long (line 5574) | typedef struct { char c; long x; } __Pyx_st_long;
type __Pyx_st_float (line 5575) | typedef struct { char c; float x; } __Pyx_st_float;
type __Pyx_st_double (line 5576) | typedef struct { char c; double x; } __Pyx_st_double;
type __Pyx_st_longdouble (line 5577) | typedef struct { char c; long double x; } __Pyx_st_longdouble;
type __Pyx_st_void_p (line 5578) | typedef struct { char c; void *x; } __Pyx_st_void_p;
type __Pyx_st_longlong (line 5580) | typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
function __Pyx_BufFmt_TypeCharToAlignment (line 5582) | static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED in...
type __Pyx_pad_short (line 5604) | typedef struct { short x; char c; } __Pyx_pad_short;
type __Pyx_pad_int (line 5605) | typedef struct { int x; char c; } __Pyx_pad_int;
type __Pyx_pad_long (line 5606) | typedef struct { long x; char c; } __Pyx_pad_long;
type __Pyx_pad_float (line 5607) | typedef struct { float x; char c; } __Pyx_pad_float;
type __Pyx_pad_double (line 5608) | typedef struct { double x; char c; } __Pyx_pad_double;
type __Pyx_pad_longdouble (line 5609) | typedef struct { long double x; char c; } __Pyx_pad_longdouble;
type __Pyx_pad_void_p (line 5610) | typedef struct { void *x; char c; } __Pyx_pad_void_p;
type __Pyx_pad_longlong (line 5612) | typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
function __Pyx_BufFmt_TypeCharToPadding (line 5614) | static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int ...
function __Pyx_BufFmt_TypeCharToGroup (line 5632) | static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
function __Pyx_BufFmt_RaiseExpected (line 5653) | static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
function __Pyx_BufFmt_ProcessTypeChunk (line 5677) | static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
function CYTHON_INLINE (line 5779) | static CYTHON_INLINE PyObject *
function CYTHON_INLINE (line 5956) | static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
function CYTHON_INLINE (line 5963) | static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
function CYTHON_INLINE (line 5997) | static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
function CYTHON_INLINE (line 6023) | static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObj...
function __Pyx_RaiseBufferIndexError (line 6042) | static void __Pyx_RaiseBufferIndexError(int axis) {
function CYTHON_INLINE (line 6049) | static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate,...
function CYTHON_INLINE (line 6061) | static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, P...
function __Pyx_Raise (line 6073) | static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
function CYTHON_INLINE (line 6235) | static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expec...
function CYTHON_INLINE (line 6241) | static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t inde...
function CYTHON_INLINE (line 6248) | static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
function CYTHON_INLINE (line 6254) | static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, Py...
function CYTHON_INLINE (line 6262) | static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, P...
function CYTHON_INLINE (line 6278) | static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadSta...
function __Pyx_GetException (line 6290) | static int __Pyx_GetException(PyObject **type, PyObject **value, PyObjec...
function PyObject (line 6348) | static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int l...
function __pyx_bisect_code_objects (line 6422) | static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries...
function PyCodeObject (line 6443) | static PyCodeObject *__pyx_find_code_object(int code_line) {
function __pyx_insert_code_object (line 6457) | static void __pyx_insert_code_object(int code_line, PyCodeObject* code_o...
function PyCodeObject (line 6505) | static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
function __Pyx_AddTraceback (line 6557) | static void __Pyx_AddTraceback(const char *funcname, int c_line,
function __Pyx_GetBuffer (line 6583) | static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
function __Pyx_ReleaseBuffer (line 6589) | static void __Pyx_ReleaseBuffer(Py_buffer *view) {
function CYTHON_INLINE (line 6626) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned in...
function CYTHON_INLINE (line 6659) | static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_pa...
function CYTHON_INLINE (line 6663) | static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_pa...
function CYTHON_INLINE (line 6668) | static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_pa...
function CYTHON_INLINE (line 6679) | static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx...
function CYTHON_INLINE (line 6682) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_flo...
function CYTHON_INLINE (line 6688) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_fl...
function CYTHON_INLINE (line 6694) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_fl...
function CYTHON_INLINE (line 6701) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_fl...
function CYTHON_INLINE (line 6721) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_fl...
function CYTHON_INLINE (line 6732) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_flo...
function CYTHON_INLINE (line 6738) | static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
function CYTHON_INLINE (line 6741) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_fl...
function CYTHON_INLINE (line 6748) | static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
function CYTHON_INLINE (line 6755) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_flo...
function CYTHON_INLINE (line 6814) | static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_...
function CYTHON_INLINE (line 6818) | static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_...
function CYTHON_INLINE (line 6823) | static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_...
function CYTHON_INLINE (line 6834) | static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __p...
function CYTHON_INLINE (line 6837) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_d...
function CYTHON_INLINE (line 6843) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_...
function CYTHON_INLINE (line 6849) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_...
function CYTHON_INLINE (line 6856) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_...
function CYTHON_INLINE (line 6876) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_...
function CYTHON_INLINE (line 6887) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_d...
function CYTHON_INLINE (line 6893) | static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
function CYTHON_INLINE (line 6896) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_...
function CYTHON_INLINE (line 6903) | static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
function CYTHON_INLINE (line 6910) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_d...
function CYTHON_INLINE (line 6967) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
function CYTHON_INLINE (line 6998) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY...
function __Pyx_PyInt_As_unsigned_int (line 7029) | static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *...
function CYTHON_INLINE (line 7407) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
function __Pyx_check_binary_version (line 7627) | static int __Pyx_check_binary_version(void) {
function PyObject (line 7645) | static PyObject *__Pyx_ImportModule(const char *name) {
function PyTypeObject (line 7663) | static PyTypeObject *__Pyx_ImportType(const char *module_name, const cha...
function __Pyx_InitStrings (line 7726) | static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
function CYTHON_INLINE (line 7756) | static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_...
function CYTHON_INLINE (line 7759) | static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
function CYTHON_INLINE (line 7821) | static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
function CYTHON_INLINE (line 7877) | static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
function CYTHON_INLINE (line 7939) | static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
FILE: lib/evaluation/sg_eval.py
class BasicSceneGraphEvaluator (line 11) | class BasicSceneGraphEvaluator:
method __init__ (line 12) | def __init__(self, mode, multiple_preds=False):
method all_modes (line 19) | def all_modes(cls, **kwargs):
method vrd_modes (line 24) | def vrd_modes(cls, **kwargs):
method evaluate_scene_graph_entry (line 28) | def evaluate_scene_graph_entry(self, gt_entry, pred_scores, viz_dict=N...
method save (line 34) | def save(self, fn):
method print_stats (line 37) | def print_stats(self):
function evaluate_from_dict (line 43) | def evaluate_from_dict(gt_entry, pred_entry, mode, result_dict, multiple...
function evaluate_recall (line 147) | def evaluate_recall(gt_rels, gt_boxes, gt_classes,
function _triplet (line 210) | def _triplet(predicates, relations, classes, boxes,
function _compute_pred_matches (line 243) | def _compute_pred_matches(gt_triplets, pred_triplets,
FILE: lib/evaluation/sg_eval_all_rel_cates.py
class BasicSceneGraphEvaluator (line 12) | class BasicSceneGraphEvaluator:
method __init__ (line 13) | def __init__(self, mode, multiple_preds=False):
method all_modes (line 78) | def all_modes(cls, **kwargs):
method vrd_modes (line 83) | def vrd_modes(cls, **kwargs):
method evaluate_scene_graph_entry (line 87) | def evaluate_scene_graph_entry(self, gt_entry, pred_scores, viz_dict=N...
method save (line 93) | def save(self, fn):
method print_stats (line 96) | def print_stats(self):
function evaluate_from_dict (line 103) | def evaluate_from_dict(gt_entry, pred_entry, mode, result_dict, multiple...
function evaluate_recall (line 213) | def evaluate_recall(gt_rels, gt_boxes, gt_classes,
function _triplet (line 277) | def _triplet(predicates, relations, classes, boxes,
function _compute_pred_matches (line 310) | def _compute_pred_matches(gt_triplets, pred_triplets,
FILE: lib/evaluation/sg_eval_slow.py
class BasicSceneGraphEvaluator (line 5) | class BasicSceneGraphEvaluator:
method __init__ (line 7) | def __init__(self, mode):
method all_modes (line 16) | def all_modes(cls):
method evaluate_scene_graph_entry (line 19) | def evaluate_scene_graph_entry(self, gt_entry, pred_entry, iou_thresh=...
method save (line 43) | def save(self, fn):
method print_stats (line 47) | def print_stats(self):
method save (line 52) | def save(self, fn):
method print_stats (line 55) | def print_stats(self):
function eval_relation_recall (line 61) | def eval_relation_recall(sg_entry,
function _triplet (line 149) | def _triplet(predicates, relations, classes, boxes,
function _relation_recall (line 173) | def _relation_recall(gt_triplets, pred_triplets,
function iou (line 198) | def iou(gt_box, pred_boxes):
FILE: lib/evaluation/test_sg_eval.py
function eval_relation_recall (line 9) | def eval_relation_recall(sg_entry,
function _triplet (line 108) | def _triplet(predicates, relations, classes, boxes,
function _relation_recall (line 132) | def _relation_recall(gt_triplets, pred_triplets,
function iou (line 157) | def iou(gt_box, pred_boxes):
FILE: lib/fpn/anchor_targets.py
function anchor_target_layer (line 16) | def anchor_target_layer(gt_boxes, im_size,
FILE: lib/fpn/box_intersections_cpu/bbox.c
type PyObject (line 195) | typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **a...
type Py_hash_t (line 317) | typedef long Py_hash_t;
type __Pyx_PyAsyncMethodsStruct (line 334) | typedef struct {
function CYTHON_INLINE (line 405) | static CYTHON_INLINE float __PYX_NAN() {
type __Pyx_StringTabEntry (line 454) | typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const c...
function CYTHON_INLINE (line 512) | static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
function __Pyx_init_sys_getdefaultencoding_params (line 545) | static int __Pyx_init_sys_getdefaultencoding_params(void) {
function __Pyx_init_sys_getdefaultencoding_params (line 595) | static int __Pyx_init_sys_getdefaultencoding_params(void) {
type __Pyx_StructField_ (line 669) | struct __Pyx_StructField_
type __Pyx_TypeInfo (line 671) | typedef struct {
type __Pyx_StructField (line 681) | typedef struct __Pyx_StructField_ {
type __Pyx_BufFmt_StackElem (line 686) | typedef struct {
type __Pyx_BufFmt_Context (line 690) | typedef struct {
type npy_int8 (line 711) | typedef npy_int8 __pyx_t_5numpy_int8_t;
type npy_int16 (line 720) | typedef npy_int16 __pyx_t_5numpy_int16_t;
type npy_int32 (line 729) | typedef npy_int32 __pyx_t_5numpy_int32_t;
type npy_int64 (line 738) | typedef npy_int64 __pyx_t_5numpy_int64_t;
type npy_uint8 (line 747) | typedef npy_uint8 __pyx_t_5numpy_uint8_t;
type npy_uint16 (line 756) | typedef npy_uint16 __pyx_t_5numpy_uint16_t;
type npy_uint32 (line 765) | typedef npy_uint32 __pyx_t_5numpy_uint32_t;
type npy_uint64 (line 774) | typedef npy_uint64 __pyx_t_5numpy_uint64_t;
type npy_float32 (line 783) | typedef npy_float32 __pyx_t_5numpy_float32_t;
type npy_float64 (line 792) | typedef npy_float64 __pyx_t_5numpy_float64_t;
type npy_long (line 801) | typedef npy_long __pyx_t_5numpy_int_t;
type npy_longlong (line 810) | typedef npy_longlong __pyx_t_5numpy_long_t;
type npy_longlong (line 819) | typedef npy_longlong __pyx_t_5numpy_longlong_t;
type npy_ulong (line 828) | typedef npy_ulong __pyx_t_5numpy_uint_t;
type npy_ulonglong (line 837) | typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
type npy_ulonglong (line 846) | typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
type npy_intp (line 855) | typedef npy_intp __pyx_t_5numpy_intp_t;
type npy_uintp (line 864) | typedef npy_uintp __pyx_t_5numpy_uintp_t;
type npy_double (line 873) | typedef npy_double __pyx_t_5numpy_float_t;
type npy_double (line 882) | typedef npy_double __pyx_t_5numpy_double_t;
type npy_longdouble (line 891) | typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
type __pyx_t_5numpy_float_t (line 900) | typedef __pyx_t_5numpy_float_t __pyx_t_4bbox_DTYPE_t;
type std (line 904) | typedef ::std::complex< float > __pyx_t_float_complex;
type __pyx_t_float_complex (line 906) | typedef float _Complex __pyx_t_float_complex;
type __pyx_t_float_complex (line 909) | typedef struct { float real, imag; } __pyx_t_float_complex;
type std (line 916) | typedef ::std::complex< double > __pyx_t_double_complex;
type __pyx_t_double_complex (line 918) | typedef double _Complex __pyx_t_double_complex;
type __pyx_t_double_complex (line 921) | typedef struct { double real, imag; } __pyx_t_double_complex;
type npy_cfloat (line 935) | typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
type npy_cdouble (line 944) | typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
type npy_clongdouble (line 953) | typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
type npy_cdouble (line 962) | typedef npy_cdouble __pyx_t_5numpy_complex_t;
type __Pyx_RefNannyAPIStruct (line 970) | typedef struct {
function CYTHON_INLINE (line 1030) | static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, ...
function PyObject (line 1114) | static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
type __Pyx_CodeObjectCacheEntry (line 1173) | typedef struct {
type __Pyx_CodeObjectCache (line 1177) | struct __Pyx_CodeObjectCache {
type __Pyx_CodeObjectCache (line 1182) | struct __Pyx_CodeObjectCache
type __Pyx_Buf_DimInfo (line 1192) | typedef struct {
type __Pyx_Buffer (line 1195) | typedef struct {
type __Pyx_LocalBuf_ND (line 1199) | typedef struct {
type NPY_TYPES (line 1323) | enum NPY_TYPES
function PyObject (line 1491) | static PyObject *__pyx_pw_4bbox_1bbox_overlaps(PyObject *__pyx_self, PyO...
function PyObject (line 1547) | static PyObject *__pyx_pf_4bbox_bbox_overlaps(CYTHON_UNUSED PyObject *__...
function PyObject (line 2340) | static PyObject *__pyx_pw_4bbox_3bbox_intersections(PyObject *__pyx_self...
function PyObject (line 2396) | static PyObject *__pyx_pf_4bbox_2bbox_intersections(CYTHON_UNUSED PyObje...
function CYTHON_UNUSED (line 3103) | static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObjec...
function __pyx_pf_5numpy_7ndarray___getbuffer__ (line 3114) | static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v...
function CYTHON_UNUSED (line 3975) | static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(Py...
function __pyx_pf_5numpy_7ndarray_2__releasebuffer__ (line 3984) | static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *_...
function CYTHON_INLINE (line 4065) | static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyOb...
function CYTHON_INLINE (line 4112) | static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyOb...
function CYTHON_INLINE (line 4159) | static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyOb...
function CYTHON_INLINE (line 4206) | static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyOb...
function CYTHON_INLINE (line 4253) | static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyOb...
function CYTHON_INLINE (line 4300) | static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Desc...
function CYTHON_INLINE (line 5055) | static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *_...
function CYTHON_INLINE (line 5151) | static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObje...
function CYTHON_INLINE (line 5225) | static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
function CYTHON_INLINE (line 5356) | static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
function CYTHON_INLINE (line 5487) | static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
type PyModuleDef (line 5612) | struct PyModuleDef
function __Pyx_InitCachedBuiltins (line 5662) | static int __Pyx_InitCachedBuiltins(void) {
function __Pyx_InitCachedConstants (line 5672) | static int __Pyx_InitCachedConstants(void) {
function __Pyx_InitGlobals (line 5803) | static int __Pyx_InitGlobals(void) {
function PyMODINIT_FUNC (line 5815) | PyMODINIT_FUNC PyInit_bbox(void)
function __Pyx_RefNannyAPIStruct (line 6010) | static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modn...
function PyObject (line 6026) | static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
function __Pyx_RaiseArgtupleInvalid (line 6040) | static void __Pyx_RaiseArgtupleInvalid(
function __Pyx_RaiseDoubleKeywordsError (line 6066) | static void __Pyx_RaiseDoubleKeywordsError(
function __Pyx_ParseOptionalKeywords (line 6080) | static int __Pyx_ParseOptionalKeywords(
function CYTHON_INLINE (line 6201) | static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObj...
function CYTHON_INLINE (line 6220) | static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *typ...
function CYTHON_INLINE (line 6233) | static CYTHON_INLINE int __Pyx_IsLittleEndian(void) {
function __Pyx_BufFmt_Init (line 6237) | static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
function __Pyx_BufFmt_ParseNumber (line 6264) | static int __Pyx_BufFmt_ParseNumber(const char** ts) {
function __Pyx_BufFmt_ExpectNumber (line 6279) | static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
function __Pyx_BufFmt_RaiseUnexpectedChar (line 6286) | static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
function __Pyx_BufFmt_TypeCharToStandardSize (line 6314) | static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_comple...
function __Pyx_BufFmt_TypeCharToNativeSize (line 6332) | static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
type __Pyx_st_short (line 6351) | typedef struct { char c; short x; } __Pyx_st_short;
type __Pyx_st_int (line 6352) | typedef struct { char c; int x; } __Pyx_st_int;
type __Pyx_st_long (line 6353) | typedef struct { char c; long x; } __Pyx_st_long;
type __Pyx_st_float (line 6354) | typedef struct { char c; float x; } __Pyx_st_float;
type __Pyx_st_double (line 6355) | typedef struct { char c; double x; } __Pyx_st_double;
type __Pyx_st_longdouble (line 6356) | typedef struct { char c; long double x; } __Pyx_st_longdouble;
type __Pyx_st_void_p (line 6357) | typedef struct { char c; void *x; } __Pyx_st_void_p;
type __Pyx_st_longlong (line 6359) | typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
function __Pyx_BufFmt_TypeCharToAlignment (line 6361) | static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED in...
type __Pyx_pad_short (line 6383) | typedef struct { short x; char c; } __Pyx_pad_short;
type __Pyx_pad_int (line 6384) | typedef struct { int x; char c; } __Pyx_pad_int;
type __Pyx_pad_long (line 6385) | typedef struct { long x; char c; } __Pyx_pad_long;
type __Pyx_pad_float (line 6386) | typedef struct { float x; char c; } __Pyx_pad_float;
type __Pyx_pad_double (line 6387) | typedef struct { double x; char c; } __Pyx_pad_double;
type __Pyx_pad_longdouble (line 6388) | typedef struct { long double x; char c; } __Pyx_pad_longdouble;
type __Pyx_pad_void_p (line 6389) | typedef struct { void *x; char c; } __Pyx_pad_void_p;
type __Pyx_pad_longlong (line 6391) | typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
function __Pyx_BufFmt_TypeCharToPadding (line 6393) | static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int ...
function __Pyx_BufFmt_TypeCharToGroup (line 6411) | static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
function __Pyx_BufFmt_RaiseExpected (line 6432) | static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
function __Pyx_BufFmt_ProcessTypeChunk (line 6456) | static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
function CYTHON_INLINE (line 6558) | static CYTHON_INLINE PyObject *
function CYTHON_INLINE (line 6735) | static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
function CYTHON_INLINE (line 6742) | static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
function CYTHON_INLINE (line 6776) | static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
function CYTHON_INLINE (line 6784) | static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate,...
function CYTHON_INLINE (line 6796) | static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, P...
function __Pyx_RaiseBufferIndexError (line 6807) | static void __Pyx_RaiseBufferIndexError(int axis) {
function __Pyx_Raise (line 6814) | static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
function CYTHON_INLINE (line 6976) | static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expec...
function CYTHON_INLINE (line 6982) | static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t inde...
function CYTHON_INLINE (line 6989) | static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
function CYTHON_INLINE (line 6995) | static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, Py...
function CYTHON_INLINE (line 7003) | static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, P...
function CYTHON_INLINE (line 7019) | static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadSta...
function __Pyx_GetException (line 7031) | static int __Pyx_GetException(PyObject **type, PyObject **value, PyObjec...
function PyObject (line 7089) | static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int l...
function __pyx_bisect_code_objects (line 7163) | static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries...
function PyCodeObject (line 7184) | static PyCodeObject *__pyx_find_code_object(int code_line) {
function __pyx_insert_code_object (line 7198) | static void __pyx_insert_code_object(int code_line, PyCodeObject* code_o...
function PyCodeObject (line 7246) | static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
function __Pyx_AddTraceback (line 7298) | static void __Pyx_AddTraceback(const char *funcname, int c_line,
function __Pyx_GetBuffer (line 7324) | static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
function __Pyx_ReleaseBuffer (line 7330) | static void __Pyx_ReleaseBuffer(Py_buffer *view) {
function CYTHON_INLINE (line 7345) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned in...
function CYTHON_INLINE (line 7400) | static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_pa...
function CYTHON_INLINE (line 7404) | static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_pa...
function CYTHON_INLINE (line 7409) | static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_pa...
function CYTHON_INLINE (line 7420) | static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx...
function CYTHON_INLINE (line 7423) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_flo...
function CYTHON_INLINE (line 7429) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_fl...
function CYTHON_INLINE (line 7435) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_fl...
function CYTHON_INLINE (line 7442) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_fl...
function CYTHON_INLINE (line 7462) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_fl...
function CYTHON_INLINE (line 7473) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_flo...
function CYTHON_INLINE (line 7479) | static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
function CYTHON_INLINE (line 7482) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_fl...
function CYTHON_INLINE (line 7489) | static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
function CYTHON_INLINE (line 7496) | static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_flo...
function CYTHON_INLINE (line 7555) | static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_...
function CYTHON_INLINE (line 7559) | static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_...
function CYTHON_INLINE (line 7564) | static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_...
function CYTHON_INLINE (line 7575) | static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __p...
function CYTHON_INLINE (line 7578) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_d...
function CYTHON_INLINE (line 7584) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_...
function CYTHON_INLINE (line 7590) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_...
function CYTHON_INLINE (line 7597) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_...
function CYTHON_INLINE (line 7617) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_...
function CYTHON_INLINE (line 7628) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_d...
function CYTHON_INLINE (line 7634) | static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
function CYTHON_INLINE (line 7637) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_...
function CYTHON_INLINE (line 7644) | static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
function CYTHON_INLINE (line 7651) | static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_d...
function CYTHON_INLINE (line 7708) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
function CYTHON_INLINE (line 7739) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY...
function __Pyx_PyInt_As_unsigned_int (line 7770) | static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *...
function CYTHON_INLINE (line 8148) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
function __Pyx_check_binary_version (line 8368) | static int __Pyx_check_binary_version(void) {
function PyObject (line 8386) | static PyObject *__Pyx_ImportModule(const char *name) {
function PyTypeObject (line 8404) | static PyTypeObject *__Pyx_ImportType(const char *module_name, const cha...
function __Pyx_InitStrings (line 8467) | static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
function CYTHON_INLINE (line 8497) | static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_...
function CYTHON_INLINE (line 8500) | static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
function CYTHON_INLINE (line 8562) | static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
function CYTHON_INLINE (line 8618) | static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
function CYTHON_INLINE (line 8680) | static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
FILE: lib/fpn/box_utils.py
function bbox_loss (line 8) | def bbox_loss(prior_boxes, deltas, gt_boxes, eps=1e-4, scale_before=1):
function bbox_preds (line 28) | def bbox_preds(boxes, deltas):
function center_size (line 51) | def center_size(boxes):
function point_form (line 66) | def point_form(boxes):
function bbox_intersections (line 85) | def bbox_intersections(box_a, box_b):
function bbox_overlaps (line 109) | def bbox_overlaps(box_a, box_b):
function nms_overlaps (line 134) | def nms_overlaps(boxes):
FILE: lib/fpn/generate_anchors.py
function generate_anchors (line 39) | def generate_anchors(base_size=16, feat_stride=16, anchor_scales=(8,16,3...
function generate_base_anchors (line 62) | def generate_base_anchors(base_size=16, ratios=[0.5, 1, 2], scales=2 ** ...
function _whctrs (line 75) | def _whctrs(anchor):
function _mkanchors (line 87) | def _mkanchors(ws, hs, x_ctr, y_ctr):
function _ratio_enum (line 102) | def _ratio_enum(anchor, ratios):
function _scale_enum (line 117) | def _scale_enum(anchor, scales):
FILE: lib/fpn/nms/functions/nms.py
function apply_nms (line 7) | def apply_nms(scores, boxes, pre_nms_topn=12000, post_nms_topn=2000, bo...
function _nms_single_im (line 35) | def _nms_single_im(scores, boxes, pre_nms_topn=12000, post_nms_topn=200...
FILE: lib/fpn/nms/src/nms_cuda.c
function nms_apply (line 7) | int nms_apply(THIntTensor* keep, THCudaTensor* boxes_sorted, const float...
FILE: lib/fpn/proposal_assignments/proposal_assignments_det.py
function proposal_assignments_det (line 12) | def proposal_assignments_det(rpn_rois, gt_boxes, gt_classes, image_offse...
function _sel_inds (line 94) | def _sel_inds(max_overlaps, fg_thresh=0.5, fg_rois_per_image=128, rois_p...
FILE: lib/fpn/proposal_assignments/proposal_assignments_gtbox.py
function proposal_assignments_gtbox (line 9) | def proposal_assignments_gtbox(rois, gt_boxes, gt_classes, gt_rels, imag...
FILE: lib/fpn/proposal_assignments/proposal_assignments_postnms.py
function proposal_assignments_postnms (line 15) | def proposal_assignments_postnms(
FILE: lib/fpn/proposal_assignments/proposal_assignments_rel.py
function proposal_assignments_rel (line 17) | def proposal_assignments_rel(rpn_rois, gt_boxes, gt_classes, gt_rels, im...
function _sel_rels (line 97) | def _sel_rels(ious, pred_boxes, pred_labels, gt_classes, gt_rels, fg_thr...
function _sel_inds (line 182) | def _sel_inds(ious, gt_classes_i, fg_thresh=0.5, fg_rois_per_image=128, ...
FILE: lib/fpn/proposal_assignments/rel_assignments.py
function rel_assignments (line 15) | def rel_assignments(im_inds, rpn_rois, roi_gtlabels, gt_boxes, gt_classe...
FILE: lib/fpn/roi_align/_ext/roi_align/__init__.py
function _import_symbols (line 6) | def _import_symbols(locals):
FILE: lib/fpn/roi_align/functions/roi_align.py
class RoIAlignFunction (line 9) | class RoIAlignFunction(Function):
method __init__ (line 10) | def __init__(self, aligned_height, aligned_width, spatial_scale):
method forward (line 17) | def forward(self, features, rois):
method backward (line 50) | def backward(self, grad_output):
FILE: lib/fpn/roi_align/modules/roi_align.py
class RoIAlign (line 6) | class RoIAlign(Module):
method __init__ (line 7) | def __init__(self, aligned_height, aligned_width, spatial_scale):
method forward (line 14) | def forward(self, features, rois):
class RoIAlignAvg (line 18) | class RoIAlignAvg(Module):
method __init__ (line 19) | def __init__(self, aligned_height, aligned_width, spatial_scale):
method forward (line 26) | def forward(self, features, rois):
class RoIAlignMax (line 31) | class RoIAlignMax(Module):
method __init__ (line 32) | def __init__(self, aligned_height, aligned_width, spatial_scale):
method forward (line 39) | def forward(self, features, rois):
FILE: lib/fpn/roi_align/src/roi_align_cuda.c
function roi_align_forward_cuda (line 7) | int roi_align_forward_cuda(int crop_height, int crop_width, float spatia...
function roi_align_backward_cuda (line 44) | int roi_align_backward_cuda(int crop_height, int crop_width, float spati...
FILE: lib/get_dataset_counts.py
function get_counts (line 12) | def get_counts(train_data=VG(mode='train', filter_duplicate_rels=False, ...
function box_filter (line 49) | def box_filter(boxes, must_overlap=False):
FILE: lib/get_union_boxes.py
class UnionBoxesAndFeats (line 15) | class UnionBoxesAndFeats(Module):
method __init__ (line 16) | def __init__(self, pooling_size=7, stride=16, dim=256, concat=False, u...
method forward (line 42) | def forward(self, fmap, rois, union_inds):
function union_boxes (line 72) | def union_boxes(fmap, rois, union_inds, pooling_size=14, stride=16):
FILE: lib/lstm/decoder_rnn.py
function get_dropout_mask (line 13) | def get_dropout_mask(dropout_probability: float, tensor_for_masking: tor...
class DecoderRNN (line 40) | class DecoderRNN(torch.nn.Module):
method __init__ (line 41) | def __init__(self, classes, embed_dim, inputs_dim, hidden_dim, recurre...
method input_size (line 83) | def input_size(self):
method reset_parameters (line 86) | def reset_parameters(self):
method lstm_equations (line 96) | def lstm_equations(self, timestep_input, previous_state, previous_memo...
method forward (line 133) | def forward(self, # pylint: disable=arguments-differ
FILE: lib/lstm/highway_lstm_cuda/_ext/highway_lstm_layer/__init__.py
function _import_symbols (line 6) | def _import_symbols(locals):
FILE: lib/lstm/highway_lstm_cuda/alternating_highway_lstm.py
function block_orthogonal (line 12) | def block_orthogonal(tensor, split_sizes, gain=1.0):
class _AlternatingHighwayLSTMFunction (line 62) | class _AlternatingHighwayLSTMFunction(Function):
method __init__ (line 63) | def __init__(self, input_size: int, hidden_size: int, num_layers: int,...
method forward (line 71) | def forward(self, # pylint: disable=arguments-differ
method backward (line 111) | def backward(self, grad_output, grad_hy): # pylint: disable=arguments...
class AlternatingHighwayLSTM (line 165) | class AlternatingHighwayLSTM(torch.nn.Module):
method __init__ (line 195) | def __init__(self,
method reset_parameters (line 233) | def reset_parameters(self) -> None:
method forward (line 259) | def forward(self, inputs, initial_state=None) -> Tuple[PackedSequence,...
FILE: lib/lstm/highway_lstm_cuda/src/highway_lstm_cuda.c
function highway_lstm_forward_cuda (line 6) | int highway_lstm_forward_cuda(int inputSize, int hiddenSize, int miniBatch,
function highway_lstm_backward_cuda (line 48) | int highway_lstm_backward_cuda(int inputSize, int hiddenSize, int miniBa...
FILE: lib/object_detector.py
class Result (line 22) | class Result(object):
method __init__ (line 26) | def __init__(self, od_obj_dists=None, rm_obj_dists=None,
method is_none (line 36) | def is_none(self):
function gather_res (line 40) | def gather_res(outputs, target_device, dim=0):
class ObjectDetector (line 50) | class ObjectDetector(nn.Module):
method __init__ (line 57) | def __init__(self, classes, mode='rpntrain', num_gpus=1, nms_filter_du...
method num_classes (line 107) | def num_classes(self):
method feature_map (line 110) | def feature_map(self, x):
method obj_feature_map (line 129) | def obj_feature_map(self, features, rois):
method rpn_boxes (line 140) | def rpn_boxes(self, fmap, im_sizes, image_offset, gt_boxes=None, gt_cl...
method gt_boxes (line 200) | def gt_boxes(self, fmap, im_sizes, image_offset, gt_boxes=None, gt_cla...
method proposal_boxes (line 226) | def proposal_boxes(self, fmap, im_sizes, image_offset, gt_boxes=None, ...
method get_boxes (line 264) | def get_boxes(self, *args, **kwargs):
method forward (line 274) | def forward(self, x, im_sizes, image_offset,
method nms_boxes (line 363) | def nms_boxes(self, obj_dists, rois, box_deltas, im_sizes):
method __getitem__ (line 410) | def __getitem__(self, batch):
function filter_det (line 425) | def filter_det(scores, boxes, start_ind=0, max_per_img=100, thresh=0.001...
class RPNHead (line 488) | class RPNHead(nn.Module):
method __init__ (line 493) | def __init__(self, dim=512, input_dim=1024):
method _A (line 518) | def _A(self):
method forward (line 521) | def forward(self, fmap):
method anchor_preds (line 533) | def anchor_preds(self, preds, train_anchor_inds, image_offset):
method _reshape_channels (line 551) | def _reshape_channels(x):
method roi_proposals (line 560) | def roi_proposals(self, fmap, im_sizes, nms_thresh=0.7, pre_nms_topn=1...
function filter_roi_proposals (line 600) | def filter_roi_proposals(box_preds, class_preds, boxes_per_im, nms_thres...
function load_resnet (line 615) | def load_resnet():
function load_vgg (line 623) | def load_vgg(use_dropout=True, use_relu=True, use_linear=True, pretraine...
FILE: lib/pytorch_misc.py
function optimistic_restore (line 14) | def optimistic_restore(network, state_dict):
function pairwise (line 36) | def pairwise(iterable):
function get_ranking (line 43) | def get_ranking(predictions, labels, num_guesses=5):
function cache (line 63) | def cache(f):
class Flattener (line 80) | class Flattener(nn.Module):
method __init__ (line 81) | def __init__(self):
method forward (line 86) | def forward(self, x):
function to_variable (line 90) | def to_variable(f):
function arange (line 103) | def arange(base_tensor, n=None):
function to_onehot (line 110) | def to_onehot(vec, num_classes, fill=1000):
function save_net (line 127) | def save_net(fname, net):
function load_net (line 133) | def load_net(fname, net):
function batch_index_iterator (line 144) | def batch_index_iterator(len_l, batch_size, skip_end=True):
function batch_map (line 161) | def batch_map(f, a, batch_size):
function const_row (line 178) | def const_row(fill, l, volatile=False):
function print_para (line 185) | def print_para(model):
function accuracy (line 206) | def accuracy(output, target, topk=(1,)):
function nonintersecting_2d_inds (line 222) | def nonintersecting_2d_inds(x):
function intersect_2d (line 233) | def intersect_2d(x1, x2):
function np_to_variable (line 249) | def np_to_variable(x, is_cuda=True, dtype=torch.FloatTensor):
function gather_nd (line 255) | def gather_nd(x, index):
function enumerate_by_image (line 278) | def enumerate_by_image(im_inds):
function diagonal_inds (line 301) | def diagonal_inds(tensor):
function enumerate_imsize (line 314) | def enumerate_imsize(im_sizes):
function argsort_desc (line 323) | def argsort_desc(scores):
function unravel_index (line 333) | def unravel_index(index, dims):
function de_chunkize (line 341) | def de_chunkize(tensor, chunks):
function random_choose (line 347) | def random_choose(tensor, num):
function transpose_packed_sequence_inds (line 365) | def transpose_packed_sequence_inds(lengths):
function right_shift_packed_sequence_inds (line 387) | def right_shift_packed_sequence_inds(lengths):
function clip_grad_norm (line 416) | def clip_grad_norm(named_parameters, max_norm, clip=False, verbose=False):
function update_lr (line 457) | def update_lr(optimizer, lr=1e-4):
FILE: lib/rel_model.py
function _sort_by_score (line 31) | def _sort_by_score(im_inds, scores):
class LinearizedContext (line 66) | class LinearizedContext(nn.Module):
method __init__ (line 70) | def __init__(self, classes, rel_classes, mode='sgdet',
method sort_rois (line 139) | def sort_rois(self, batch_idx, confidence, box_priors):
method num_classes (line 164) | def num_classes(self):
method num_rels (line 168) | def num_rels(self):
method edge_ctx (line 171) | def edge_ctx(self, obj_feats, obj_dists, im_inds, obj_preds, box_prior...
method obj_ctx (line 197) | def obj_ctx(self, obj_feats, obj_dists, im_inds, obj_labels=None, box_...
method forward (line 236) | def forward(self, obj_fmaps, obj_logits, im_inds, obj_labels=None, box...
class RelModel (line 299) | class RelModel(nn.Module):
method __init__ (line 303) | def __init__(self, classes, rel_classes, mode='sgdet', num_gpus=1, use...
method num_classes (line 396) | def num_classes(self):
method num_rels (line 400) | def num_rels(self):
method visual_rep (line 403) | def visual_rep(self, features, rois, pair_inds):
method get_rel_inds (line 416) | def get_rel_inds(self, rel_labels, im_inds, box_priors):
method obj_feature_map (line 439) | def obj_feature_map(self, features, rois):
method forward (line 450) | def forward(self, x, im_sizes, image_offset,
method __getitem__ (line 549) | def __getitem__(self, batch):
FILE: lib/rel_model_stanford.py
class RelModelStanford (line 20) | class RelModelStanford(RelModel):
method __init__ (line 25) | def __init__(self, classes, rel_classes, mode='sgdet', num_gpus=1, req...
method message_pass (line 60) | def message_pass(self, rel_rep, obj_rep, rel_inds):
method forward (line 111) | def forward(self, x, im_sizes, image_offset,
FILE: lib/resnet.py
class Bottleneck (line 8) | class Bottleneck(nn.Module):
method __init__ (line 11) | def __init__(self, inplanes, planes, stride=1, downsample=None, relu_e...
method forward (line 25) | def forward(self, x):
class ResNet (line 49) | class ResNet(nn.Module):
method __init__ (line 51) | def __init__(self, block, layers, num_classes=1000):
method _make_layer (line 74) | def _make_layer(self, block, planes, blocks, stride=1):
method forward (line 91) | def forward(self, x):
function resnet101 (line 108) | def resnet101(pretrained=False, **kwargs):
function resnet_l123 (line 119) | def resnet_l123():
function resnet_l4 (line 126) | def resnet_l4(relu_end=True):
function vgg_fc (line 135) | def vgg_fc(relu_end=True, linear_end=True):
FILE: lib/sparse_targets.py
class FrequencyBias (line 11) | class FrequencyBias(nn.Module):
method __init__ (line 17) | def __init__(self, eps=1e-3):
method index_with_labels (line 32) | def index_with_labels(self, labels):
method forward (line 39) | def forward(self, obj_cands0, obj_cands1):
FILE: lib/surgery.py
function filter_dets (line 21) | def filter_dets(boxes, obj_scores, obj_classes, rel_inds, pred_scores):
FILE: lib/word_vectors.py
function obj_edge_vectors (line 17) | def obj_edge_vectors(names, wv_type='glove.6B', wv_dir=DATA_PATH, wv_dim...
function load_word_vectors (line 47) | def load_word_vectors(root, wv_type, dim):
function reporthook (line 115) | def reporthook(t):
FILE: misc/motifs.py
function id_to_str (line 63) | def id_to_str(_id):
function increment_recursive (line 180) | def increment_recursive(i):
function meme_length (line 189) | def meme_length(i):
FILE: models/_visualize.py
function get_cmap (line 54) | def get_cmap(N):
function load_unscaled (line 71) | def load_unscaled(fn):
function draw_box (line 84) | def draw_box(draw, boxx, cls_ind, text_str):
function val_epoch (line 114) | def val_epoch():
function val_batch (line 123) | def val_batch(batch_num, b, evaluator, thrs=(20, 50, 100)):
FILE: models/eval_rel_count.py
function predict (line 76) | def predict(boxes, classes):
function gimme_the_dist (line 92) | def gimme_the_dist(c1name, c2name):
FILE: models/eval_rels.py
function val_batch (line 59) | def val_batch(batch_num, b, evaluator, thrs=(20, 50, 100)):
FILE: models/train_detector.py
function train_epoch (line 60) | def train_epoch(epoch_num):
function train_batch (line 78) | def train_batch(b):
function val_epoch (line 158) | def val_epoch():
function val_batch (line 184) | def val_batch(batch_num, b):
FILE: models/train_rels.py
function get_optim (line 57) | def get_optim(lr):
function train_epoch (line 100) | def train_epoch(epoch_num):
function train_batch (line 118) | def train_batch(b, verbose=False):
function val_epoch (line 155) | def val_epoch():
function val_batch (line 164) | def val_batch(batch_num, b, evaluator):
Condensed preview — 98 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,110K chars).
[
{
"path": ".gitignore",
"chars": 1152,
"preview": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packagi"
},
{
"path": "LICENSE",
"chars": 1070,
"preview": "MIT License\n\nCopyright (c) 2018 Rowan Zellers\n\nPermission is hereby granted, free of charge, to any person obtaining a c"
},
{
"path": "Makefile",
"chars": 388,
"preview": "export PATH := /usr/local/cuda-9.1/bin:$(PATH)\n\nall: draw_rectangles box_intersections nms roi_align lstm\n\ndraw_rectangl"
},
{
"path": "README.md",
"chars": 2632,
"preview": "# neural-motifs\n\n### Like this work, or scene understanding in general? You might be interested in checking out my brand"
},
{
"path": "config.py",
"chars": 8468,
"preview": "\"\"\"\nConfiguration file!\n\"\"\"\nimport os\nfrom argparse import ArgumentParser\nimport numpy as np\n\nROOT_PATH = os.path.dirnam"
},
{
"path": "data/stanford_filtered/README.md",
"chars": 1006,
"preview": "# Filtered data\nAdapted from [Danfei Xu](https://github.com/danfeiX/scene-graph-TF-release/blob/master/data_tools/README"
},
{
"path": "dataloaders/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "dataloaders/blob.py",
"chars": 9073,
"preview": "\"\"\"\nData blob, hopefully to make collating less painful and MGPU training possible\n\"\"\"\nfrom lib.fpn.anchor_targets impor"
},
{
"path": "dataloaders/image_transforms.py",
"chars": 4172,
"preview": "# Some image transforms\n\nfrom PIL import Image, ImageOps, ImageFilter, ImageEnhance\nimport numpy as np\nfrom random impor"
},
{
"path": "dataloaders/mscoco.py",
"chars": 6775,
"preview": "from config import COCO_PATH, IM_SCALE, BOX_SCALE\nimport os\nfrom torch.utils.data import Dataset\nfrom pycocotools.coco i"
},
{
"path": "dataloaders/visual_genome.py",
"chars": 16333,
"preview": "\"\"\"\nFile that involves dataloaders for the Visual Genome dataset.\n\"\"\"\n\nimport json\nimport os\n\nimport h5py\nimport numpy a"
},
{
"path": "docs/LICENSE.md",
"chars": 1071,
"preview": "MIT License\n\nCopyright (c) 2017 Heiswayi Nrird\n\nPermission is hereby granted, free of charge, to any person obtaining a "
},
{
"path": "docs/_config.yaml",
"chars": 78,
"preview": "exclude: [README.md, LICENSE.md]\n\ndefaults:\n - values:\n layout: default\n"
},
{
"path": "docs/_includes/image.html",
"chars": 104,
"preview": "<div class=\"image-wrapper\">\n <img src=\"{{ include.url }}\" alt=\"{{ include.description }}\" />\n</div>\n\n"
},
{
"path": "docs/_layouts/default.html",
"chars": 2316,
"preview": "<!DOCTYPE html>\n<html>\n\n<head>\n <meta charset=\"UTF-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome"
},
{
"path": "docs/index.md",
"chars": 2991,
"preview": "---\npermalink: /\ntitle: Neural Motifs\nauthor: Rowan Zellers\ndescription: Scene Graph Parsing with Global Context (CVPR 2"
},
{
"path": "docs/upload.sh",
"chars": 81,
"preview": "#!/usr/bin/env bash\n\nscp -r _site/* USERNAME@SITE:~/rowanzellers.com/neuralmotifs"
},
{
"path": "lib/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "lib/draw_rectangles/draw_rectangles.c",
"chars": 326059,
"preview": "/* Generated by Cython 0.25.2 */\n\n/* BEGIN: Cython Metadata\n{\n \"distutils\": {\n \"depends\": []\n },\n \"modul"
},
{
"path": "lib/draw_rectangles/draw_rectangles.pyx",
"chars": 2577,
"preview": "######\n# Draws rectangles\n######\n\ncimport cython\nimport numpy as np\ncimport numpy as np\n\nDTYPE = np.float32\nctypedef np."
},
{
"path": "lib/draw_rectangles/setup.py",
"chars": 200,
"preview": "from distutils.core import setup\nfrom Cython.Build import cythonize\nimport numpy\n\nsetup(name=\"draw_rectangles_cython\", e"
},
{
"path": "lib/evaluation/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "lib/evaluation/sg_eval.py",
"chars": 11883,
"preview": "\"\"\"\nAdapted from Danfei Xu. In particular, slow code was removed\n\"\"\"\nimport numpy as np\nfrom functools import reduce\nfro"
},
{
"path": "lib/evaluation/sg_eval_all_rel_cates.py",
"chars": 14355,
"preview": "\"\"\"\nAdapted from Danfei Xu. In particular, slow code was removed\n\"\"\"\nimport numpy as np\nfrom functools import reduce\nfro"
},
{
"path": "lib/evaluation/sg_eval_slow.py",
"chars": 7743,
"preview": "# JUST TO CHECK THAT IT IS EXACTLY THE SAME..................................\nimport numpy as np\nfrom config import MODE"
},
{
"path": "lib/evaluation/test_sg_eval.py",
"chars": 9840,
"preview": "# Just some tests so you can be assured that sg_eval.py works the same as the (original) stanford evaluation\n\nimport num"
},
{
"path": "lib/fpn/anchor_targets.py",
"chars": 4333,
"preview": "\"\"\"\nGenerates anchor targets to train the detector. Does this during the collate step in training\nas it's much cheaper t"
},
{
"path": "lib/fpn/box_intersections_cpu/bbox.c",
"chars": 364394,
"preview": "/* Generated by Cython 0.25.2 */\n\n/* BEGIN: Cython Metadata\n{\n \"distutils\": {\n \"depends\": []\n },\n \"modul"
},
{
"path": "lib/fpn/box_intersections_cpu/bbox.pyx",
"chars": 3696,
"preview": "# --------------------------------------------------------\n# Fast R-CNN\n# Copyright (c) 2015 Microsoft\n# Licensed under "
},
{
"path": "lib/fpn/box_intersections_cpu/setup.py",
"chars": 178,
"preview": "from distutils.core import setup\nfrom Cython.Build import cythonize\nimport numpy\n\nsetup(name=\"bbox_cython\", ext_modules="
},
{
"path": "lib/fpn/box_utils.py",
"chars": 5965,
"preview": "import torch\nimport numpy as np\nfrom torch.nn import functional as F\nfrom lib.fpn.box_intersections_cpu.bbox import bbox"
},
{
"path": "lib/fpn/generate_anchors.py",
"chars": 4017,
"preview": "# --------------------------------------------------------\n# Faster R-CNN\n# Copyright (c) 2015 Microsoft\n# Licensed unde"
},
{
"path": "lib/fpn/make.sh",
"chars": 297,
"preview": "#!/usr/bin/env bash\n\ncd anchors\npython setup.py build_ext --inplace\ncd ..\n\ncd box_intersections_cpu\npython setup.py buil"
},
{
"path": "lib/fpn/nms/Makefile",
"chars": 139,
"preview": "all: src/cuda/nms.cu.o\n\tpython build.py\n\nsrc/cuda/nms.cu.o: src/cuda/nms_kernel.cu\n\t$(MAKE) -C src/cuda\n\nclean:\n\t$(MAKE)"
},
{
"path": "lib/fpn/nms/build.py",
"chars": 814,
"preview": "import os\nimport torch\nfrom torch.utils.ffi import create_extension\n# Might have to export PATH=/usr/local/cuda-8.0/bin$"
},
{
"path": "lib/fpn/nms/functions/nms.py",
"chars": 1312,
"preview": "# Le code for doing NMS\nimport torch\nimport numpy as np\nfrom .._ext import nms\n\n\ndef apply_nms(scores, boxes, pre_nms_t"
},
{
"path": "lib/fpn/nms/src/cuda/Makefile",
"chars": 168,
"preview": "all: nms_kernel.cu nms_kernel.h\n\t/usr/local/cuda/bin/nvcc -c -o nms.cu.o nms_kernel.cu --compiler-options -fPIC -gencode"
},
{
"path": "lib/fpn/nms/src/cuda/nms_kernel.cu",
"chars": 4571,
"preview": "// ------------------------------------------------------------------\n// Faster R-CNN\n// Copyright (c) 2015 Microsoft\n//"
},
{
"path": "lib/fpn/nms/src/cuda/nms_kernel.h",
"chars": 129,
"preview": "int ApplyNMSGPU(int* keep_out, const float* boxes_dev, const int boxes_num,\n float nms_overlap_thresh, int devi"
},
{
"path": "lib/fpn/nms/src/nms_cuda.c",
"chars": 567,
"preview": "#include <THC/THC.h>\n#include <math.h>\n#include \"cuda/nms_kernel.h\"\n\nextern THCState *state;\n\nint nms_apply(THIntTensor*"
},
{
"path": "lib/fpn/nms/src/nms_cuda.h",
"chars": 85,
"preview": "int nms_apply(THIntTensor* keep, THCudaTensor* boxes_sorted, const float nms_thresh);"
},
{
"path": "lib/fpn/proposal_assignments/proposal_assignments_det.py",
"chars": 4477,
"preview": "\nimport numpy as np\nimport numpy.random as npr\nfrom config import BG_THRESH_HI, BG_THRESH_LO, FG_FRACTION, ROIS_PER_IMG\n"
},
{
"path": "lib/fpn/proposal_assignments/proposal_assignments_gtbox.py",
"chars": 3434,
"preview": "from lib.pytorch_misc import enumerate_by_image, gather_nd, random_choose\nfrom lib.fpn.box_utils import bbox_preds, cent"
},
{
"path": "lib/fpn/proposal_assignments/proposal_assignments_postnms.py",
"chars": 5420,
"preview": "# --------------------------------------------------------\n# Goal: assign ROIs to targets\n# ----------------------------"
},
{
"path": "lib/fpn/proposal_assignments/proposal_assignments_rel.py",
"chars": 9678,
"preview": "# --------------------------------------------------------\n# Goal: assign ROIs to targets\n# ----------------------------"
},
{
"path": "lib/fpn/proposal_assignments/rel_assignments.py",
"chars": 6381,
"preview": "# --------------------------------------------------------\n# Goal: assign ROIs to targets\n# ----------------------------"
},
{
"path": "lib/fpn/roi_align/Makefile",
"chars": 157,
"preview": "all: src/cuda/roi_align.cu.o\n\tpython build.py\n\nsrc/cuda/roi_align.cu.o: src/cuda/roi_align_kernel.cu\n\t$(MAKE) -C src/cud"
},
{
"path": "lib/fpn/roi_align/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "lib/fpn/roi_align/_ext/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "lib/fpn/roi_align/_ext/roi_align/__init__.py",
"chars": 308,
"preview": "\nfrom torch.utils.ffi import _wrap_function\nfrom ._roi_align import lib as _lib, ffi as _ffi\n\n__all__ = []\ndef _import_s"
},
{
"path": "lib/fpn/roi_align/build.py",
"chars": 901,
"preview": "import os\nimport torch\nfrom torch.utils.ffi import create_extension\n# Might have to export PATH=/usr/local/cuda-8.0/bin$"
},
{
"path": "lib/fpn/roi_align/functions/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "lib/fpn/roi_align/functions/roi_align.py",
"chars": 2455,
"preview": "\"\"\"\nperforms ROI aligning\n\"\"\"\n\nimport torch\nfrom torch.autograd import Function\nfrom .._ext import roi_align\n\nclass RoIA"
},
{
"path": "lib/fpn/roi_align/modules/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "lib/fpn/roi_align/modules/roi_align.py",
"chars": 1672,
"preview": "from torch.nn.modules.module import Module\nfrom torch.nn.functional import avg_pool2d, max_pool2d\nfrom ..functions.roi_a"
},
{
"path": "lib/fpn/roi_align/src/cuda/Makefile",
"chars": 198,
"preview": "all: roi_align_kernel.cu roi_align_kernel.h\n\t/usr/local/cuda/bin/nvcc -c -o roi_align.cu.o roi_align_kernel.cu --compile"
},
{
"path": "lib/fpn/roi_align/src/cuda/roi_align_kernel.cu",
"chars": 7576,
"preview": "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <stdio.h>\n#include <math.h>\n#include <float.h>\n#include \"roi_align_kern"
},
{
"path": "lib/fpn/roi_align/src/cuda/roi_align_kernel.h",
"chars": 1136,
"preview": "#ifndef _ROI_ALIGN_KERNEL\n#define _ROI_ALIGN_KERNEL\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n__global__ void ROIAlignFor"
},
{
"path": "lib/fpn/roi_align/src/roi_align_cuda.c",
"chars": 2433,
"preview": "#include <THC/THC.h>\n#include <math.h>\n#include \"cuda/roi_align_kernel.h\"\n\nextern THCState *state;\n\nint roi_align_forwar"
},
{
"path": "lib/fpn/roi_align/src/roi_align_cuda.h",
"chars": 381,
"preview": "int roi_align_forward_cuda(int crop_height, int crop_width, float spatial_scale,\n THCudaTensor * "
},
{
"path": "lib/get_dataset_counts.py",
"chars": 2285,
"preview": "\"\"\"\nGet counts of all of the examples in the dataset. Used for creating the baseline\ndictionary model\n\"\"\"\n\nimport numpy "
},
{
"path": "lib/get_union_boxes.py",
"chars": 3895,
"preview": "\"\"\"\ncredits to https://github.com/ruotianluo/pytorch-faster-rcnn/blob/master/lib/nets/network.py#L91\n\"\"\"\n\nimport torch\nf"
},
{
"path": "lib/lstm/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "lib/lstm/decoder_rnn.py",
"chars": 12192,
"preview": "import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom torch.autograd import Variable\nfrom torch.nn.uti"
},
{
"path": "lib/lstm/highway_lstm_cuda/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "lib/lstm/highway_lstm_cuda/_ext/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "lib/lstm/highway_lstm_cuda/_ext/highway_lstm_layer/__init__.py",
"chars": 317,
"preview": "\nfrom torch.utils.ffi import _wrap_function\nfrom ._highway_lstm_layer import lib as _lib, ffi as _ffi\n\n__all__ = []\ndef "
},
{
"path": "lib/lstm/highway_lstm_cuda/alternating_highway_lstm.py",
"chars": 15177,
"preview": "from typing import Tuple\n\nfrom overrides import overrides\nimport torch\nfrom torch.autograd import Function, Variable\nfro"
},
{
"path": "lib/lstm/highway_lstm_cuda/build.py",
"chars": 798,
"preview": "# pylint: disable=invalid-name\nimport os\nimport torch\nfrom torch.utils.ffi import create_extension\n\nif not torch.cuda.is"
},
{
"path": "lib/lstm/highway_lstm_cuda/make.sh",
"chars": 1610,
"preview": "#!/usr/bin/env bash\n\nCUDA_PATH=/usr/local/cuda/\n\n# Which CUDA capabilities do we want to pre-build for?\n# https://develo"
},
{
"path": "lib/lstm/highway_lstm_cuda/src/highway_lstm_cuda.c",
"chars": 3781,
"preview": "#include <THC/THC.h>\n#include \"highway_lstm_kernel.h\"\n\nextern THCState *state;\n\nint highway_lstm_forward_cuda(int inputS"
},
{
"path": "lib/lstm/highway_lstm_cuda/src/highway_lstm_cuda.h",
"chars": 929,
"preview": "int highway_lstm_forward_cuda(int inputSize, int hiddenSize, int miniBatch, int numLayers, int seqLength,\n THCudaTens"
},
{
"path": "lib/lstm/highway_lstm_cuda/src/highway_lstm_kernel.cu",
"chars": 18610,
"preview": "#include \"cuda_runtime.h\"\n#include \"curand.h\"\n#include \"cublas_v2.h\"\n#include <iostream>\n\n#ifdef __cplusplus\nextern \"C\" "
},
{
"path": "lib/lstm/highway_lstm_cuda/src/highway_lstm_kernel.h",
"chars": 854,
"preview": "#include <cublasXt.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nvoid highway_lstm_forward_ongpu(int inputSize, int hidden"
},
{
"path": "lib/object_detector.py",
"chars": 25429,
"preview": "import numpy as np\nimport torch\nimport torch.nn as nn\nimport torch.nn.parallel\nfrom torch.autograd import Variable\nfrom "
},
{
"path": "lib/pytorch_misc.py",
"chars": 14457,
"preview": "\"\"\"\nMiscellaneous functions that might be useful for pytorch\n\"\"\"\n\nimport h5py\nimport numpy as np\nimport torch\nfrom torch"
},
{
"path": "lib/rel_model.py",
"chars": 23579,
"preview": "\"\"\"\nLet's get the relationships yo\n\"\"\"\n\nimport numpy as np\nimport torch\nimport torch.nn as nn\nimport torch.nn.parallel\nf"
},
{
"path": "lib/rel_model_stanford.py",
"chars": 9332,
"preview": "\"\"\"\nLet's get the relationships yo\n\"\"\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.parallel\nfrom torch.autograd "
},
{
"path": "lib/resnet.py",
"chars": 4805,
"preview": "import torch.nn as nn\nimport math\nimport torch.utils.model_zoo as model_zoo\nfrom torchvision.models.resnet import model_"
},
{
"path": "lib/sparse_targets.py",
"chars": 1718,
"preview": "from lib.word_vectors import obj_edge_vectors\nimport torch.nn as nn\nimport torch\nfrom torch.autograd import Variable\nimp"
},
{
"path": "lib/surgery.py",
"chars": 2963,
"preview": "# create predictions from the other stuff\n\"\"\"\nGo from proposals + scores to relationships.\n\npred-cls: No bbox regression"
},
{
"path": "lib/word_vectors.py",
"chars": 4711,
"preview": "\"\"\"\nAdapted from PyTorch's text library.\n\"\"\"\n\nimport array\nimport os\nimport zipfile\n\nimport six\nimport torch\nfrom six.mo"
},
{
"path": "misc/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "misc/motifs.py",
"chars": 6096,
"preview": "\"\"\"\nSCRIPT TO MAKE MEMES. this was from an old version of the code, so it might require some fixes to get working.\n\n\"\"\"\n"
},
{
"path": "misc/object_types.txt",
"chars": 2361,
"preview": "__background__\tbackground\nairplane\tvehicle\nanimal\tanimal\narm\tpart_animal_person\nbag\tclothes\nbanana\tfood\nbasket\tartifact\n"
},
{
"path": "misc/relation_types.txt",
"chars": 908,
"preview": "__background__\tbackground\nabove\tgeometric\nacross\tgeometric\nagainst\tgeometric\nalong\tgeometric\nand\tgeometric\nat\tgeometric\n"
},
{
"path": "models/_visualize.py",
"chars": 9693,
"preview": "\"\"\"\nVisualization script. I used this to create the figures in the paper.\n\nWARNING: I haven't tested this in a while. It"
},
{
"path": "models/eval_rel_count.py",
"chars": 9552,
"preview": "\"\"\"\nBaseline model that works by simply iterating through the training set to make a dictionary.\n\nAlso, caches this (we "
},
{
"path": "models/eval_rels.py",
"chars": 4353,
"preview": "\nfrom dataloaders.visual_genome import VGDataLoader, VG\nimport numpy as np\nimport torch\n\nfrom config import ModelConfig\n"
},
{
"path": "models/train_detector.py",
"chars": 9155,
"preview": "\"\"\"\nTraining script 4 Detection\n\"\"\"\nfrom dataloaders.mscoco import CocoDetection, CocoDataLoader\nfrom dataloaders.visual"
},
{
"path": "models/train_rels.py",
"chars": 8783,
"preview": "\"\"\"\nTraining script for scene graph detection. Integrated with my faster rcnn setup\n\"\"\"\n\nfrom dataloaders.visual_genome "
},
{
"path": "scripts/eval_models_sgcls.sh",
"chars": 1660,
"preview": "#!/usr/bin/env bash\n\n# This is a script that will evaluate all models for SGCLS\nexport CUDA_VISIBLE_DEVICES=$1\n\nif [ $1 "
},
{
"path": "scripts/eval_models_sgdet.sh",
"chars": 976,
"preview": "#!/usr/bin/env bash\n\n# This is a script that will evaluate all the models for SGDET\nexport CUDA_VISIBLE_DEVICES=$1\n\nif ["
},
{
"path": "scripts/pretrain_detector.sh",
"chars": 721,
"preview": "#!/usr/bin/env bash\n# Train the model without COCO pretraining\npython models/train_detector.py -b 6 -lr 1e-3 -save_dir c"
},
{
"path": "scripts/refine_for_detection.sh",
"chars": 991,
"preview": "#!/usr/bin/env bash\n\n# Refine Motifnet for detection\n\n\nexport CUDA_VISIBLE_DEVICES=$1\n\nif [ $1 == \"0\" ]; then\n echo "
},
{
"path": "scripts/train_models_sgcls.sh",
"chars": 1011,
"preview": "#!/usr/bin/env bash\n\n# This is a script that will train all of the models for scene graph classification and then evalua"
},
{
"path": "scripts/train_motifnet.sh",
"chars": 1112,
"preview": "#!/usr/bin/env bash\n\n# Train Motifnet using different orderings\n\nexport CUDA_VISIBLE_DEVICES=$1\n\nif [ $1 == \"0\" ]; then\n"
},
{
"path": "scripts/train_stanford.sh",
"chars": 318,
"preview": "#!/usr/bin/env bash\n\npython models/train_rels.py -m sgcls -model stanford -b 4 -p 400 -lr 1e-4 -ngpu 1 -ckpt checkpoints"
}
]
About this extraction
This page contains the full source code of the rowanz/neural-motifs GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 98 files (1.0 MB), approximately 318.7k tokens, and a symbol index with 639 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.