Skip to content

Commit 87c4f74

Browse files
Bordawaleedka
authored andcommitted
fix import in ipynb, clear init, minor upadte by comments
1 parent 1afcbb5 commit 87c4f74

13 files changed

+32
-45
lines changed

README.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,6 @@ All required packages are listed in standard file:
167167
pip3 install -r requirements.txt
168168
```
169169

170-
## Installation
171-
172-
The installation as possible using following command:
173-
```bash
174-
python3 setup.py build_ext --inplace
175-
python3 setup.py install
176-
```
177-
178170
### MS COCO Requirements:
179171
To train or test on MS COCO, you'll also need:
180172
* pycocotools (installation instructions below)
@@ -188,7 +180,10 @@ If you use Docker, the code has been verified to work on
188180

189181

190182
## Installation
191-
1. Clone this repository
183+
1. Clone this repository. The installation as possible using following command:
184+
```bash
185+
python3 setup.py install
186+
```
192187
2. Download pre-trained COCO weights (mask_rcnn_coco.h5) from the [releases page](https://github.com/matterport/Mask_RCNN/releases).
193188
3. (Optional) To train or test on MS COCO install `pycocotools` from one of these repos. They are forks of the original pycocotools with fixes for Python3 and Windows (the official repo doesn't seem to be active anymore).
194189

mrcnn/__init__.py

-17
Original file line numberDiff line numberDiff line change
@@ -1,18 +1 @@
1-
import os
2-
import logging
31

4-
import matplotlib
5-
import numpy as np
6-
7-
# in case you are running on machine without display, e.g. server
8-
if os.environ.get('DISPLAY', '') == '' \
9-
and matplotlib.rcParams['backend'] != 'agg':
10-
logging.warning('No display found. Using non-interactive Agg backend')
11-
# https://matplotlib.org/faq/usage_faq.html
12-
matplotlib.use('Agg')
13-
14-
# parse the numpy versions
15-
np_version = [int(i) for i in np.version.full_version.split('.')]
16-
# comparing strings does not work for version lower 1.10
17-
if np_version >= [1, 14]:
18-
np.set_printoptions(legacy='1.13')

mrcnn/model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2033,7 +2033,7 @@ def find_last(self):
20332033
dir_name = os.path.join(self.model_dir, dir_names[-1])
20342034
# Find the last checkpoint
20352035
checkpoints = next(os.walk(dir_name))[2]
2036-
checkpoints = filter(lambda f: f.startswith("mrcnn"), checkpoints)
2036+
checkpoints = filter(lambda f: f.startswith("mask_rcnn"), checkpoints)
20372037
checkpoints = sorted(checkpoints)
20382038
if not checkpoints:
20392039
return dir_name, None

mrcnn/visualize.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@
77
Written by Waleed Abdulla
88
"""
99

10+
import os
11+
import logging
1012
import random
1113
import itertools
1214
import colorsys
15+
16+
import matplotlib
17+
# in case you are running on machine without display, e.g. server
18+
if os.environ.get('DISPLAY', '') == '' \
19+
and matplotlib.rcParams['backend'] != 'agg':
20+
logging.warning('No display found. Using non-interactive Agg backend')
21+
# https://matplotlib.org/faq/usage_faq.html
22+
matplotlib.use('Agg')
23+
1324
import numpy as np
1425
from skimage.measure import find_contours
1526
import matplotlib.pyplot as plt
16-
import matplotlib.patches as patches
17-
import matplotlib.lines as lines
27+
from matplotlib import patches, lines
1828
from matplotlib.patches import Polygon
1929
import IPython.display
2030

samples/balloon/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ Open the `inspect_balloon_data.ipynb` or `inspect_balloon_model.ipynb` Jupter no
3030
## Train the Balloon model
3131

3232
Train a new model starting from pre-trained COCO weights
33-
```bash
33+
```
3434
python3 balloon.py train --dataset=/path/to/balloon/dataset --weights=coco
3535
```
3636

3737
Resume training a model that you had trained earlier
38-
```bash
38+
```
3939
python3 balloon.py train --dataset=/path/to/balloon/dataset --weights=last
4040
```
4141

4242
Train a new model starting from ImageNet weights
43-
```bash
43+
```
4444
python3 balloon.py train --dataset=/path/to/balloon/dataset --weights=imagenet
4545
```
4646

samples/balloon/inspect_balloon_data.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
"\n",
5050
"# Import Mask RCNN\n",
5151
"sys.path.append(ROOT_DIR)\n",
52-
"import mrcnn.utils\n",
53-
"import mrcnn.visualize\n",
52+
"from mrcnn import utils\n",
53+
"from mrcnn import visualize\n",
5454
"from mrcnn.visualize import display_images\n",
5555
"import mrcnn.model as modellib\n",
5656
"from mrcnn.model import log\n",

samples/balloon/inspect_balloon_model.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
"\n",
4646
"# Import Mask RCNN\n",
4747
"sys.path.append(ROOT_DIR)\n",
48-
"import mrcnn.utils\n",
49-
"import mrcnn.visualize\n",
48+
"from mrcnn import utils\n",
49+
"from mrcnn import visualize\n",
5050
"from mrcnn.visualize import display_images\n",
5151
"import mrcnn.model as modellib\n",
5252
"from mrcnn.model import log\n",

samples/inspect_data.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
"import matplotlib.lines as lines\n",
4040
"from matplotlib.patches import Polygon\n",
4141
"\n",
42-
"import mrcnn.utils\n",
43-
"import mrcnn.visualize\n",
42+
"from mrcnn import utils\n",
43+
"from mrcnn import visualize\n",
4444
"from mrcnn.visualize import display_images\n",
4545
"import mrcnn.model as modellib\n",
4646
"from mrcnn.model import log\n",

samples/inspect_model.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"import matplotlib.pyplot as plt\n",
3636
"import matplotlib.patches as patches\n",
3737
"\n",
38-
"import mrcnn.utils\n",
39-
"import mrcnn.visualize\n",
38+
"from mrcnn import utils\n",
39+
"from mrcnn import visualize\n",
4040
"from mrcnn.visualize import display_images\n",
4141
"import mrcnn.model as modellib\n",
4242
"from mrcnn.model import log\n",

samples/inspect_weights.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
"import matplotlib.pyplot as plt\n",
3232
"import keras\n",
3333
"\n",
34-
"import mrcnn.utils\n",
34+
"from mrcnn import utils\n",
3535
"import mrcnn.model as modellib\n",
36-
"import mrcnn.visualize\n",
36+
"from mrcnn import visualize\n",
3737
"from mrcnn.model import log\n",
3838
"\n",
3939
"%matplotlib inline \n",

mrcnn/shapes.py samples/shapes.py

File renamed without changes.

samples/train_shapes.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
"import matplotlib.pyplot as plt\n",
3939
"\n",
4040
"from mrcnn.config import Config\n",
41-
"import mrcnn.utils\n",
41+
"from mrcnn import utils\n",
4242
"import mrcnn.model as modellib\n",
43-
"import mrcnn.visualize\n",
43+
"from mrcnn import visualize\n",
4444
"from mrcnn.model import log\n",
4545
"\n",
4646
"%matplotlib inline \n",

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
The build/compilations setup
33
44
>> pip install -r requirements.txt
5-
>> python setup.py build_ext --inplace
65
>> python setup.py install
76
87
For uploading to PyPi follow instructions

0 commit comments

Comments
 (0)