Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Simulation Oxydation Vcsel
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
Antoine Rouxel
Simulation Oxydation Vcsel
Compare revisions
66ba91fa4a753e0e6eef85255a85b085d663869d to 226e9b6c68cf6df2c7e297c2ca36b004aa193ea3
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
arouxel/simulation-oxydation-vcsel
Select target project
No results found
226e9b6c68cf6df2c7e297c2ca36b004aa193ea3
Select Git revision
Branches
main
Swap
Target
arouxel/simulation-oxydation-vcsel
Select target project
arouxel/simulation-oxydation-vcsel
1 result
66ba91fa4a753e0e6eef85255a85b085d663869d
Select Git revision
Branches
main
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
add main lines .\clean\generate_acquisition_V1.py
· 5f7767a8
Antoine Rouxel
authored
1 year ago
5f7767a8
pytorchLightning dataloader esquisse
· 226e9b6c
Antoine Rouxel
authored
1 year ago
226e9b6c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
clean/DataModule.py
+75
-0
75 additions, 0 deletions
clean/DataModule.py
clean/generate_acquisition_V1.py
+12
-0
12 additions, 0 deletions
clean/generate_acquisition_V1.py
with
87 additions
and
0 deletions
clean/DataModule.py
0 → 100644
View file @
226e9b6c
import
pytorch_lightning
as
pl
from
torch.utils.data
import
Dataset
,
DataLoader
import
os
import
numpy
as
np
### DATASET STRUCTURE
### --- IMAGES ONLY ---
# -- labels folder
# * example file : mask_0.png with 0,1,2,...
# -- data folder
# * example file :
class
VCSELDataset
(
Dataset
):
def
__init__
(
self
,
image_paths
,
label_paths
,
transform
=
None
):
"""
Args:
image_paths (list): List of paths to hyperspectral images.
label_paths (list): List of paths to corresponding segmentation labels.
transform (callable, optional): Optional transform to be applied on a sample.
"""
self
.
image_paths
=
image_paths
self
.
label_paths
=
label_paths
self
.
transform
=
transform
def
__len__
(
self
):
pass
def
__getitem__
(
self
,
idx
):
hyperspectral_cube
=
self
.
load_hyperspectral_cube
(
idx
)
if
self
.
transform
:
hyperspectral_cube
=
self
.
transform
(
hyperspectral_cube
)
return
hyperspectral_cube
def
load_hyperspectral_cube
(
self
,
idx
):
spectra
=
np
.
load
(
os
.
path
.
join
(
self
.
image_paths
[
idx
],
"
spectra.npy
"
))
map
=
np
.
load
(
os
.
path
.
join
(
self
.
image_paths
[
idx
],
"
map.npy
"
))
hyperspectral_cube
=
self
.
generate_hyperspectral_cube
(
spectra
,
map
)
return
hyperspectral_cube
def
generate_hyperspectral_cube
(
self
,
spectra
,
map
):
nb_of_spectra
=
spectra
.
shape
[
0
]
# Ensure map values are within valid range
map
=
np
.
clip
(
map
,
0
,
nb_of_spectra
-
1
)
# Index spectra with the map to generate the hyperspectral cube
hyperspectral_cube
=
spectra
[
map
]
return
hyperspectral_cube
class
VCSELDataModule
(
pl
.
LightningDataModule
):
def
__init__
(
self
,
data_dir
,
batch_size
,
num_workers
):
self
.
data_dir
=
data_dir
self
.
batch_size
=
batch_size
self
.
num_workers
=
num_workers
def
prepare_data
(
self
):
pass
def
setup
(
stage
):
pass
def
train_dataloader
(
self
):
pass
def
val_dataloader
(
self
):
pass
def
test_dataloader
(
self
):
pass
This diff is collapsed.
Click to expand it.
clean/generate_acquisition_V1.py
0 → 100644
View file @
226e9b6c
#--- LOADING DATA
# Load spectra
# Load ground truth png
#--- PREPROCESSING DATA
# Add smooth noise to the spectra (impurities in the materials) : ie add a std depending on lambda for each spectrum
# --> TO BE CONSIDERED CAREFULLY
# * should we generate various spectra for each material to take into account non regular surface ?
# Generate spectral filters using one of the following methods : PCA+LDA or neural network
#
This diff is collapsed.
Click to expand it.