project¶
A project: a folder holding deeperfly.toml, and everything made for its videos.
The manifest, Manifest, names the videos the project
works on (file patterns relative to the folder, or absolute), which views each carries
and which are mirrored, the skeleton, the animal count, the active calibration and,
optionally, the precedence of runs. The folder holds what deeperfly produces for
those videos: labels.h5, calibrations/, suggestions.json, results/ and
renders/ (ADR-0081). The recommended layout, and the one
create_default writes, is a folder
deeperfly/ inside the directory holding the videos.
project = Project.resolve("/data/260730_001") # or .../260730_001/deeperfly
project.views # the V axis, the manifest's order
rig = project.rig(project.calibration()) # the active calibration applied
A Project opens nothing: its videos are opened by open_recording. A Collection is projects given together, and nothing is stored for it.
Collection
dataclass
¶
Projects given together, to the GUI or training; nothing is stored for it.
Attributes:
| Name | Type | Description |
|---|---|---|
projects |
tuple[Project, ...]
|
The projects, in the order given. |
Source code in src/deeperfly/project.py
get ¶
The project in folder (KeyError when it is not one of the collection).
Source code in src/deeperfly/project.py
open
classmethod
¶
The projects some paths stand for: each a project or a directory of them.
A path resolves to a project as Project.resolve does, never creating one; else its children that do are taken, in name order.
Raises:
| Type | Description |
|---|---|
ValueError
|
If a path stands for no project, or a project comes twice. |
Source code in src/deeperfly/project.py
skeleton_digest ¶
The skeleton digest every project shares, or None when they differ.
Manifest ¶
Bases: Table
deeperfly.toml: the videos a project works on and how they are laid out.
Attributes:
| Name | Type | Description |
|---|---|---|
format_version |
int
|
The manifest's schema version, |
skeleton |
str
|
A packaged preset name, or a |
animals |
int
|
How many animals the videos may hold: the instance slots. |
active_calibration |
int | None
|
The id of the calibration the GUI labels with, or |
mirrored |
tuple[str, ...]
|
The views the apparatus reflects (ADR-0053). |
videos |
dict[str, tuple[str, ...]]
|
|
layout |
dict[str, tuple[str, ...]]
|
|
detections |
ManifestDetections
|
The |
Source code in src/deeperfly/project.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
views
property
¶
The view names in order, the V axis: the layout's, else the video keys.
load
classmethod
¶
Parse a deeperfly.toml, its format version before the rest (ADR-0061).
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the file is not valid TOML, is another format version, or breaks a rule, the message naming the file. |
Source code in src/deeperfly/project.py
to_table ¶
The mapping deeperfly.io.toml writes, scalars before tables.
active_calibration, mirrored, [layout] and [detections] are left out
when unset.
Source code in src/deeperfly/project.py
ManifestDetections ¶
Bases: Table
[detections]: which runs supply the 2D detections, first wins (ADR-0083).
Attributes:
| Name | Type | Description |
|---|---|---|
runs |
tuple[str, ...]
|
Run names, |
Source code in src/deeperfly/project.py
Project
dataclass
¶
A project folder and its parsed manifest; nothing is opened.
Build one with load,
resolve or
create_default. The editing
functions of this module return a new Project over the rewritten manifest.
Attributes:
| Name | Type | Description |
|---|---|---|
folder |
Path
|
The folder holding |
manifest |
Manifest
|
Its parsed manifest. |
Source code in src/deeperfly/project.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | |
calibrations_dir
property
¶
The numbered calibrations, whether or not the directory exists yet.
renders_dir
property
¶
The rendered videos, renders/<run>/, whether or not it exists yet.
results_dir
property
¶
The runs, results/<name>.h5, whether or not the directory exists yet.
calibration ¶
A calibration by id, or the active one; None only when none is active.
Raises:
| Type | Description |
|---|---|
KeyError
|
If a given |
Source code in src/deeperfly/project.py
create_default
classmethod
¶
Make the default project, <directory>/deeperfly/, from its video files.
The manifest default builds, written.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
FileExistsError
|
If the default project's manifest already exists. |
Source code in src/deeperfly/project.py
default
classmethod
¶
Build the default project, <directory>/deeperfly/, in memory.
One video per file, named by its stem and sorted, each one view of its own
name; fly38, one animal, entries ../<file>, glob-escaped when the name
holds *?[. Nothing is written: this is what
create_default writes, and what a
dry run plans against.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/deeperfly/project.py
frame_sizes ¶
Each view's frame (height, width), probed once per video (ADR-0056).
Source code in src/deeperfly/project.py
label_files ¶
The project's label files, keyed to its views, skeleton and frame count.
Without n_frames the recording is opened for the frame count its videos agree
on, so hold the result for a session's reads and writes.
Source code in src/deeperfly/project.py
load
classmethod
¶
The project in folder.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If |
ConfigError
|
If the manifest is not valid. |
Source code in src/deeperfly/project.py
placed_views ¶
A calibration's views checked against the manifest, in its view order.
Views are matched by name; the manifest fixes their order and which are mirrored.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the view sets differ, or a view's |
Source code in src/deeperfly/project.py
resolve
classmethod
¶
The project a path stands for, as every command resolves one (ADR-0081).
A project is used as is; else <path>/deeperfly/ if that is a project; else,
with create, the default project is made in <path>/deeperfly/ from the
video files <path> holds.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If |
ValueError
|
If it resolves to no project and none is to be created, or it holds no video file to create one from. |
Source code in src/deeperfly/project.py
results_paths ¶
Every run's results file, results/**/*.h5, sorted.
rig ¶
The manifest's views under a calibration's parameters, in manifest order.
frame_hw sets an orbit view's default principal point; without it the
videos are probed for their frame sizes.
Raises:
| Type | Description |
|---|---|
ValueError
|
As placed_views. |
Source code in src/deeperfly/project.py
run_name ¶
The run a results file is, results/<name>.h5 -> <name>, or None.
Source code in src/deeperfly/project.py
save ¶
Rewrite the manifest in place, atomically: an edit of this project.
skeleton ¶
skeleton_source ¶
The skeleton's TOML: a .toml path against the folder, else a preset.
A .. climbs out of the real folder, as in a video pattern
(under_folder).
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the path is no file or the name no preset. |
Source code in src/deeperfly/project.py
video_paths ¶
The files of one video, in stream order; a glob's matches sorted.
Raises:
| Type | Description |
|---|---|
KeyError
|
If the manifest names no such video. |
FileNotFoundError
|
If a pattern matches no file. |
ValueError
|
If a pattern names a directory. |
Source code in src/deeperfly/project.py
add_calibration ¶
Add a calibration under calibrations/ and return the project and its id.
Its views are written in the manifest's order. It becomes active only when none is.
Raises:
| Type | Description |
|---|---|
ValueError
|
As placed_views. |
Source code in src/deeperfly/project.py
classify ¶
What a path is to deeperfly, the question the GUI's launcher asks.
"project": it or its deeperfly/ holds a manifest; "videos": a directory of
video files without a project, which setup makes one of; "collection": a
directory whose children resolve to projects; "empty": none of these;
"missing": nothing is there.
Source code in src/deeperfly/project.py
expand_projects ¶
The projects some paths or globs name, relative to root, in order, once each.
A path must resolve to a project or be a directory of them, whose children that
resolve to one are taken in name order, as
Collection.open takes them; a glob must match
something, and a match that resolves to no project is logged and skipped. A ..
in either is taken lexically, without following a symlinked root, as every path
in a config document is. Nothing is created.
Raises:
| Type | Description |
|---|---|
ConfigError
|
If a glob matches nothing. |
(FileNotFoundError, ValueError)
|
If a path resolves to no project and holds none. |
Source code in src/deeperfly/project.py
project_names ¶
A distinct short name per project folder: its shortest distinct suffix.
The names are the last k parts of each folder's path, k the least that tells
them apart, with a trailing /deeperfly dropped (unless the folder above is a
project too). /mnt/a/001/deeperfly and /home/b/002/deeperfly are 001 and
002; the default project of /data/260730_001 beside
/data/260730_001/deeperfly_bc gives 260730_001 and
260730_001/deeperfly_bc. One folder is named by its leaf.
Raises:
| Type | Description |
|---|---|
ValueError
|
If a folder is given twice. |
Source code in src/deeperfly/project.py
rename_view ¶
Rename a view across the manifest, every calibration and the labels.
The name is the join key, so all of them change together and the view order is
kept; a no-op when new == old. In a one-view-per-video layout the video is
renamed with it. Runs keep the names they were written with.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/deeperfly/project.py
set_active_calibration ¶
Make calibration cid the one the GUI labels with.
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
Source code in src/deeperfly/project.py
set_detection_precedence ¶
Name the runs that supply the detections, first wins; empty clears the list.
Raises:
| Type | Description |
|---|---|
ValueError
|
If a run is named twice or has no |
Source code in src/deeperfly/project.py
set_skeleton ¶
Give the project its own skeleton, skeleton.toml, remapping its labels.
Stored verbatim, and the manifest then names it. Points may be reordered or added and edges or symmetries changed freely; a point may be dropped only when no label is on it.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the TOML is not a valid skeleton, or it drops a labeled keypoint. |
Source code in src/deeperfly/project.py
write_manifest ¶
write_manifest(
folder: str | Path,
*,
videos: Mapping[str, str | Sequence[str]],
skeleton: str | Path = "fly38",
skeleton_toml: str | None = None,
animals: int = 1,
layout: Mapping[str, Sequence[str]] | None = None,
mirrored: Sequence[str] = (),
) -> Project
Create a project: write <folder>/deeperfly.toml, atomically.
videos maps each video name to its file patterns, relative to folder or
absolute. skeleton_toml, a custom table's text, takes precedence over
skeleton and is written verbatim to skeleton.toml beside the manifest.
Everything is checked before anything is written.
Raises:
| Type | Description |
|---|---|
FileExistsError
|
If |
ConfigError
|
If the manifest would break a rule. |
FileNotFoundError
|
If |
ValueError
|
If |