Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flatland
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
Model registry
Operate
Environments
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
sfwatergit
Flatland
Commits
e60edeba
Commit
e60edeba
authored
5 years ago
by
spmohanty
Browse files
Options
Downloads
Patches
Plain Diff
Add video generation code
parent
1a5dada3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flatland/evaluators/aicrowd_helpers.py
+5
-5
5 additions, 5 deletions
flatland/evaluators/aicrowd_helpers.py
flatland/evaluators/service.py
+19
-4
19 additions, 4 deletions
flatland/evaluators/service.py
with
24 additions
and
9 deletions
flatland/evaluators/aicrowd_helpers.py
+
5
−
5
View file @
e60edeba
...
@@ -55,7 +55,7 @@ def make_subprocess_call(command, shell=False):
...
@@ -55,7 +55,7 @@ def make_subprocess_call(command, shell=False):
return
result
.
returncode
,
stdout
,
stderr
return
result
.
returncode
,
stdout
,
stderr
def
generate_movie_from_
screenshot
(
frames_folder
):
def
generate_movie_from_
frames
(
frames_folder
):
"""
"""
Expects the frames in the frames_folder folder
Expects the frames in the frames_folder folder
and then use ffmpeg to generate the video
and then use ffmpeg to generate the video
...
@@ -66,9 +66,9 @@ def generate_movie_from_screenshot(frames_folder):
...
@@ -66,9 +66,9 @@ def generate_movie_from_screenshot(frames_folder):
frames_path
=
os
.
path
.
join
(
frames_folder
,
"
flatland_frame_%04d.png
"
)
frames_path
=
os
.
path
.
join
(
frames_folder
,
"
flatland_frame_%04d.png
"
)
thumb_output_path
=
os
.
path
.
join
(
frames_folder
,
"
out_thumb.mp4
"
)
thumb_output_path
=
os
.
path
.
join
(
frames_folder
,
"
out_thumb.mp4
"
)
return_code
,
output
,
output_err
=
make_subprocess_call
(
return_code
,
output
,
output_err
=
make_subprocess_call
(
"
/usr/bin/
ffmpeg -r
25
-start_number 0 -i
"
+
"
ffmpeg -r
7
-start_number 0 -i
"
+
frames_path
+
frames_path
+
"
-c:v libx264 -vf fps=
25
-pix_fmt yuv420p -s 320x2
4
0
"
+
"
-c:v libx264 -vf fps=
7
-pix_fmt yuv420p -s 320x
3
20
"
+
thumb_output_path
thumb_output_path
)
)
if
return_code
!=
0
:
if
return_code
!=
0
:
...
@@ -79,9 +79,9 @@ def generate_movie_from_screenshot(frames_folder):
...
@@ -79,9 +79,9 @@ def generate_movie_from_screenshot(frames_folder):
frames_path
=
os
.
path
.
join
(
frames_folder
,
"
flatland_frame_%04d.png
"
)
frames_path
=
os
.
path
.
join
(
frames_folder
,
"
flatland_frame_%04d.png
"
)
output_path
=
os
.
path
.
join
(
frames_folder
,
"
out.mp4
"
)
output_path
=
os
.
path
.
join
(
frames_folder
,
"
out.mp4
"
)
return_code
,
output
,
output_err
=
make_subprocess_call
(
return_code
,
output
,
output_err
=
make_subprocess_call
(
"
/usr/bin/
ffmpeg -r
25
-start_number 0 -i
"
+
"
ffmpeg -r
7
-start_number 0 -i
"
+
frames_path
+
frames_path
+
"
-c:v libx264 -vf fps=
25
-pix_fmt yuv420p -s
320x24
0
"
+
"
-c:v libx264 -vf fps=
7
-pix_fmt yuv420p -s
600x60
0
"
+
output_path
output_path
)
)
if
return_code
!=
0
:
if
return_code
!=
0
:
...
...
This diff is collapsed.
Click to expand it.
flatland/evaluators/service.py
+
19
−
4
View file @
e60edeba
...
@@ -375,14 +375,29 @@ class FlatlandRemoteEvaluationService:
...
@@ -375,14 +375,29 @@ class FlatlandRemoteEvaluationService:
to operate on all the test environments.
to operate on all the test environments.
"""
"""
)
)
mean_reward
=
np
.
mean
(
self
.
simulation_rewards
)
mean_percentage_complete
=
np
.
mean
(
self
.
simulation_percentage_complete
)
# Generate the video
#
# Note, if you had depdency issues due to ffmpeg, you can
# install it by :
#
# conda install -c conda-forge x264 ffmpeg
print
(
"
Generating Video from thumbnails...
"
)
video_output_path
,
video_thumb_output_path
=
\
aicrowd_helpers
.
generate_movie_from_frames
(
self
.
vizualization_folder_name
)
print
(
"
Videos :
"
,
video_output_path
,
video_thumb_output_path
)
_command_response
=
{}
_command_response
=
{}
_command_response
[
'
type
'
]
=
messages
.
FLATLAND_RL
.
ENV_SUBMIT_RESPONSE
_command_response
[
'
type
'
]
=
messages
.
FLATLAND_RL
.
ENV_SUBMIT_RESPONSE
_payload
=
{}
_payload
=
{}
_payload
[
'
mean_reward
'
]
=
np
.
mean
(
self
.
simulation_rewards
)
_payload
[
'
mean_reward
'
]
=
mean_reward
_payload
[
'
mean_percentage_complete
'
]
=
\
_payload
[
'
mean_percentage_complete
'
]
=
mean_percentage_complete
np
.
mean
(
self
.
simulation_percentage_complete
)
_command_response
[
'
payload
'
]
=
_payload
_command_response
[
'
payload
'
]
=
_payload
self
.
send_response
(
_command_response
,
command
)
self
.
send_response
(
_command_response
,
command
)
...
...
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