Upload images
Upload a folder of images to a dataset with one Python call or CLI command: parallel, safe to re-run, and it keeps, groups or flattens your subfolders.
On this page
One call uploads a folder of images, creating the dataset if it doesn’t exist. A rerun skips the files already uploaded.
from pictograph import Client, UploadReport
client = Client()
report: UploadReport = client.images.upload_from_directory(
dataset="road-signs",
source_path="./road_signs",
)
print(f"{report.images_uploaded} uploaded, {report.images_skipped} skipped")
pictograph images upload-directory road-signs ./road_signs
Every argument: upload_from_directory.
Raising max_workers past its default of 8 can hit the rate limit.
Where each file lands
| Folders | SDK | CLI | ./road_signs/stop/night/5.jpg lands in |
|---|---|---|---|
| First level only (a folder per class) | organize_by_class=True (default) |
--by-class |
/stop |
| The whole tree | preserve_structure=True |
Default | /stop/night |
| None | organize_by_class=False |
--flat |
/ |
A filename is unique within its directory: /stop/001.jpg and /yield/001.jpg are two images.
Re-running and progress
A rerun skips images already in the dataset, so it picks up where a failed one stopped; with
skip_existing=False, an existing name is a failure instead. progress is called once per file:
def on_progress(done: int, total: int, filename: str | None) -> None:
print(f"[{done}/{total}] {filename}")
client.images.upload_from_directory(
dataset="road-signs",
source_path="./road_signs",
progress=on_progress,
)
Errors
A file that fails is listed in report.failures, never raised. The call raises
FileNotFoundError when source_path isn’t a directory, and NotFoundError when the dataset
doesn’t exist and create_if_missing=False.
Other ways in
| You have | Use |
|---|---|
| A V7 or Roboflow dataset | Connectors |
| A public Pictograph dataset | Explore (import a copy) |
| Images with COCO, YOLO or Pascal VOC labels | Export & conversion |
| Images with labels in Pictograph JSON | bulk_upload with annotations= |