Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
Farmbot Yolo
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robotlab
Farmbot Yolo
Commits
47b8aedc
Commit
47b8aedc
authored
3 years ago
by
Anton Tetov Johansson
Browse files
Options
Downloads
Patches
Plain Diff
download metadata together with images
parent
e30cb0a5
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/farmbot_yolo/download.py
+19
-6
19 additions, 6 deletions
src/farmbot_yolo/download.py
with
19 additions
and
6 deletions
src/farmbot_yolo/download.py
+
19
−
6
View file @
47b8aedc
...
...
@@ -3,16 +3,14 @@ import argparse
import
os
from
pathlib
import
Path
from
typing
import
List
import
json
import
requests
from
farmbot_yolo
import
creds
from
farmbot_yolo
import
TMPDIR
# note: download only returns 100 at a time!
# note: we are currently ignoreing placeholders
DEBUG_SKIP_DELETE_FILES
=
True
IMG_FILE_SUFFIX
=
"
.jpg
"
...
...
@@ -80,7 +78,19 @@ def download_images(directory: os.PathLike, delete_after=False) -> List[str]:
with
filepath
.
open
(
mode
=
"
wb
"
)
as
fp
:
fp
.
write
(
img_req
.
content
)
img_paths
.
append
(
filepath
)
img_metadata_dict
=
{
"
farmbot_metadata
"
:
{
"
id
"
:
img_dict
[
"
id
"
],
"
location
"
:
{
"
x
"
:
img_dict
[
"
meta
"
][
"
x
"
],
"
y
"
:
img_dict
[
"
meta
"
][
"
y
"
],
"
z
"
:
img_dict
[
"
meta
"
][
"
z
"
],
},
}
}
with
filepath
.
with_suffix
(
"
.json
"
).
open
(
mode
=
"
w
"
)
as
fp
:
json
.
dump
(
img_metadata_dict
,
fp
)
# post delete from cloud storage
if
delete_after
:
...
...
@@ -93,7 +103,10 @@ def download_images(directory: os.PathLike, delete_after=False) -> List[str]:
if
__name__
==
"
__main__
"
:
parser
=
argparse
.
ArgumentParser
(
description
=
"
Farmbot YOLO image downloader
"
)
parser
.
add_argument
(
"
download_dir
"
,
type
=
Path
,
help
=
"
Directory to download images too.
"
"
download_dir
"
,
type
=
Path
,
help
=
"
Directory to download images too.
"
,
default
=
TMPDIR
,
)
parser
.
add_argument
(
"
-d
"
,
"
--delete
"
,
action
=
"
store_true
"
)
...
...
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