Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pseudo_image
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Léo Calmettes
pseudo_image
Commits
5e2d0620
Commit
5e2d0620
authored
2 months ago
by
Schneider Leo
Browse files
Options
Downloads
Patches
Plain Diff
model cuda loading
parent
b3a3c45a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config/config.py
+1
-0
1 addition, 0 deletions
config/config.py
main.py
+3
-3
3 additions, 3 deletions
main.py
models/model.py
+3
-2
3 additions, 2 deletions
models/model.py
with
7 additions
and
5 deletions
config/config.py
+
1
−
0
View file @
5e2d0620
...
...
@@ -10,6 +10,7 @@ def load_args():
parser
.
add_argument
(
'
--noise_threshold
'
,
type
=
int
,
default
=
0
)
parser
.
add_argument
(
'
--lr
'
,
type
=
float
,
default
=
0.001
)
parser
.
add_argument
(
'
--batch_size
'
,
type
=
int
,
default
=
64
)
parser
.
add_argument
(
'
--model
'
,
type
=
str
,
default
=
'
ResNet18
'
)
parser
.
add_argument
(
'
--dataset_dir
'
,
type
=
str
,
default
=
'
data/processed_data/png_image/data_training
'
)
parser
.
add_argument
(
'
--output
'
,
type
=
str
,
default
=
'
output/out.csv
'
)
parser
.
add_argument
(
'
--save_path
'
,
type
=
str
,
default
=
'
output/best_model.pt
'
)
...
...
This diff is collapsed.
Click to expand it.
main.py
+
3
−
3
View file @
5e2d0620
...
...
@@ -60,7 +60,7 @@ def test(model, data_test, loss_function, epoch):
def
run
(
args
):
data_train
,
data_test
=
load_data
(
base_dir
=
args
.
dataset_dir
,
batch_size
=
args
.
batch_size
)
model
=
Classification_model
(
n_class
=
len
(
data_train
.
dataset
.
dataset
.
classes
))
model
=
Classification_model
(
model
=
args
.
model
,
n_class
=
len
(
data_train
.
dataset
.
dataset
.
classes
))
if
args
.
pretrain_path
is
not
None
:
load_model
(
model
,
args
.
pretrain_path
)
if
torch
.
cuda
.
is_available
():
...
...
@@ -89,10 +89,10 @@ def run(args):
plt
.
plot
(
train_acc
)
plt
.
plot
(
train_acc
)
plt
.
show
()
plt
.
savefig
(
'
output/training_plot_
{}_.png
'
.
format
(
args
.
output
))
plt
.
savefig
(
'
output/training_plot_
noise_{}_lr_{}_model_{}.png
'
.
format
(
args
.
noise_thresold
,
args
.
lr
,
args
.
model
))
load_model
(
model
,
args
.
save_path
)
make_prediction
(
model
,
data_test
,
'
output/confusion_matrix_
{}_.png
'
.
format
(
args
.
output
))
make_prediction
(
model
,
data_test
,
'
output/confusion_matrix_
noise_{}_lr_{}_model_{}.png
'
.
format
(
args
.
noise_thresold
,
args
.
lr
,
args
.
model
))
def
make_prediction
(
model
,
data
,
f_name
):
...
...
This diff is collapsed.
Click to expand it.
models/model.py
+
3
−
2
View file @
5e2d0620
...
...
@@ -262,10 +262,11 @@ def resnet152(num_classes=1000,**kwargs):
class
Classification_model
(
nn
.
Module
):
def
__init__
(
self
,
n_class
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
model
,
n_class
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
n_class
=
n_class
self
.
im_encoder
=
resnet18
(
num_classes
=
self
.
n_class
)
if
model
==
'
Resnet18
'
:
self
.
im_encoder
=
resnet18
(
num_classes
=
self
.
n_class
)
def
forward
(
self
,
input
):
...
...
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