Last active
February 6, 2025 07:49
-
-
Save pouriast/b9002493daf7d966e1a18f5b2706d56f to your computer and use it in GitHub Desktop.
dataloop_download_class #dataloop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dtlpy as dl | |
import numpy as np | |
import cv2 | |
import matplotlib | |
matplotlib.use('TkAgg') | |
import matplotlib.pyplot as plt | |
dl.login_m2m(email='', password='') | |
# == Environment Pointing | |
dl.add_environment( | |
environment='', | |
verify_ssl=True, | |
alias='', | |
gate_url="", | |
url="" | |
) | |
dl.setenv("") | |
# == get project by name | |
project = dl.projects.get(project_name='_Biology') | |
# == get dataset within project | |
dataset = project.datasets.get(dataset_name='_Track') | |
# == ***get all items from dataset*** | |
pages_all = dataset.items.list() | |
# == FILTER dataset (***get individual annotation***) | |
'''filters = dl.Filters() | |
filters.resource = dl.FiltersResource.ANNOTATION | |
filters.sort = [] | |
pages = dataset.annotations.list(filters=filters)''' | |
# == FILTER dataset (***get images that are annotated***) | |
filter = dl.Filters() | |
filter.add(field='annotated', values=True) | |
pages_filtered = dataset.items.list(filters=filter) | |
# == find ids of items that are annotated | |
file_id_annot = [] | |
for file_annot in pages_filtered.all(): | |
file_id_annot.append(file_annot.id) | |
# == find ids of all items | |
file_id = [] | |
for file in pages_all.all(): | |
file_id.append(file.id) | |
# == find ids that are different between two lists which means the ones that are not annotated | |
file_id_not_annot = set(file_id).difference(set(file_id_annot)).union(set(file_id_annot).difference(set(file_id))) | |
# == get all items from dataset | |
#### for file in dataset.items.get_all_items(): | |
for item_id in file_id_annot: | |
file = dataset.items.get(item_id=item_id) | |
file.download(local_path=r'/Train_Dataset/Dataloop', # Changed folder name to reflect BBX | |
annotation_options=[dl.VIEW_ANNOTATION_OPTIONS_JSON, | |
]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment