Skip to content

Commit

Permalink
after balance dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
cizhenshi committed Aug 3, 2019
1 parent e8240e6 commit b00a8e8
Show file tree
Hide file tree
Showing 10 changed files with 1,671 additions and 256 deletions.
120 changes: 120 additions & 0 deletions Pesudo_label.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"import mmcv\n",
"import cv2\n",
"import numpy as np\n",
"from tqdm import tqdm_notebook as tqdm"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"out_file = \"./result/test_postnms.pkl\"\n",
"ann = mmcv.load(out_file)\n",
"CLASSES = ['tennis-court', 'container-crane', 'storage-tank', 'baseball-diamond', 'plane', 'ground-track-field', 'helicopter', 'airport', 'harbor', 'ship', 'large-vehicle', 'swimming-pool', 'soccer-ball-field', 'roundabout', 'basketball-court', 'bridge', 'small-vehicle', 'helipad']"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"def generate_single_label(info, img_name, outdir, score_thresh=0.5):\n",
" bboxes = info['bbox']\n",
" polys = info['vis']\n",
" fp = open(outdir + \"{}.txt\".format(img_name), \"w\")\n",
" fp.write(\"xx\\nxx\\n\")\n",
" for i in range(len(CLASSES)):\n",
" class_name = CLASSES[i]\n",
" bbox = bboxes[i]\n",
" poly = polys[i]\n",
" if len(bbox) == 0:\n",
" continue\n",
" scores = bbox[:,4]\n",
" for p, score in zip(poly, scores):\n",
" if(score<0.5):\n",
" continue\n",
" rect = np.array(p).flatten()\n",
" rect = [str(x) for x in rect]\n",
" loc = \" \".join(rect)\n",
" out = loc + \" \" + class_name + \" 0\\n\"\n",
" fp.write(out)\n",
" fp.close()\n",
"\n",
"def generate_labels(ann, outdir, score_thresh=0.5):\n",
" img_names = ann.keys()\n",
" for img_name in tqdm(img_names):\n",
" generate_single_label(ann[img_name], img_name, outdir, score_thresh)"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9a6eff1102494dd98e264c229d098380",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(IntProgress(value=0, max=780), HTML(value='')))"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"generate_labels(ann, \"./result/pesudo/labelTxt/\", 0.5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "mm",
"language": "python",
"name": "mmdet"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
141 changes: 99 additions & 42 deletions PrepareData.ipynb

Large diffs are not rendered by default.

293 changes: 201 additions & 92 deletions Sampler.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit b00a8e8

Please sign in to comment.