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
minhhoa
Flatland
Commits
b85dd6f8
Commit
b85dd6f8
authored
5 years ago
by
spmohanty
Browse files
Options
Downloads
Patches
Plain Diff
Upload and save reference to a randomly chosen static frame
parent
3ec11100
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flatland/evaluators/aicrowd_helpers.py
+21
-0
21 additions, 0 deletions
flatland/evaluators/aicrowd_helpers.py
flatland/evaluators/service.py
+5
-0
5 additions, 0 deletions
flatland/evaluators/service.py
with
26 additions
and
0 deletions
flatland/evaluators/aicrowd_helpers.py
+
21
−
0
View file @
b85dd6f8
...
@@ -2,6 +2,8 @@ import os
...
@@ -2,6 +2,8 @@ import os
import
boto3
import
boto3
import
uuid
import
uuid
import
subprocess
import
subprocess
import
glob
import
random
###############################################################
###############################################################
# Expected Env Variables
# Expected Env Variables
...
@@ -44,6 +46,25 @@ def is_grading():
...
@@ -44,6 +46,25 @@ def is_grading():
os
.
getenv
(
"
AICROWD_IS_GRADING
"
,
False
)
os
.
getenv
(
"
AICROWD_IS_GRADING
"
,
False
)
def
upload_random_frame_to_s3
(
frames_folder
):
all_frames
=
glob
.
glob
(
os
.
path
.
join
(
frames_folder
,
"
*.png
"
))
random_frame
=
random
.
choice
(
all_frames
)
s3
=
get_boto_client
()
if
not
S3_UPLOAD_PATH_TEMPLATE
:
raise
Exception
(
"
S3_UPLOAD_PATH_TEMPLATE not provided...
"
)
if
not
S3_BUCKET
:
raise
Exception
(
"
S3_BUCKET not provided...
"
)
image_target_key
=
S3_UPLOAD_PATH_TEMPLATE
.
replace
(
"
.mp4
"
,
"
.png
"
).
format
(
str
(
uuid
.
uuid4
()))
s3
.
put_object
(
ACL
=
"
public-read
"
,
Bucket
=
S3_BUCKET
,
Key
=
image_target_key
,
Body
=
open
(
random_frame
,
'
rb
'
)
)
return
image_target_key
def
upload_to_s3
(
localpath
):
def
upload_to_s3
(
localpath
):
s3
=
get_boto_client
()
s3
=
get_boto_client
()
if
not
S3_UPLOAD_PATH_TEMPLATE
:
if
not
S3_UPLOAD_PATH_TEMPLATE
:
...
...
This diff is collapsed.
Click to expand it.
flatland/evaluators/service.py
+
5
−
0
View file @
b85dd6f8
...
@@ -483,9 +483,14 @@ class FlatlandRemoteEvaluationService:
...
@@ -483,9 +483,14 @@ class FlatlandRemoteEvaluationService:
video_thumb_s3_key
=
aicrowd_helpers
.
upload_to_s3
(
video_thumb_s3_key
=
aicrowd_helpers
.
upload_to_s3
(
video_thumb_output_path
video_thumb_output_path
)
)
static_thumbnail_s3_key
=
aicrowd_helpers
.
upload_random_frame_to_s3
(
self
.
vizualization_folder_name
)
self
.
evaluation_state
[
"
score
"
][
"
media_content_type
"
]
=
"
video/mp4
"
self
.
evaluation_state
[
"
score
"
][
"
media_content_type
"
]
=
"
video/mp4
"
self
.
evaluation_state
[
"
score
"
][
"
media_large
"
]
=
video_s3_key
self
.
evaluation_state
[
"
score
"
][
"
media_large
"
]
=
video_s3_key
self
.
evaluation_state
[
"
score
"
][
"
media_thumbnail
"
]
=
video_thumb_s3_key
self
.
evaluation_state
[
"
score
"
][
"
media_thumbnail
"
]
=
video_thumb_s3_key
self
.
evaluation_state
[
"
meta
"
][
"
static_media_frame
"
]
=
static_thumbnail_s3_key
else
:
else
:
print
(
"
[WARNING] Ignoring uploading of video to S3
"
)
print
(
"
[WARNING] Ignoring uploading of video to S3
"
)
...
...
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