Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output
**/__pycache__
build
.idea
**egg-info
ic15_evaluate/ch4_gt
datasets
Res50_imagenet.pth
maskrcnn_benchmark/*.so
maskrcnn_benchmark.egg-info/SOURCES.txt
ic15_evaluate/mb_ch4_results
ic15_evaluate/all_detcors.txt
ic15_evaluate/bo.json
ic15_evaluate/evaluation_results.txt
ic15_evaluate/rrc_evaluation_funcs.pyc
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ This is a pytorch-based implementation for paper [ContourNet](https://arxiv.org/

## Requirements

We recommend you to use Anaconda [BaiduYun Link](https://pan.baidu.com/s/1_J9INU-UpiT43qormibAuw)(passward:1y3v) or [Geogle Drive](https://drive.google.com/file/d/1H64lTpR3xzlSRfUxfZa4dOhAYZJcO7RU/view?usp=sharing) to manage your libraries.
We recommend you to use Anaconda [BaiduYun Link](https://pan.baidu.com/s/1_J9INU-UpiT43qormibAuw)(passward:1y3v) or [Google Drive](https://drive.google.com/file/d/1H64lTpR3xzlSRfUxfZa4dOhAYZJcO7RU/view?usp=sharing) to manage your libraries.


### Step-by-step install

```bash
conda create --name ContourNet
conda create --name ContourNet python=3.6
conda activate ContourNet
conda install ipython
pip install ninja yacs cython matplotlib tqdm scipy shapely networkx pandas
conda install pytorch=1.0 torchvision=0.2 cudatoolkit=9.0 -c pytorch
conda install pytorch=1.0 torchvision=0.2 cudatoolkit=10.0 -c pytorch
conda install -c menpo opencv
export INSTALL_DIR=$PWDcd $INSTALL_DIR
export INSTALL_DIR=$PWD
git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
python setup.py build_ext install
Expand All @@ -42,7 +42,7 @@ We recommend you to use Anaconda [BaiduYun Link](https://pan.baidu.com/s/1_J9INU
## Experiment on IC15 dataset
### Data preparing
#### step 1
Prepare data follow COCO format or you can download our [IC15dataset-BAIDU](https://pan.baidu.com/s/1GbF0PnWDKw3qn2o2XgpB7Q) (passward:ect5) or [Geogle Drive](https://drive.google.com/file/d/1ZWRQWJwhydoCsqdNlX80y94cKQedUywO/view?usp=sharing), and unzip it in
Prepare data follow COCO format or you can download our [IC15dataset-BAIDU](https://pan.baidu.com/s/1GbF0PnWDKw3qn2o2XgpB7Q) (passward:ect5) or [Google Drive](https://drive.google.com/file/d/1ZWRQWJwhydoCsqdNlX80y94cKQedUywO/view?usp=sharing), and unzip it in
```bash
datasets/.
```
Expand Down
18 changes: 9 additions & 9 deletions ic15_evaluate/eval_ic15.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
########## second step: evaluate results
dirn = "mb_ch4_results"
eval_dir = "./"
# lsc = [0.51+i*1.0/100 for i in range(30)]
lsc = [0.65]
lsc = list(range(20,90,1))
# lsc = [0.65]

f = open("evaluation_resutls.txt",'w')
f = open("evaluation_results.txt",'w')

fres = open('all_detcors.txt', 'r').readlines()

for isc in lsc:
print 'Evaluating cf threshold {} ...'.format(str(isc)),
print('Evaluating cf threshold 0.{}:'.format(str(isc)))
sys.stdout.flush()

if os.path.exists("mb_ch4.zip"):
Expand All @@ -56,19 +56,19 @@
outName = os.path.join(dirn, filename)
with open(outName, 'a') as fout:
score = s[1].split(',')[-1].strip()
if float(score)<isc:
if float(score)<isc/100.:
continue
cors = ','.join(e for e in s[1].split(',')[:-1])
fout.writelines(cors+'\n')

os.chdir("mb_ch4_results/")
os.popen("zip -r ../mb_ch4.zip ./")
os.chdir("../")
cmd = "python "+eval_dir+"script.py "+"-g="+eval_dir+"ch4_gt.zip -s=mb_ch4.zip"
cmd = "python "+eval_dir+"script.py -g=ch4_gt.zip -s=mb_ch4.zip"
output = os.popen(cmd).read()
print(output)
f.writelines("========= "+str(isc)+":\n")
f.writelines("========= 0."+str(isc)+":\n")
lout = output.split('\n')
print("output is:",output)
f.writelines(lout[1]+'\n')
f.writelines(lout[2]+'\n')

Expand All @@ -78,6 +78,6 @@
shutil.rmtree("mb_ch4_results/")

f.flush()
time.sleep(0.01)
# time.sleep(0.01)

f.close()
7 changes: 3 additions & 4 deletions ic15_evaluate/rrc_evaluation_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import os
import codecs
import importlib
from StringIO import StringIO

def print_help():
sys.stdout.write('Usage: python %s.py -g=<gtFile> -s=<submFile> [-o=<outputFolder> -p=<jsonParams>]' %sys.argv[0])
Expand Down Expand Up @@ -303,7 +302,7 @@ def main_evaluation(p,default_evaluation_params_fn,validate_data_fn,evaluate_met
evalData = evaluate_method_fn(p['g'], p['s'], evalParams)
resDict.update(evalData)

except Exception, e:
except Exception as e:
resDict['Message']= str(e)
resDict['calculated']=False

Expand Down Expand Up @@ -355,8 +354,8 @@ def main_validation(default_evaluation_params_fn,validate_data_fn):
evalParams.update( p['p'] if isinstance(p['p'], dict) else json.loads(p['p'][1:-1]) )

validate_data_fn(p['g'], p['s'], evalParams)
print 'SUCCESS'
print('SUCCESS')
sys.exit(0)
except Exception as e:
print str(e)
print(str(e))
sys.exit(101)
2 changes: 1 addition & 1 deletion ic15_evaluate/script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env pytho
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from collections import namedtuple
import rrc_evaluation_funcs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def boundary_to_mask(bo_x, bo_y, name, num):
def mask_to_roRect(mask, img_shape):
## convert mask into rotated rect
e = mask[0, :, :]
_, countours, hier = cv2.findContours(e.clone().numpy(), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE) # Aarlog
countours, hier = cv2.findContours(e.clone().numpy(), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE) # Aarlog
if len(countours) == 0:
return np.zeros((1, 8))
t_c = countours[0].copy()
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ yacs
cython
matplotlib
tqdm
scipy
shapely
networkx
pandas