Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
tongue-diagnosis
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhiyang.zhou
tongue-diagnosis
Commits
445d587e
Commit
445d587e
authored
Jul 09, 2021
by
zhiyang.zhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a bug of preprocess_data
parent
96e31bcc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
img_dataset.py
img_dataset.py
+20
-19
No files found.
img_dataset.py
View file @
445d587e
...
@@ -89,32 +89,33 @@ def preprocess_data():
...
@@ -89,32 +89,33 @@ def preprocess_data():
if
os
.
path
.
isdir
(
path
):
if
os
.
path
.
isdir
(
path
):
# take image dir and xlsx file
# take image dir and xlsx file
sub_paths
=
os
.
listdir
(
path
)
sub_paths
=
os
.
listdir
(
path
)
img_path
=
None
img_path
s
=
[]
xlsx_path
=
None
xlsx_path
=
None
for
j
in
range
(
0
,
len
(
sub_paths
)):
for
j
in
range
(
0
,
len
(
sub_paths
)):
sub_path
=
os
.
path
.
join
(
path
,
sub_paths
[
j
])
sub_path
=
os
.
path
.
join
(
path
,
sub_paths
[
j
])
if
os
.
path
.
isdir
(
sub_path
):
if
os
.
path
.
isdir
(
sub_path
):
img_path
=
sub_path
img_path
s
.
append
(
sub_path
)
elif
os
.
path
.
isfile
(
sub_path
):
elif
os
.
path
.
isfile
(
sub_path
):
xlsx_path
=
sub_path
xlsx_path
=
sub_path
# take patient info
# take images
# take images
processed_dir
=
'./processed-data'
for
img_path
in
img_paths
:
if
not
os
.
path
.
exists
(
processed_dir
):
processed_dir
=
'./processed-data'
os
.
makedirs
(
processed_dir
)
if
not
os
.
path
.
exists
(
processed_dir
):
img_files
=
os
.
listdir
(
img_path
)
os
.
makedirs
(
processed_dir
)
img_files
=
os
.
listdir
(
img_path
)
for
k
in
range
(
0
,
len
(
img_files
)):
img_file
=
os
.
path
.
join
(
img_path
,
img_files
[
k
])
for
k
in
range
(
0
,
len
(
img_files
)):
img_file_only
=
img_files
[
k
]
img_file
=
os
.
path
.
join
(
img_path
,
img_files
[
k
])
islabeled
,
name
,
label
=
check_label
(
xlsx_path
,
img_file_only
,
property
=
property
)
img_file_only
=
img_files
[
k
]
if
islabeled
and
label
!=
None
:
islabeled
,
name
,
label
=
check_label
(
xlsx_path
,
img_file_only
,
property
=
property
)
if
label
>=
8
:
if
islabeled
and
label
!=
None
:
continue
if
label
>=
8
:
tmpstrs
=
os
.
path
.
splitext
(
img_file_only
)
continue
dst_img_file_only
=
tmpstrs
[
0
]
+
'-'
+
property
+
'_'
+
str
(
label
)
+
tmpstrs
[
1
]
tmpstrs
=
os
.
path
.
splitext
(
img_file_only
)
dst_img_file
=
os
.
path
.
join
(
processed_dir
,
dst_img_file_only
)
dst_img_file_only
=
tmpstrs
[
0
]
+
'-'
+
property
+
'_'
+
str
(
label
)
+
tmpstrs
[
1
]
copyfile
(
img_file
,
dst_img_file
)
dst_img_file
=
os
.
path
.
join
(
processed_dir
,
dst_img_file_only
)
copyfile
(
img_file
,
dst_img_file
)
def
crop_img
():
def
crop_img
():
from
PIL
import
Image
from
PIL
import
Image
...
...
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