Datasets
Create, update, archive and delete image datasets; check class balance and near-duplicates; import a public dataset; move one to cold storage.
On this page
A dataset is a set of images sharing one class list, addressed by its name (unique in your
organization). A name can’t contain / or be . or ..; use
directories for hierarchy.
list
One page of your organization’s datasets. archived=True lists the archived ones instead.
Source: Datasets.list
| Arg | Type | Default | Notes |
|---|---|---|---|
limit |
int |
100 |
Page size (max 1,000) |
offset |
int |
0 |
Items to skip |
archived |
bool |
False |
List archived datasets instead |
datasets = client.datasets.list(limit=100)
for ds in datasets:
print(ds.name, ds.image_count)
pictograph datasets list --limit 100
curl -s "https://api.pictograph.io/api/v1/developer/datasets/?limit=100&offset=0" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns list[Dataset]
Dataset · 24 fields
class Dataset(BaseModel):
"""A Pictograph dataset - a group of images sharing an annotation config."""
id: str
# The organization that owns it.
organization_id: str | None = None
name: str
# Its URL slug: pictograph.io/datasets/<organization>/<slug>.
slug: str | None = None
description: str | None = None
annotation_types: list[str] = ['bbox']
# Its classes; empty until it has any.
classes: list[DatasetClass] = []
# Images, archived ones excluded.
image_count: int = 0
# Images at the complete stage.
completed_image_count: int = 0
# Archived images (restorable).
archived_image_count: int = 0
# Bytes of its images, archived ones excluded.
total_size: int = 0
# Listed on Explore, readable by anyone.
is_public: bool = False
is_archived: bool = False
archived_at: datetime | None = None
# Where its images are stored: standard or coldline (cold storage).
storage_class: str = 'standard'
# Its license, a catalog id such as 'mit' or 'cc-by-4.0' ('custom': the terms are in
# license_custom_text).
license_id: str | None = None
# A custom license's terms (on get, not on list rows).
license_custom_text: str | None = None
# Its dataset card, in markdown (on get, not on list rows).
readme: str | None = None
# Where an imported dataset came from (on get, not on list rows).
source: DatasetSource | None = None
# Its Hugging Face mirror (e.g. 'pictograph/a2d2') while the mirror is live (on get,
# not on list rows).
hf_repo: str | None = None
# The image paths it shows on every card and page, in order; [] = automatic, the
# best-annotated images (on get, not on list rows).
hero_images: list[str] | None = None
# Its images, only from `datasets.get(..., include_images=True)`.
images: list[Image] | None = None
created_at: datetime
updated_at: datetime | None = None
iter
Every dataset, fetched page by page.
Source: Datasets.iter
| Arg | Type | Default | Notes |
|---|---|---|---|
page_size |
int |
100 |
Items fetched per request |
max_total |
int | None |
None |
Stop after this many items |
archived |
bool |
False |
Iterate archived datasets instead |
for ds in client.datasets.iter(page_size=100):
print(ds.name)
# Or materialize:
all_datasets = client.datasets.iter().all()
print(len(all_datasets), "datasets")
pictograph datasets list -n 1000 # pages through the API up to 1000 datasets
# Page manually with limit + offset until pagination.has_more is false.
curl -s "https://api.pictograph.io/api/v1/developer/datasets/?limit=100&offset=100" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns OffsetPager[Dataset]
Dataset · 24 fields
class Dataset(BaseModel):
"""A Pictograph dataset - a group of images sharing an annotation config."""
id: str
# The organization that owns it.
organization_id: str | None = None
name: str
# Its URL slug: pictograph.io/datasets/<organization>/<slug>.
slug: str | None = None
description: str | None = None
annotation_types: list[str] = ['bbox']
# Its classes; empty until it has any.
classes: list[DatasetClass] = []
# Images, archived ones excluded.
image_count: int = 0
# Images at the complete stage.
completed_image_count: int = 0
# Archived images (restorable).
archived_image_count: int = 0
# Bytes of its images, archived ones excluded.
total_size: int = 0
# Listed on Explore, readable by anyone.
is_public: bool = False
is_archived: bool = False
archived_at: datetime | None = None
# Where its images are stored: standard or coldline (cold storage).
storage_class: str = 'standard'
# Its license, a catalog id such as 'mit' or 'cc-by-4.0' ('custom': the terms are in
# license_custom_text).
license_id: str | None = None
# A custom license's terms (on get, not on list rows).
license_custom_text: str | None = None
# Its dataset card, in markdown (on get, not on list rows).
readme: str | None = None
# Where an imported dataset came from (on get, not on list rows).
source: DatasetSource | None = None
# Its Hugging Face mirror (e.g. 'pictograph/a2d2') while the mirror is live (on get,
# not on list rows).
hf_repo: str | None = None
# The image paths it shows on every card and page, in order; [] = automatic, the
# best-annotated images (on get, not on list rows).
hero_images: list[str] | None = None
# Its images, only from `datasets.get(..., include_images=True)`.
images: list[Image] | None = None
created_at: datetime
updated_at: datetime | None = None
get
One dataset by name or id. Unlike list, it includes readme, license_custom_text, source
and hf_repo.
Source: Datasets.get
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
include_images |
bool |
False |
Include the first images_limit image summaries |
images_limit |
int |
1000 |
Max 10,000 |
images_offset |
int |
0 |
Images to skip in that list |
ds = client.datasets.get(
dataset="road-signs",
include_images=True,
images_limit=200,
)
print(ds.image_count, len(ds.images))
pictograph datasets get road-signs --include-images --images-limit 200
curl -s "https://api.pictograph.io/api/v1/developer/datasets/road-signs?include_images=true&images_limit=200" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
# Same resource, addressed by UUID:
curl -s "https://api.pictograph.io/api/v1/developer/datasets/a3e12f0b-4c6d-4e88-9a1b-2c3d4e5f6a7b" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns Dataset
Dataset · 24 fields
class Dataset(BaseModel):
"""A Pictograph dataset - a group of images sharing an annotation config."""
id: str
# The organization that owns it.
organization_id: str | None = None
name: str
# Its URL slug: pictograph.io/datasets/<organization>/<slug>.
slug: str | None = None
description: str | None = None
annotation_types: list[str] = ['bbox']
# Its classes; empty until it has any.
classes: list[DatasetClass] = []
# Images, archived ones excluded.
image_count: int = 0
# Images at the complete stage.
completed_image_count: int = 0
# Archived images (restorable).
archived_image_count: int = 0
# Bytes of its images, archived ones excluded.
total_size: int = 0
# Listed on Explore, readable by anyone.
is_public: bool = False
is_archived: bool = False
archived_at: datetime | None = None
# Where its images are stored: standard or coldline (cold storage).
storage_class: str = 'standard'
# Its license, a catalog id such as 'mit' or 'cc-by-4.0' ('custom': the terms are in
# license_custom_text).
license_id: str | None = None
# A custom license's terms (on get, not on list rows).
license_custom_text: str | None = None
# Its dataset card, in markdown (on get, not on list rows).
readme: str | None = None
# Where an imported dataset came from (on get, not on list rows).
source: DatasetSource | None = None
# Its Hugging Face mirror (e.g. 'pictograph/a2d2') while the mirror is live (on get,
# not on list rows).
hf_repo: str | None = None
# The image paths it shows on every card and page, in order; [] = automatic, the
# best-annotated images (on get, not on list rows).
hero_images: list[str] | None = None
# Its images, only from `datasets.get(..., include_images=True)`.
images: list[Image] | None = None
created_at: datetime
updated_at: datetime | None = None
Each included image has its width, height, content_type, directory_path, and absolute
image_url, thumbnail_url and annotation_url.
create
Create a dataset with its annotation types and classes. Needs a member key.
Source: Datasets.create
| Arg | Type | Default | Notes |
|---|---|---|---|
name |
str |
required | Up to 100 characters, no /; a taken name gets a (2) suffix |
readme |
str | None |
None |
Dataset card, in Markdown |
description |
str | None |
None |
Short description, up to 2,000 characters |
annotation_types |
Sequence[str] | None |
None |
Any of bbox, polygon, polyline, keypoint and tag (an image-level label); None means ["bbox"] |
classes |
Sequence[DatasetClass | dict[str, Any]] | None |
None |
DatasetClass models or dicts; a class without a color (#RRGGBB) gets an unused palette color; None means [] |
ds = client.datasets.create(
name="new-dataset",
readme="# Road signs\n\nTraffic cameras, downtown.",
annotation_types=["bbox", "polygon"],
classes=[{"name": "car", "type": "bbox", "color": "#e6194b"}],
)
pictograph datasets create new-dataset \
--readme README.md \
--type bbox \
--type polygon
curl -s -X POST "https://api.pictograph.io/api/v1/developer/datasets/" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "new-dataset",
"readme": "# Road signs",
"annotation_types": ["bbox", "polygon"],
"classes": [{"name": "car", "type": "bbox", "color": "#e6194b"}]
}'
Returns Dataset
Dataset · 24 fields
class Dataset(BaseModel):
"""A Pictograph dataset - a group of images sharing an annotation config."""
id: str
# The organization that owns it.
organization_id: str | None = None
name: str
# Its URL slug: pictograph.io/datasets/<organization>/<slug>.
slug: str | None = None
description: str | None = None
annotation_types: list[str] = ['bbox']
# Its classes; empty until it has any.
classes: list[DatasetClass] = []
# Images, archived ones excluded.
image_count: int = 0
# Images at the complete stage.
completed_image_count: int = 0
# Archived images (restorable).
archived_image_count: int = 0
# Bytes of its images, archived ones excluded.
total_size: int = 0
# Listed on Explore, readable by anyone.
is_public: bool = False
is_archived: bool = False
archived_at: datetime | None = None
# Where its images are stored: standard or coldline (cold storage).
storage_class: str = 'standard'
# Its license, a catalog id such as 'mit' or 'cc-by-4.0' ('custom': the terms are in
# license_custom_text).
license_id: str | None = None
# A custom license's terms (on get, not on list rows).
license_custom_text: str | None = None
# Its dataset card, in markdown (on get, not on list rows).
readme: str | None = None
# Where an imported dataset came from (on get, not on list rows).
source: DatasetSource | None = None
# Its Hugging Face mirror (e.g. 'pictograph/a2d2') while the mirror is live (on get,
# not on list rows).
hf_repo: str | None = None
# The image paths it shows on every card and page, in order; [] = automatic, the
# best-annotated images (on get, not on list rows).
hero_images: list[str] | None = None
# Its images, only from `datasets.get(..., include_images=True)`.
images: list[Image] | None = None
created_at: datetime
updated_at: datetime | None = None
From the CLI, add classes with pictograph classes add.
update
Changes only the fields you pass. Needs a member key; visibility and hf_publish_enabled
need admin. classes replaces the stored list; also pass the list you read as classes_base
to merge only your changes.
Source: Datasets.update
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
name |
str | None |
None |
New name; 409 if another dataset has it |
readme |
str | None |
None |
New dataset card in Markdown (no longer generated) |
description |
str | None |
None |
Deprecated (use readme); up to 2,000 characters |
annotation_types |
Sequence[str] | None |
None |
New list of allowed annotation types |
classes |
Sequence[DatasetClass | dict[str, Any]] | None |
None |
Full class list; a class without a color keeps its own, a new one gets an unused palette color; a keypoint class may carry a skeleton (nodes, 0-indexed edges) |
classes_base |
Sequence[DatasetClass | dict[str, Any]] | None |
None |
The class list you read; your classes edit is merged onto the stored list |
visibility |
Literal["public", "private"] | None |
None |
public lists it on Explore and mirrors it to Hugging Face (with hf_publish_enabled); private removes it; a cold dataset must be restored first |
license |
str | None |
None |
License catalog id, e.g. mit or cc-by-4.0; custom with license_custom_text |
license_custom_text |
str | None |
None |
Terms of a custom license |
hf_publish_enabled |
bool | None |
None |
Mirror to Pictograph’s Hugging Face organization while public (on by default) |
hero_images |
Sequence[str] | None |
None |
Up to 6 image paths (train/a.jpg, or a.jpg at the root) shown on its cards and pages, in order; [] restores automatic picks |
client.datasets.update(
dataset="new-dataset",
readme="# Road signs\n\nUpdated card.",
)
client.datasets.update(
dataset="new-dataset",
name="renamed-dataset",
)
client.datasets.update(
dataset="renamed-dataset",
license="cc-by-4.0",
visibility="public",
)
# Add a class without dropping anyone else's:
ds = client.datasets.get(dataset="renamed-dataset")
client.datasets.update(
dataset="renamed-dataset",
classes=[*ds.classes, {"name": "truck", "type": "box"}],
classes_base=ds.classes,
)
pictograph datasets update new-dataset --readme README.md
pictograph datasets update new-dataset --name renamed-dataset
pictograph datasets update renamed-dataset --license cc-by-4.0 --visibility public
pictograph classes add renamed-dataset truck --type box # the class list: pictograph classes
curl -s -X PATCH "https://api.pictograph.io/api/v1/developer/datasets/new-dataset" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "renamed-dataset"}'
Returns Dataset
Dataset · 24 fields
class Dataset(BaseModel):
"""A Pictograph dataset - a group of images sharing an annotation config."""
id: str
# The organization that owns it.
organization_id: str | None = None
name: str
# Its URL slug: pictograph.io/datasets/<organization>/<slug>.
slug: str | None = None
description: str | None = None
annotation_types: list[str] = ['bbox']
# Its classes; empty until it has any.
classes: list[DatasetClass] = []
# Images, archived ones excluded.
image_count: int = 0
# Images at the complete stage.
completed_image_count: int = 0
# Archived images (restorable).
archived_image_count: int = 0
# Bytes of its images, archived ones excluded.
total_size: int = 0
# Listed on Explore, readable by anyone.
is_public: bool = False
is_archived: bool = False
archived_at: datetime | None = None
# Where its images are stored: standard or coldline (cold storage).
storage_class: str = 'standard'
# Its license, a catalog id such as 'mit' or 'cc-by-4.0' ('custom': the terms are in
# license_custom_text).
license_id: str | None = None
# A custom license's terms (on get, not on list rows).
license_custom_text: str | None = None
# Its dataset card, in markdown (on get, not on list rows).
readme: str | None = None
# Where an imported dataset came from (on get, not on list rows).
source: DatasetSource | None = None
# Its Hugging Face mirror (e.g. 'pictograph/a2d2') while the mirror is live (on get,
# not on list rows).
hf_repo: str | None = None
# The image paths it shows on every card and page, in order; [] = automatic, the
# best-annotated images (on get, not on list rows).
hero_images: list[str] | None = None
# Its images, only from `datasets.get(..., include_images=True)`.
images: list[Image] | None = None
created_at: datetime
updated_at: datetime | None = None
archive
Hide a dataset from the default list; everything in it stays, and unarchive
brings it back. Needs an admin key; a public dataset must be made private first.
Source: Datasets.archive
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
client.datasets.archive(dataset="old-dataset")
client.datasets.list(archived=True)
pictograph datasets archive old-dataset
curl -s -X POST "https://api.pictograph.io/api/v1/developer/datasets/old-dataset/archive" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns Dataset
Dataset · 24 fields
class Dataset(BaseModel):
"""A Pictograph dataset - a group of images sharing an annotation config."""
id: str
# The organization that owns it.
organization_id: str | None = None
name: str
# Its URL slug: pictograph.io/datasets/<organization>/<slug>.
slug: str | None = None
description: str | None = None
annotation_types: list[str] = ['bbox']
# Its classes; empty until it has any.
classes: list[DatasetClass] = []
# Images, archived ones excluded.
image_count: int = 0
# Images at the complete stage.
completed_image_count: int = 0
# Archived images (restorable).
archived_image_count: int = 0
# Bytes of its images, archived ones excluded.
total_size: int = 0
# Listed on Explore, readable by anyone.
is_public: bool = False
is_archived: bool = False
archived_at: datetime | None = None
# Where its images are stored: standard or coldline (cold storage).
storage_class: str = 'standard'
# Its license, a catalog id such as 'mit' or 'cc-by-4.0' ('custom': the terms are in
# license_custom_text).
license_id: str | None = None
# A custom license's terms (on get, not on list rows).
license_custom_text: str | None = None
# Its dataset card, in markdown (on get, not on list rows).
readme: str | None = None
# Where an imported dataset came from (on get, not on list rows).
source: DatasetSource | None = None
# Its Hugging Face mirror (e.g. 'pictograph/a2d2') while the mirror is live (on get,
# not on list rows).
hf_repo: str | None = None
# The image paths it shows on every card and page, in order; [] = automatic, the
# best-annotated images (on get, not on list rows).
hero_images: list[str] | None = None
# Its images, only from `datasets.get(..., include_images=True)`.
images: list[Image] | None = None
created_at: datetime
updated_at: datetime | None = None
To store a dataset’s images cheaply, use cold storage instead.
unarchive
Bring an archived dataset back into the default list. Needs an admin key.
Source: Datasets.unarchive
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
client.datasets.unarchive(dataset="old-dataset")
pictograph datasets unarchive old-dataset
curl -s -X POST "https://api.pictograph.io/api/v1/developer/datasets/old-dataset/unarchive" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns Dataset
Dataset · 24 fields
class Dataset(BaseModel):
"""A Pictograph dataset - a group of images sharing an annotation config."""
id: str
# The organization that owns it.
organization_id: str | None = None
name: str
# Its URL slug: pictograph.io/datasets/<organization>/<slug>.
slug: str | None = None
description: str | None = None
annotation_types: list[str] = ['bbox']
# Its classes; empty until it has any.
classes: list[DatasetClass] = []
# Images, archived ones excluded.
image_count: int = 0
# Images at the complete stage.
completed_image_count: int = 0
# Archived images (restorable).
archived_image_count: int = 0
# Bytes of its images, archived ones excluded.
total_size: int = 0
# Listed on Explore, readable by anyone.
is_public: bool = False
is_archived: bool = False
archived_at: datetime | None = None
# Where its images are stored: standard or coldline (cold storage).
storage_class: str = 'standard'
# Its license, a catalog id such as 'mit' or 'cc-by-4.0' ('custom': the terms are in
# license_custom_text).
license_id: str | None = None
# A custom license's terms (on get, not on list rows).
license_custom_text: str | None = None
# Its dataset card, in markdown (on get, not on list rows).
readme: str | None = None
# Where an imported dataset came from (on get, not on list rows).
source: DatasetSource | None = None
# Its Hugging Face mirror (e.g. 'pictograph/a2d2') while the mirror is live (on get,
# not on list rows).
hf_repo: str | None = None
# The image paths it shows on every card and page, in order; [] = automatic, the
# best-annotated images (on get, not on list rows).
hero_images: list[str] | None = None
# Its images, only from `datasets.get(..., include_images=True)`.
images: list[Image] | None = None
created_at: datetime
updated_at: datetime | None = None
delete
Permanently delete a dataset and its images. Needs an admin key. Files an imported copy
still uses are kept.
Source: Datasets.delete
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
summary = client.datasets.delete(dataset="old-dataset")
print(summary["images_deleted"], "images deleted")
pictograph datasets delete old-dataset --yes
curl -s -X DELETE "https://api.pictograph.io/api/v1/developer/datasets/old-dataset" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns DatasetDeleteResult
DatasetDeleteResult · 7 fields
class DatasetDeleteResult(BaseModel):
"""What `datasets.delete` removed."""
id: str
name: str
deleted: bool = True
# Images deleted.
images_deleted: int = 0
# Directories deleted.
directories_deleted: int = 0
# Stored files deleted.
files_deleted: int = 0
# Stored files kept because an imported copy of the dataset still uses them.
files_kept: int = 0
insights
A dataset’s composition: totals, stage counts, per-class counts (class balance), per-type totals, annotations per image and image sizes.
Source: Datasets.insights
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
health = client.datasets.insights(dataset="road-signs")
print(health.total_images, health.total_annotations)
# Class balance - instances per class, sorted:
for name, count in sorted(health.class_annotation_counts.items(), key=lambda kv: -kv[1]):
print(f"{name}: {count} annotations in {health.class_image_counts.get(name, 0)} images")
# Labeling progress:
print(health.status_counts.complete, "of", health.total_images, "complete")
# Image dimensions:
d = health.dimensions
print(f"{d.min_width}-{d.max_width} by {d.min_height}-{d.max_height}, "
f"{d.orientation.landscape} landscape / {d.orientation.portrait} portrait")
# How many images carry a low-confidence model prediction?
mc = health.model_confidence
if mc and mc.flagged:
print(f"{mc.flagged} images need review (lowest {mc.lowest:.0%})")
# ...then page them with client.images.iter(..., min_confidence_lt=0.9)
pictograph datasets insights road-signs
pictograph datasets insights road-signs --json
curl -s "https://api.pictograph.io/api/v1/developer/datasets/road-signs/insights" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns DatasetInsights
DatasetInsights · 13 fields
class DatasetInsights(BaseModel):
"""Dataset Health / Insights - headline totals, class balance, and more."""
total_images: int = 0
total_annotations: int = 0
annotated_images: int = 0
unannotated_images: int = 0
avg_annotations_per_image: float = 0.0
total_bytes: int = 0
status_counts: InsightsStatusCounts = ...
class_annotation_counts: dict[str, int] = {}
class_image_counts: dict[str, int] = {}
type_counts: dict[str, int] = {}
annotation_density: dict[str, int] = {}
dimensions: InsightsDimensions = ...
model_confidence: ModelConfidence | None = None
Counts leave out archived images. model_confidence is None unless a model drafted labels;
then it holds flagged (images under 100% confidence), lowest, avg_flagged and buckets.
near_duplicates
Group visually near-duplicate images (embedding cosine similarity at or above threshold),
so you can keep one per group and archive the rest before labeling.
Source: Datasets.near_duplicates
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
threshold |
float | None |
None |
Minimum cosine similarity, 0.5 to 0.9999 (higher is stricter); None means 0.92 |
sample |
int | None |
None |
Max images to scan (up to 2,000); None means 1000 |
neighbors |
int | None |
None |
Max matches per image; None means 10 |
max_pairs |
int | None |
None |
Max pairs returned; None means 2000 |
directory |
str | None |
None |
Only scan this directory, e.g. /train |
dup = client.datasets.near_duplicates(
dataset="road-signs",
threshold=0.92,
)
print(f"{dup.group_count} duplicate groups, {dup.redundant_count} redundant images "
f"(analyzed {dup.analyzed} of {dup.total_images})")
# Keep the first image of each group; archive the rest in one request:
redundant = [m.id for g in dup.groups for m in g.members[1:]]
client.batch.delete(
dataset="road-signs",
images=redundant,
)
# Scope the scan to one directory of a large multi-directory dataset:
dup = client.datasets.near_duplicates(
dataset="road-signs",
directory="/train",
)
pictograph datasets duplicates road-signs --threshold 0.92 --directory /train
curl -s "https://api.pictograph.io/api/v1/developer/datasets/road-signs/duplicates?threshold=0.92&directory=/train" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns NearDuplicatesResult
NearDuplicatesResult · 11 fields
class NearDuplicatesResult(BaseModel):
"""Near-duplicate clusters for a dataset + headline data-curation counts."""
groups: list[DuplicateGroup] = []
group_count: int = 0
duplicate_image_count: int = 0
redundant_count: int = 0
analyzed: int = 0
total_images: int = 0
sample_limit: int = 0
sample_capped: bool = False
pairs_capped: bool = False
threshold: float = 0.0
directory_path: str | None = None
Archived images are left out. sample_capped and pairs_capped say a bound was reached; raise
sample to compare more.
backfill_embeddings
Queue embeddings and auto-tags for images that have none (uploaded with embed=False, or never
finished), which search and the embedding map skip. Each call queues up to limit; call again
until missing is 0. For a large backlog, run up to 3 loops at once, each on its own shard.
Source: Datasets.backfill_embeddings
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
limit |
int |
500 |
Images to queue (max 500); 0 only counts |
shard |
int | None |
None |
This loop’s shard, 0 to shards - 1 |
shards |
int | None |
None |
Number of shards (max 3); loops on different shards never queue the same image |
result = client.datasets.backfill_embeddings(
dataset="road-signs",
limit=500,
)
print(result.queued, "queued;", result.remaining, "still missing")
pictograph datasets embed road-signs --limit 500
pictograph datasets embed road-signs --shard 0 --shards 3 # one of three parallel loops
curl -s -X POST "https://api.pictograph.io/api/v1/developer/datasets/road-signs/embeddings/backfill" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"limit": 500}'
Returns EmbeddingBackfill
EmbeddingBackfill · 3 fields
class EmbeddingBackfill(BaseModel):
"""What pictograph.resources.datasets.Datasets.backfill_embeddings queued."""
queued: int = 0
missing: int = 0
remaining: int = 0
download
Download a dataset’s images, annotations, or both, to a local directory, in parallel.
Source: Datasets.download
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
output_path |
str | Path | None |
None |
Local directory to write to |
mode |
DownloadMode |
"full" |
"full" · "images_only" · "annotations_only" |
status_filter |
str | None |
None |
Only images in this stage, e.g. complete |
max_workers |
int |
10 |
Files downloaded at once |
progress |
Callable[[int, int, str | None], None] | None |
None |
Called with (done, total, filename) |
report = client.datasets.download(
dataset="road-signs",
output_path="./dump",
mode="full",
status_filter="complete",
max_workers=10,
progress=lambda done, total, fn: print(f"{done}/{total} {fn}"),
)
print(report.images_downloaded, report.annotations_downloaded, len(report.failures))
pictograph datasets download road-signs --output ./dump --mode full --status complete --workers 10
# Returns the manifest of signed URLs the SDK then downloads in parallel.
curl -s "https://api.pictograph.io/api/v1/developer/datasets/road-signs/download?mode=full&status_filter=complete" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns DownloadReport
DownloadReport · 5 fields
class DownloadReport(BaseModel):
"""Result of a Datasets.download invocation."""
dataset_id: str
images_downloaded: int = 0
annotations_downloaded: int = 0
failures: list[DownloadFailure] = []
truncated: bool = False
@property
def success(self) -> bool: ...
@property
def total_attempted(self) -> int: ...
REST answers a manifest of signed URLs (60 minutes) for up to 10,000 images: items, each with
filename, file_size, image_url and annotation_url. A file that fails is listed in
report.failures, never raised.
Public datasets
Import a dataset another organization published (find it with
client.explore). The copy is private to your organization, keeps
the source’s classes, license and attribution, and stays yours if the source goes private. Needs a
member key.
import_public
Copy a public dataset into your organization: a private dataset with its images, annotations, classes, license and attribution.
Source: Datasets.import_public
| Arg | Type | Default | Notes |
|---|---|---|---|
ref |
str |
required | organization/dataset (a row’s ref from client.explore.datasets()), or a bare name with organization |
organization |
str | None |
None |
Publishing organization’s slug, when ref is a bare name |
name |
str | None |
None |
Name for the copy (default: the source’s); a taken name gets an (imported) suffix, so read dataset_name |
wait |
bool |
True |
Wait until the copy is ready; False returns at once with status="pending" |
poll_interval |
float |
3.0 |
Seconds between checks |
timeout |
float |
1800.0 |
Max seconds to wait |
job = client.datasets.import_public(
ref="pictograph-research/coco-5k",
name="coco-start",
)
print(job.status, job.dataset_name, job.image_count)
pictograph datasets import-public pictograph-research/coco-5k --name coco-start
curl -s -X POST "https://api.pictograph.io/api/v1/developer/public/datasets/pictograph-research/coco-5k/import" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "coco-start"}'
Returns PublicDatasetImport
PublicDatasetImport · 11 fields
class PublicDatasetImport(BaseModel):
"""An import of a public dataset into your organization."""
import_id: str
status: Union[Literal['pending', 'running', 'completed', 'failed', 'cancelled'], str]
# The copy in your organization.
dataset_id: str | None = None
# The copy's name (a name your organization already used is suffixed '(imported)').
dataset_name: str | None = None
source: PublicImportSource | None = None
total_images: int = 0
# Images copied so far.
image_count: int = 0
# 0-100.
progress: float = 0.0
error: str | None = None
created_at: datetime | None = None
completed_at: datetime | None = None
# It finished, one way or another.
@property
def done(self) -> bool: ...
A copy that would pass your plan’s image limit is refused (402, image_limit_exceeded). REST
answers 202 with the import pending; follow it with get_public_import.
get_public_import
An import’s progress and outcome.
Source: Datasets.get_public_import
| Arg | Type | Default | Notes |
|---|---|---|---|
job |
str |
required | Import id (import_id from import_public) |
job = client.datasets.get_public_import(job="3f6c2a1e-8b4d-4c2a-9e1f-5a7b9c0d1e2f")
print(job.status, f"{job.image_count}/{job.total_images}", job.progress)
pictograph datasets import-status 3f6c2a1e-8b4d-4c2a-9e1f-5a7b9c0d1e2f
curl -s "https://api.pictograph.io/api/v1/developer/public/imports/3f6c2a1e-8b4d-4c2a-9e1f-5a7b9c0d1e2f" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns PublicDatasetImport
PublicDatasetImport · 11 fields
class PublicDatasetImport(BaseModel):
"""An import of a public dataset into your organization."""
import_id: str
status: Union[Literal['pending', 'running', 'completed', 'failed', 'cancelled'], str]
# The copy in your organization.
dataset_id: str | None = None
# The copy's name (a name your organization already used is suffixed '(imported)').
dataset_name: str | None = None
source: PublicImportSource | None = None
total_images: int = 0
# Images copied so far.
image_count: int = 0
# 0-100.
progress: float = 0.0
error: str | None = None
created_at: datetime | None = None
completed_at: datetime | None = None
# It finished, one way or another.
@property
def done(self) -> bool: ...
status moves from pending to running to completed, failed (with error) or
cancelled.
wait_for_public_import
Wait for an import started with import_public(..., wait=False).
Source: Datasets.wait_for_public_import
| Arg | Type | Default | Notes |
|---|---|---|---|
job |
str |
required | Import id (import_id from import_public) |
poll_interval |
float |
3.0 |
Seconds between checks |
timeout |
float |
1800.0 |
Max seconds to wait |
job = client.datasets.import_public(
ref="pictograph-research/coco-5k",
wait=False,
)
job = client.datasets.wait_for_public_import(
job=job.import_id,
timeout=900,
)
print(job.dataset_name)
pictograph datasets import-public pictograph-research/coco-5k --no-wait
pictograph datasets import-status 3f6c2a1e-8b4d-4c2a-9e1f-5a7b9c0d1e2f --wait --timeout 900
# There is no wait endpoint: poll the import until its status is final.
curl -s "https://api.pictograph.io/api/v1/developer/public/imports/3f6c2a1e-8b4d-4c2a-9e1f-5a7b9c0d1e2f" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns PublicDatasetImport
PublicDatasetImport · 11 fields
class PublicDatasetImport(BaseModel):
"""An import of a public dataset into your organization."""
import_id: str
status: Union[Literal['pending', 'running', 'completed', 'failed', 'cancelled'], str]
# The copy in your organization.
dataset_id: str | None = None
# The copy's name (a name your organization already used is suffixed '(imported)').
dataset_name: str | None = None
source: PublicImportSource | None = None
total_images: int = 0
# Images copied so far.
image_count: int = 0
# 0-100.
progress: float = 0.0
error: str | None = None
created_at: datetime | None = None
completed_at: datetime | None = None
# It finished, one way or another.
@property
def done(self) -> bool: ...
An import that ends failed or cancelled raises ApiError (code job_failed or
job_cancelled; the import is its response). One still running at timeout raises
PollTimeoutError and keeps running.
Cold storage
A dataset in cold storage counts half toward your plan’s image and storage limits. Browsing,
search and annotations still work; uploads, exports, auto-annotation and full-resolution viewing
pause until it’s restored. Freezing is free; restoring is charged by size
(quote), never twice for a retry. A public dataset, or one with imported
copies, can’t freeze. Needs an admin key.
storage_status
The storage state, plus a restore quote while the dataset is cold.
Source: Datasets.storage_status
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
status = client.datasets.storage_status(dataset="road-signs")
print(status.storage_class, status.storage_state)
if status.restore_estimate:
print(f"Restore costs ${status.restore_estimate.total_micro_usd / 1_000_000:.4f}")
pictograph datasets storage road-signs
curl -s "https://api.pictograph.io/api/v1/developer/datasets/road-signs/storage" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns DatasetStorageStatus
DatasetStorageStatus · 7 fields
class DatasetStorageStatus(BaseModel):
"""Cold-storage state of a dataset (`GET /developer/datasets/{id}/storage`)."""
storage_class: str = 'standard'
storage_state: str = 'idle'
cold_since: datetime | None = None
cold_bytes: int = 0
cold_image_count: int = 0
storage_job_id: str | None = None
restore_estimate: DatasetRestoreEstimate | None = None
freeze
Move the dataset to cold storage. Free, and runs as a background job.
Source: Datasets.freeze
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
client.datasets.freeze(dataset="road-signs")
client.datasets.wait_for_storage(dataset="road-signs")
pictograph datasets freeze road-signs
curl -s -X POST "https://api.pictograph.io/api/v1/developer/datasets/road-signs/storage/freeze" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns DatasetStorageTransition
DatasetStorageTransition · 3 fields
class DatasetStorageTransition(BaseModel):
"""Acknowledgement that a freeze/restore background job started."""
job_id: str
storage_state: str
quoted_micro_usd: int | None = None
The CLI waits for the job; --no-wait returns at once.
restore
Move the dataset back to standard storage, for a charge (quote it first).
Source: Datasets.restore
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
job = client.datasets.restore(dataset="road-signs")
client.datasets.wait_for_storage(dataset="road-signs")
pictograph datasets restore road-signs
curl -s -X POST "https://api.pictograph.io/api/v1/developer/datasets/road-signs/storage/restore" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns DatasetStorageTransition
DatasetStorageTransition · 3 fields
class DatasetStorageTransition(BaseModel):
"""Acknowledgement that a freeze/restore background job started."""
job_id: str
storage_state: str
quoted_micro_usd: int | None = None
The CLI asks you to confirm the price; --yes skips the prompt and --no-wait returns at
once.
wait_for_storage
Wait for a freeze or restore to finish.
Source: Datasets.wait_for_storage
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
timeout |
float |
600.0 |
Max seconds to wait |
poll_interval |
float |
3.0 |
Seconds between checks |
status = client.datasets.wait_for_storage(
dataset="road-signs",
timeout=600.0,
poll_interval=3.0,
)
print(status.storage_class, status.storage_state)
# There is no standalone wait command: freeze and restore already block
# until done. This is what --wait (the default) is doing for you.
pictograph datasets restore road-signs --wait
# Poll the storage endpoint until storage_state is "idle".
curl -s "https://api.pictograph.io/api/v1/developer/datasets/road-signs/storage" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns DatasetStorageStatus
DatasetStorageStatus · 7 fields
class DatasetStorageStatus(BaseModel):
"""Cold-storage state of a dataset (`GET /developer/datasets/{id}/storage`)."""
storage_class: str = 'standard'
storage_state: str = 'idle'
cold_since: datetime | None = None
cold_bytes: int = 0
cold_image_count: int = 0
storage_job_id: str | None = None
restore_estimate: DatasetRestoreEstimate | None = None
as_pytorch
Load a dataset as a map-style torch.utils.data.Dataset.
Source: Datasets.as_pytorch
| Arg | Type | Default | Notes |
|---|---|---|---|
dataset |
str |
required | Dataset name or id |
root |
str | Path | None |
None |
Local cache directory for downloaded images; created if missing |
transform |
Callable[[Any], Any] | None |
None |
Applied to each PIL.Image, e.g. a torchvision transform |
target_transform |
Callable[[dict[str, Any]], Any] | None |
None |
Applied to each target dict |
class_to_idx |
dict[str, int] | None |
None |
Class name to integer label; default: the dataset’s classes in alphabetical order |
download |
bool |
True |
Download images on access; False when root already holds them |
images_limit |
int |
10000 |
Max images loaded (up to 10,000) |
augment |
Augmenter | None |
None |
An Augmenter applied on the fly; each item is a new variant with its boxes moved to match |
dataset = client.datasets.as_pytorch(
dataset="road-signs",
root="./cache",
)
# No `as-pytorch` command - it returns an in-process torch Dataset.
pictograph datasets get road-signs
# `as_pytorch` builds a torch Dataset in-process - there is no REST endpoint.
# `as_pytorch` runs locally in the SDK - there is no REST endpoint.
Returns PictographTorchDataset
Common errors
| Status | Exception | Cause |
|---|---|---|
| 400 | ValidationError |
archive on a public dataset; make it private first |
| 402 | PaymentRequiredError |
create past the plan’s dataset limit, import_public past its image limit (image_limit_exceeded), or restore without enough credits |
| 403 | ForbiddenError |
A key below member (create, update, import_public) or admin (archive, unarchive, delete, freeze, restore) |
| 404 | NotFoundError |
The name or id doesn’t exist in your organization (names are case-sensitive) |
| 409 | ConflictError |
update with a name another dataset has |
| 422 | ValidationError |
A name that contains / or is . or .. |