Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-129
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-129
2021-129
Commits
2bfaf248
Commit
2bfaf248
authored
Oct 15, 2021
by
Dinusha Dilshan Siyasinghe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete maskImage.py
parent
ca943ceb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
89 deletions
+0
-89
Backend/maskImage.py
Backend/maskImage.py
+0
-89
No files found.
Backend/maskImage.py
deleted
100644 → 0
View file @
ca943ceb
import
warnings
warnings
.
filterwarnings
(
'ignore'
)
import
os
import
sys
import
json
import
datetime
import
numpy
as
np
import
skimage.draw
import
cv2
import
random
import
math
import
re
import
time
import
tensorflow
as
tf
import
matplotlib.pyplot
as
plt
import
matplotlib.patches
as
patches
import
matplotlib.image
as
mpimg
from
mrcnn
import
utils
from
mrcnn
import
visualize
from
mrcnn.visualize
import
display_images
from
mrcnn.visualize
import
display_instances
import
mrcnn.model
as
modellib
from
mrcnn.model
import
log
from
mrcnn.config
import
Config
from
mrcnn
import
model
as
modellib
,
utils
# Root directory of the project
ROOT_DIR
=
"samples"
DEFAULT_LOGS_DIR
=
os
.
path
.
join
(
ROOT_DIR
,
"logs"
)
MODEL_DIR
=
os
.
path
.
join
(
ROOT_DIR
,
"logs"
)
WEIGHTS_PATH
=
"D:/research -app/2021-129/Backend/mask_rcnn_object_0010.h5"
class
CustomConfig
(
Config
):
"""Configuration for training on the custom dataset.
Derives from the base Config class and overrides some values.
"""
# Give the configuration a recognizable name
NAME
=
"object"
IMAGES_PER_GPU
=
1
NUM_CLASSES
=
1
+
3
# Background + labels
# Number of training steps per epoch
STEPS_PER_EPOCH
=
10
# Skip detections with < 90% confidence
DETECTION_MIN_CONFIDENCE
=
0.9
config
=
CustomConfig
()
class
InferenceConfig
(
config
.
__class__
):
# Run detection on one image at a time
GPU_COUNT
=
1
IMAGES_PER_GPU
=
1
DETECTION_MIN_CONFIDENCE
=
0.7
def
mask
():
config
=
InferenceConfig
()
config
.
display
()
#LOAD MODEL. Create model in inference mode
model
=
modellib
.
MaskRCNN
(
mode
=
"inference"
,
model_dir
=
MODEL_DIR
,
config
=
config
)
# Load COCO weights Or, load the last model you trained
weights_path
=
WEIGHTS_PATH
# Load weights
# print("Loading weights ", weights_path)
model
.
load_weights
(
weights_path
,
by_name
=
True
)
class_names
=
[
'BG'
,
'portrait'
,
'portrait_body'
,
'selfie_top'
]
# path = sys.argv[1]
path_to_new_image
=
'static/theimage.jpg'
# path_to_new_image = path.split("/")[-1]
image1
=
mpimg
.
imread
(
path_to_new_image
)
# plt.imshow(image1)
results1
=
model
.
detect
([
image1
],
verbose
=
1
)
r1
=
results1
[
0
]
visualize
.
display_instances
(
image1
,
r1
[
'rois'
],
r1
[
'masks'
],
r1
[
'class_ids'
],
class_names
,
r1
[
'scores'
],
title
=
"Predictions1"
)
return
True
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment