Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nibio_graph_sem_seg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maciej Wielgosz
nibio_graph_sem_seg
Commits
41a20aa6
Commit
41a20aa6
authored
2 years ago
by
Maciej Wielgosz
Browse files
Options
Downloads
Patches
Plain Diff
updated flow for splitting and merging
parent
9d7fb3af
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
PyG_implementation/my_data_loader.py
+19
-2
19 additions, 2 deletions
PyG_implementation/my_data_loader.py
with
19 additions
and
2 deletions
PyG_implementation/my_data_loader.py
+
19
−
2
View file @
41a20aa6
...
...
@@ -11,7 +11,7 @@ from torch_geometric.data import (
Data
,
InMemoryDataset
)
from
torch_geometric.io
import
read
_txt_array
from
torch_geometric.io
import
parse
_txt_array
class
MyData
(
InMemoryDataset
):
...
...
@@ -82,11 +82,28 @@ class MyData(InMemoryDataset):
data_list
=
self
.
process_filenames
(
split_filenames
)
torch
.
save
(
self
.
collate
(
data_list
),
self
.
processed_paths
[
i
])
def
read_txt_array
(
self
,
path
,
sep
=
'
,
'
,
start
=
0
,
end
=
None
,
dtype
=
None
,
device
=
None
):
with
open
(
path
,
'
r
'
)
as
f
:
src
=
f
.
read
().
split
(
'
\n
'
)
# Check if the first line is a header
if
any
(
c
.
isalpha
()
for
c
in
src
[
0
]):
# If it's a header, remove it from src
src
=
src
[
1
:]
src
=
src
[:
-
1
]
# Exclude the last line, as in your original code
# # Split each line into a list of numbers
# src = [line.split(sep) for line in src]
return
parse_txt_array
(
src
,
sep
,
start
,
end
,
dtype
,
device
)
def
process_filenames
(
self
,
filenames
):
data_list
=
[]
for
name
in
filenames
:
data
=
read_txt_array
(
osp
.
join
(
self
.
raw_dir
,
name
))
data
=
self
.
read_txt_array
(
osp
.
join
(
self
.
raw_dir
,
name
))
pos
=
data
[:,
:
3
]
x
=
data
[:,
3
:
6
]
y
=
data
[:,
self
.
label_location
].
type
(
torch
.
long
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment