Skip to content
Snippets Groups Projects
Commit a8a0f55d authored by Ross Girshick's avatar Ross Girshick
Browse files

reorg code

parent caa4a46f
No related branches found
No related tags found
No related merge requests found
Showing
with 55 additions and 22 deletions
File moved
# --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
from .imdb import imdb
from .pascal_voc import pascal_voc
from . import factory
import os.path as osp
ROOT_DIR = osp.join(osp.dirname(__file__), '..', '..')
# We assume your matlab binary is in your path and called `matlab'.
# If either is not true, just add it to your path and alias it as matlab, or
# you could change this file.
MATLAB = 'matlab'
# http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python
def _which(program):
import os
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
if _which(MATLAB) is None:
msg = ("MATLAB command '{}' not found. "
"Please add '{}' to your PATH.").format(MATLAB, MATLAB)
raise EnvironmentError(msg)
File moved
......@@ -10,7 +10,7 @@ import PIL
import utils.cython_bbox
import numpy as np
import scipy.sparse
from fast_rcnn_config import cfg
import datasets
class imdb(object):
def __init__(self, name):
......@@ -62,7 +62,7 @@ class imdb(object):
@property
def cache_path(self):
return os.path.join(cfg.ROOT_DIR, 'data', 'cache')
return os.path.join(datasets.ROOT_DIR, 'data', 'cache')
@property
def num_images(self):
......
......@@ -5,6 +5,7 @@
# Written by Ross Girshick
# --------------------------------------------------------
import datasets
import datasets.pascal_voc
import os
import datasets.imdb
......@@ -15,7 +16,6 @@ import scipy.io as sio
import utils.cython_bbox
import cPickle
import subprocess
from fast_rcnn_config import cfg
class pascal_voc(datasets.imdb):
def __init__(self, image_set, year, devkit_path=None):
......@@ -81,7 +81,7 @@ class pascal_voc(datasets.imdb):
"""
Return the default path where PASCAL VOC is expected to be installed.
"""
return os.path.join(cfg.ROOT_DIR, 'data', 'VOCdevkit' + self._year)
return os.path.join(datasets.ROOT_DIR, 'data', 'VOCdevkit' + self._year)
def gt_roidb(self):
"""
......@@ -261,7 +261,7 @@ class pascal_voc(datasets.imdb):
path = os.path.join(os.path.dirname(__file__),
'VOCdevkit-matlab-wrapper')
cmd = 'cd {} && '.format(path)
cmd += '{:s} -nodisplay -nodesktop '.format(cfg.MATLAB)
cmd += '{:s} -nodisplay -nodesktop '.format(datasets.MATLAB)
cmd += '-r "dbstop if error; '
cmd += 'voc_eval(\'{:s}\',\'{:s}\',\'{:s}\',\'{:s}\',{:d}); quit;"' \
.format(self._devkit_path, comp_id,
......
......@@ -5,5 +5,6 @@
# Written by Ross Girshick
# --------------------------------------------------------
from .imdb import imdb
from .pascal_voc import pascal_voc
from . import config
from . import train
from . import test
......@@ -6,7 +6,7 @@
# --------------------------------------------------------
import numpy as np
from fast_rcnn_config import cfg
from fast_rcnn.config import cfg
import utils.cython_bbox
def _compute_targets(rois, overlaps, labels):
......
......@@ -18,16 +18,10 @@
import os
import os.path as osp
import sys
import numpy as np
# `pip install easydict` if you don't have it
from easydict import EasyDict as edict
# Add caffe to PYTHONPATH
caffe_path = osp.abspath(osp.join(osp.dirname(__file__), '..',
'caffe-fast-rcnn', 'python'))
sys.path.insert(0, caffe_path)
__C = edict()
# Consumers can get config by:
# from fast_rcnn_config import cfg
......@@ -126,15 +120,11 @@ __C.RNG_SEED = 3
__C.EPS = 1e-14
# Root directory of project
__C.ROOT_DIR = osp.abspath(osp.join(osp.dirname(__file__), '..'))
__C.ROOT_DIR = osp.join(osp.dirname(__file__), '..', '..')
# Place outputs under an experiments directory
__C.EXP_DIR = 'default'
# The shell command to start matlab
# If `matlab` is in your path, then this default should work
__C.MATLAB = 'matlab'
def get_output_path(imdb, net):
path = os.path.join(__C.ROOT_DIR, 'output', __C.EXP_DIR, imdb.name)
if net is None:
......
......@@ -8,7 +8,7 @@
import numpy as np
import cv2
import matplotlib.pyplot as plt
from fast_rcnn_config import cfg
from fast_rcnn.config import cfg
import utils.blob
def get_minibatch(roidb):
......
......@@ -5,7 +5,7 @@
# Written by Ross Girshick
# --------------------------------------------------------
from fast_rcnn_config import cfg, get_output_path
from fast_rcnn.config import cfg, get_output_path
import argparse
from utils.timer import Timer
import numpy as np
......
......@@ -5,7 +5,7 @@
# Written by Ross Girshick
# --------------------------------------------------------
from fast_rcnn_config import cfg, get_output_path
from fast_rcnn.config import cfg, get_output_path
import numpy as np
import cv2
import caffe
......
File moved
File moved
File moved
File moved
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment