Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-158
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
2
Merge Requests
2
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
2022-158
2022-158
Commits
1b6c2c6f
Commit
1b6c2c6f
authored
Sep 12, 2022
by
Weerasinghe D.N.H
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BACKEND : function linning of class_model_detection_service changed
parent
6fb6d227
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
34 deletions
+34
-34
backend/services/class_model_detection_service.py
backend/services/class_model_detection_service.py
+34
-34
No files found.
backend/services/class_model_detection_service.py
View file @
1b6c2c6f
...
...
@@ -18,6 +18,22 @@ from models.method import Method
nlp
=
spacy
.
load
(
'en_core_web_sm'
)
def
component_separation
(
filename
,
class_comp_id
):
mdl1_path
=
app
.
CLASS_SAVED_MODEL_PATH
lbl1_path
=
app
.
CLASS_SAVED_LABEL_PATH
img1_path
=
app
.
SUBMISSION_PATH_CLASS
+
'/'
+
filename
boxes
,
num_entities
,
accurate_indexes
,
num_entities
,
category_index
,
class_id
=
class_object_detection
(
mdl1_path
,
lbl1_path
,
img1_path
)
# Convert the class id in their name
if
num_entities
>
0
:
for
index
in
range
(
0
,
len
(
accurate_indexes
)):
if
category_index
[
class_id
[
index
]][
'name'
]
==
'class'
or
category_index
[
class_id
][
'name'
]
==
'interface'
:
class_details_detection
(
filename
,
boxes
,
index
,
class_comp_id
)
def
class_object_detection
(
model_path
,
label_path
,
image_path
):
detect_fn
=
tf
.
saved_model
.
load
(
model_path
)
category_index
=
label_map_util
.
create_category_index_from_labelmap
(
label_path
,
use_display_name
=
True
)
...
...
@@ -43,20 +59,25 @@ def class_object_detection(model_path, label_path, image_path):
return
boxes
,
num_entities
,
accurate_indexes
,
num_entities
,
category_index
,
class_id
def
component_separation
(
filename
,
class_comp_id
):
mdl1_path
=
app
.
CLASS_SAVED_MODEL_PATH
lbl1_path
=
app
.
CLASS_SAVED_LABEL_PATH
img1_path
=
app
.
SUBMISSION_PATH_CLASS
+
'/'
+
filename
boxes
,
num_entities
,
accurate_indexes
,
num_entities
,
category_index
,
class_id
=
class_object_detection
(
mdl1_path
,
lbl1_path
,
img1_path
)
# Convert the class id in their name
if
num_entities
>
0
:
for
index
in
range
(
0
,
len
(
accurate_indexes
)):
def
class_details_detection
(
filename
,
boxes
,
index
,
class_comp_id
):
_image
=
crop_and_image_resolution
(
filename
,
boxes
,
index
)
cv2
.
imwrite
(
app
.
SUBMISSION_PATH_CLASS
+
'/'
+
"class"
+
str
(
index
),
_image
)
mdl2_path
=
app
.
CLASS_COMP_SAVED_MODEL_PATH
lbl2_path
=
app
.
CLASS_COMP_SAVED_LABEL_PATH
img2_path
=
app
.
SUBMISSION_PATH_CLASS
+
'/'
+
"class"
+
str
(
index
)
boxes_class
,
num_entities
,
accurate_indexes
,
num_entities
,
category_index
,
class_id
=
class_object_detection
(
mdl2_path
,
lbl2_path
,
img2_path
)
if
category_index
[
class_id
[
index
]][
'name'
]
==
'class'
or
category_index
[
class_id
][
'name'
]
==
'interface'
:
class_details_detection
(
filename
,
boxes
,
index
,
class_comp_id
)
if
num_entities
>
1
:
for
j
in
range
(
0
,
len
(
accurate_indexes
)):
if
category_index
[
class_id
[
j
]][
'name'
]
==
'class_attributes'
:
class_attributes
=
crop_and_image_resolution
(
img2_path
,
boxes_class
,
j
)
text
=
text_extraction
(
class_attributes
)
save_attribute_method
(
text
,
'attribute'
)
elif
category_index
[
class_id
[
j
]][
'name'
]
==
'class_methods'
:
class_methods
=
crop_and_image_resolution
(
img2_path
,
boxes_class
,
j
)
text
=
text_extraction
(
class_methods
)
save_attribute_method
(
text
,
'method'
)
def
crop_and_image_resolution
(
path
,
boxes
,
index
):
...
...
@@ -84,27 +105,6 @@ def text_extraction(image):
return
text
def
class_details_detection
(
filename
,
boxes
,
index
,
class_comp_id
):
_image
=
crop_and_image_resolution
(
filename
,
boxes
,
index
)
cv2
.
imwrite
(
app
.
SUBMISSION_PATH_CLASS
+
'/'
+
"class"
+
str
(
index
),
_image
)
mdl2_path
=
app
.
CLASS_COMP_SAVED_MODEL_PATH
lbl2_path
=
app
.
CLASS_COMP_SAVED_LABEL_PATH
img2_path
=
app
.
SUBMISSION_PATH_CLASS
+
'/'
+
"class"
+
str
(
index
)
boxes_class
,
num_entities
,
accurate_indexes
,
num_entities
,
category_index
,
class_id
=
class_object_detection
(
mdl2_path
,
lbl2_path
,
img2_path
)
if
num_entities
>
1
:
for
j
in
range
(
0
,
len
(
accurate_indexes
)):
if
category_index
[
class_id
[
j
]][
'name'
]
==
'class_attributes'
:
class_attributes
=
crop_and_image_resolution
(
img2_path
,
boxes_class
,
j
)
text
=
text_extraction
(
class_attributes
)
save_attribute_method
(
text
,
'attribute'
)
elif
category_index
[
class_id
[
j
]][
'name'
]
==
'class_methods'
:
class_methods
=
crop_and_image_resolution
(
img2_path
,
boxes_class
,
j
)
text
=
text_extraction
(
class_methods
)
save_attribute_method
(
text
,
'method'
)
def
save_attribute_method
(
text
,
typ
):
for
element
in
text
:
access
=
covert_to_access_specifier
(
element
)
...
...
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