Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IDATT2900 45b
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
Bård Sørensen Hestmark
IDATT2900 45b
Commits
41f9899d
Commit
41f9899d
authored
3 years ago
by
Tommy Duc Luu
Browse files
Options
Downloads
Patches
Plain Diff
saving function added v3
parent
9e9bfc77
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
interactive_CA/interactive.py
+5
-5
5 additions, 5 deletions
interactive_CA/interactive.py
with
5 additions
and
5 deletions
interactive_CA/interactive.py
+
5
−
5
View file @
41f9899d
...
@@ -95,9 +95,9 @@ class Interactive:
...
@@ -95,9 +95,9 @@ class Interactive:
else
:
else
:
image
=
to_rgb_ad
(
x
[:,
:
4
].
detach
().
cpu
())
image
=
to_rgb_ad
(
x
[:,
:
4
].
detach
().
cpu
())
save_image
(
image
,
path
,
nrow
=
1
,
padding
=
0
)
save_image
(
image
,
path
,
nrow
=
1
,
padding
=
0
)
return
np
.
asarray
(
Image
.
open
(
self
.
imgpath
))
# Do damage on model using pygame, cannot run through ssh
# Do damage on model using pygame, cannot run through ssh
def
interactive
(
self
):
def
interactive
(
self
):
x_eval
=
self
.
seedclone
()
x_eval
=
self
.
seedclone
()
...
@@ -147,12 +147,12 @@ class Interactive:
...
@@ -147,12 +147,12 @@ class Interactive:
x_eval
=
self
.
seedclone
()
x_eval
=
self
.
seedclone
()
x_eval
=
self
.
net
(
x_eval
)
x_eval
=
self
.
net
(
x_eval
)
image
=
self
.
save_cell
(
x_eval
,
self
.
imgpath
)
self
.
save_cell
(
x_eval
,
self
.
imgpath
)
cur_path
=
f
'
{
self
.
logdir
}
/
{
counter
}
.png
'
cur_path
=
f
'
{
self
.
logdir
}
/
{
counter
}
.png
'
# Damage at 51:
# Damage at 51:
if
counter
==
40
:
if
counter
==
40
:
s
ave_image
(
image
,
cur_path
,
nrow
=
1
,
padding
=
0
)
s
elf
.
save_cell
(
x_eval
,
cur_path
)
elif
counter
==
51
:
elif
counter
==
51
:
# For lower half:
# For lower half:
mpos_y
=
(
self
.
size
//
2
)
+
1
mpos_y
=
(
self
.
size
//
2
)
+
1
...
@@ -167,7 +167,7 @@ class Interactive:
...
@@ -167,7 +167,7 @@ class Interactive:
mpos_x
:
mpos_x
+
dmg_size
]
=
0
mpos_x
:
mpos_x
+
dmg_size
]
=
0
self
.
save_cell
(
x_eval
,
cur_path
)
self
.
save_cell
(
x_eval
,
cur_path
)
elif
counter
==
60
:
elif
counter
==
60
:
s
ave_image
(
image
,
cur_path
,
nrow
=
1
,
padding
=
0
)
s
elf
.
save_cell
(
x_eval
,
cur_path
)
loss
=
self
.
net
.
loss
(
x_eval
,
self
.
pad_target
)
loss
=
self
.
net
.
loss
(
x_eval
,
self
.
pad_target
)
self
.
writer
.
add_scalar
(
"
train/fit
"
,
loss
,
counter
)
self
.
writer
.
add_scalar
(
"
train/fit
"
,
loss
,
counter
)
...
@@ -182,7 +182,7 @@ class Interactive:
...
@@ -182,7 +182,7 @@ class Interactive:
# damaged += 1
# damaged += 1
# Saving and loading each image as a quick hack to get rid of the batch dimension in tensor
# Saving and loading each image as a quick hack to get rid of the batch dimension in tensor
image
=
np
.
asarray
(
Image
.
open
(
self
.
imgpath
))
self
.
game_update
(
surface
,
image
,
cellsize
)
self
.
game_update
(
surface
,
image
,
cellsize
)
time
.
sleep
(
0.00
)
# update delay
time
.
sleep
(
0.00
)
# update delay
if
counter
==
400
:
if
counter
==
400
:
...
...
This diff is collapsed.
Click to expand it.
Tommy Duc Luu
@tommydl
mentioned in commit
192a5f38
·
2 years ago
mentioned in commit
192a5f38
mentioned in commit 192a5f38c696efb777016fc0a06567eaa36015a6
Toggle commit list
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