Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
COM3015 Group Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Trewern, James R (PG/R - Comp Sci & Elec Eng)
COM3015 Group Project
Commits
69995a5f
Commit
69995a5f
authored
2 years ago
by
JamesTrewern
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
c6c00517
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Quick fixes
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
constants.py
+3
-1
3 additions, 1 deletion
constants.py
datahandler.py
+4
-21
4 additions, 21 deletions
datahandler.py
with
7 additions
and
22 deletions
constants.py
+
3
−
1
View file @
69995a5f
EPOCHS
=
16
BATCH_SIZE
=
32
INPUT_DIM
=
32
\ No newline at end of file
INPUT_DIM
=
32
VAL_SPLIT
=
2000
TEST_SPLIT
=
500
\ No newline at end of file
This diff is collapsed.
Click to expand it.
datahandler.py
+
4
−
21
View file @
69995a5f
...
...
@@ -29,26 +29,21 @@ def getHamDataLoaders():
df_ham
,
df_ham_single_image
=
setupHamData
()
# Then returns two dataframes, df_ham_val is a 20% split of all single images, df_ham_train is the rest
df_ham_train
,
df_ham_val
=
createHamTrain
Test
(
df_ham
,
df_ham_single_image
)
df_ham_train
,
df_ham_val
=
createHamTrain
Val
(
df_ham
,
df_ham_single_image
)
# Define the training set using the table train_df and using our defined transitions (train_transform)
train_transform
,
_
=
getTrainValTransform
(
INPUT_DIM
,
0.48215827
,
0.24348505
)
train_transform
,
val_transform
=
getTrainValTransform
(
INPUT_DIM
,
0.48215827
,
0.24348505
)
training_set
=
HAM10000
(
df_ham_train
,
transform
=
train_transform
)
trainLoader
=
DataLoader
(
training_set
,
batch_size
=
BATCH_SIZE
,
shuffle
=
True
,
num_workers
=
4
)
# Same for the validation set:
validation_set
=
HAM10000
(
df_ham_val
,
transform
=
train
_transform
)
validation_set
=
HAM10000
(
df_ham_val
,
transform
=
val
_transform
)
valLoader
=
DataLoader
(
validation_set
,
batch_size
=
BATCH_SIZE
,
shuffle
=
False
,
num_workers
=
4
)
return
trainLoader
,
valLoader
def
getHamTestLoader
():
testLoader
=
None
return
testLoader
# Excludes rows that are in the val set
# Identifies if an image is part of the train or val
def
get_val_rows
(
x
):
...
...
@@ -160,7 +155,7 @@ def equalSampling(df_ham_train):
return
concat_df_ham_train
def
createHamTrain
Test
(
df_ham
,
df_ham_single_image
):
def
createHamTrain
Val
(
df_ham
,
df_ham_single_image
):
# create a val set knowing none of the images have multi in the train set
y
=
df_ham_single_image
[
'
cell_type_idx
'
]
...
...
@@ -178,29 +173,17 @@ def createHamTrainTest(df_ham, df_ham_single_image):
count
=
0
for
x
in
df_ham
[
'
train_or_val
'
]:
#print(x)
if
x
in
val_list
:
df_ham
.
iloc
[
count
,
df_ham
.
columns
.
get_loc
(
'
train_or_val
'
)]
=
'
val
'
#print((df_ham.iloc[count, df_ham.columns.get_loc('train_or_val')]), "\t val")
count
+=
1
else
:
df_ham
.
iloc
[
count
,
df_ham
.
columns
.
get_loc
(
'
train_or_val
'
)]
=
'
train
'
#print((df_ham.iloc[count, df_ham.columns.get_loc('train_or_val')]), "\t train")
count
+=
1
#print("\n df_ham After: \n", df_ham['train_or_val'], "\n\n")
#print("\n df_ham After: \n", df_ham, "\n\n")
# filter out the train rows
df_ham_train
=
df_ham
[
df_ham
[
'
train_or_val
'
]
==
'
train
'
]
#print("Length of df_ham_train set: ", len(df_ham_train))
#print("Length of df_ham_val set: ", len(df_ham_val))
# df_ham_val is a 20% split of all single images, df_ham_train is the rest
#print("\nTraining samples: ", df_ham_train[['cell_type', 'cell_type_idx']].value_counts(), "\n")
#print("\nTest Samples (No multi): ", df_ham_val[['cell_type', 'cell_type_idx']].value_counts(), "\n")
#print("\nTotal Samples: ", df_ham[['cell_type', 'cell_type_idx']].value_counts(), "\n")
# Equilising training samples
concat_df_ham_train
=
equalSampling
(
df_ham_train
)
...
...
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