gui¶
The FastAPI app behind deeperfly gui: the browser workspace's server half.
A thin shell over deeperfly.project: the launcher (/) opens a project or a
collection of them (ADR-0081), or sets one up over a directory of videos
(deeperfly.gui.setup), and the tabbed workspace (/workspace) edits the
skeleton, lists the projects, calibrates and labels. The workspace names what it
opened by the paths it was given, repeatable directory= parameters, and every
per-project route names its project by its folder. The front end computes no
geometry (ADR-0022). build_app serves serve and the
TestClient tests.
RenameViewIn ¶
SetSkeletonIn ¶
Bases: BaseModel
Give every project of a collection this custom skeleton TOML.
directory is the collection's paths, as the workspace was opened with.
Source code in src/deeperfly/gui/app.py
SkeletonTomlIn ¶
build_app ¶
Build the GUI's FastAPI app (routes and static files), no server attached.
on_quit asks the host to stop, so the Quit button can end the process; without
one (the tests) POST /api/quit closes the sessions and says nothing stopped.
Source code in src/deeperfly/gui/app.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 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 229 230 231 232 233 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 | |
open_collection ¶
The collection some paths stand for, a 404 naming what is wrong otherwise.
Source code in src/deeperfly/gui/app.py
project_state ¶
One project as the workspace reads it: its views, videos and progress.
name is the project's name in its collection. The labeled-frame counts come
from the stored columns alone (n_complete counts the frames ADR-0102 calls
complete), so they stay cheap on every read; a video that cannot be found is
listed empty, with the reason in error. unsaved says the labels come from the
recovery sidecar, i.e. edits not yet saved to labels.h5.
Source code in src/deeperfly/gui/app.py
The labeling half of the GUI: multi-view frame annotation over one project.
The workspace follows Lightning Pose 3D's (ADR-0021): a canvas per source video with
every view that reads it drawn on it, and the aid that triangulates two labeled views
and reprojects into the others (an epipolar line when one is labeled). An
EditorSession per project folder holds the mutable state (ADR-0023): open
readers, the labels in memory, the rig, and an undo stack, each edit also written to
the crash-recovery sidecar; /save flushes to labels.h5 and /discard drops the
sidecar and reloads. Every route names its project by its folder, project=<folder>
(ADR-0081), and every one but /frame and the two suggest routes runs under the
session store's lock (ADR-0090, ADR-0111).
HELD_PROJECTS
module-attribute
¶
How many projects keep their videos' decoders open between frame reads (ADR-0092).
A held decoder costs 90-230 MB per video, and a session lives until the GUI quits, so only the projects whose frames were read last keep theirs; the others reopen on demand.
READ_CHUNK
module-attribute
¶
How many frames of a run the suggest scoring reads per hold of its lock (ADR-0111).
A frame step's /points waits on the detections' lock for as long as a read holds it,
and reading a sparse run of ten thousand frames takes a second; a chunk of this many
takes about 25 ms.
STAMPED_FILES
module-attribute
¶
A video of at most this many files is checked for replacement on every read.
An image sequence has a file per frame, and statting them all would cost more than the decode.
SUGGEST_METHODS
module-attribute
¶
What /suggest and /suggest/all compute from.
UNDO_DEPTH
module-attribute
¶
How many edits back one session's undo stack reaches.
AbsentIn ¶
Bases: BaseModel
Declare a keypoint absent (or present), in one frame or in every frame.
Source code in src/deeperfly/gui/labeling.py
CellEdit ¶
Bases: BaseModel
One cell's edit in a /cells batch: place, clear, exclude or include it.
instance is the animal the cell belongs to, where a batch reaches several; a
cell without one is the batch's.
Source code in src/deeperfly/gui/labeling.py
CellsIn ¶
Bases: BaseModel
Edit cells of a frame, each in its own view, as one undoable step.
Source code in src/deeperfly/gui/labeling.py
EditorSession
dataclass
¶
Open project, readers, labels and geometry for one project being labeled.
Held across requests so a scrub reopens no video; built lazily by
sessions and closed on eviction.
skeleton is the project's, read once: a skeleton edit evicts the session.
detections are the project's runs merged per frame (ADR-0083), which every
request revalidates, so a run written or swapped since is read without a reopen.
Source code in src/deeperfly/gui/labeling.py
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 229 230 231 232 233 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 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | |
fps
property
¶
The frame rate the first video declares, None for an image sequence.
Probed once through a reader of its own, so the display readers keep their place.
frame_sizes
property
¶
Per view, the (height, width) of the video it reads, probed once.
Never through the display readers: reading frame 0 would pull their decoders away from the frames on screen.
rig_error
property
¶
Why the project's active calibration gives no rig, when it names one.
runs_error
property
¶
Why the detections are missing where a run should serve them, if they are.
sources
property
¶
The videos the views read, each with the views that read it, in view order.
The editor draws a panel per video, so shared pixels are decoded, sent and held once.
__post_init__ ¶
Recovered labels have no saved step to come back to.
Source code in src/deeperfly/gui/labeling.py
autosave ¶
Bring the crash-recovery sidecar up to date, after each edit.
Unsaved labels are flushed to it and stay dirty, since labels.h5 is still
behind; /save clears it. Labels back at the saved step have nothing to
recover, so the sidecar goes and a reopen finds none (ADR-0110). A write or a
removal that fails keeps the edit in memory and sets autosave_error instead
of failing the request: the operator can still save by hand.
Source code in src/deeperfly/gui/labeling.py
bone_reference ¶
The project's (median, mad, count) bone lengths, cached.
bone_reference, recomputed when the geometry, the detections or the labels behind it change.
Source code in src/deeperfly/gui/labeling.py
close ¶
Close every open reader (labels are the caller's to save first).
A frame read in flight finishes first; one that starts later raises SessionClosed.
Source code in src/deeperfly/gui/labeling.py
detected ¶
detected_frame over this session.
The slot whose detections the instance's clicks sit on (ADR-0128); (None,
None) where no run covers the frame, for an instance no slot is, and when the
winner's read failed, which runs_error then says.
Source code in src/deeperfly/gui/labeling.py
discard_unsaved ¶
Set every edit since the last save aside, and the undo history with them.
They are kept for /restore-discarded (ADR-0120); the undo stack is not.
Source code in src/deeperfly/gui/labeling.py
frame ¶
One uint8 display frame: video source at index, whole.
(H, W) for footage that carries no color, else (H, W, 3). Every view of the
video is drawn on it, in its own pixels, where its labels and calibration are
(ADR-0053); nothing is flipped.
Raises:
| Type | Description |
|---|---|
SessionClosed
|
If the session closed before or during the read. |
Source code in src/deeperfly/gui/labeling.py
holds ¶
Whether anything in frame places this animal, so a skeleton is drawn.
A labeled pixel, a detection that passes min_conf (detected is what
detected answered for the frame), or the operator's drop-in (/seed).
Absent and hidden marks place nothing (ADR-0091).
Source code in src/deeperfly/gui/labeling.py
mark_saved ¶
Note that labels.h5 holds the labels as they are now, undo history kept.
point_name ¶
record ¶
record(
label: str,
frame: int | None,
snapshot: Callable[[], Callable[[], None]],
restore: Callable[[], None],
) -> None
Push one edit onto the undo stack, oldest dropped past the cap.
Called after a route's mutation succeeded, with the snapshot of the slice it
touches and the restore taken just before; a new edit empties the redo stack
and leaves the labels unsaved, whatever they held.
Source code in src/deeperfly/gui/labeling.py
redo ¶
refresh_geometry ¶
Adopt a freshly opened project and drop the cached rig.
For a changed active calibration or run precedence; the labels and readers are kept, and the detections recompute their winners under the new manifest.
Source code in src/deeperfly/gui/labeling.py
release_readers ¶
Let go of every display reader's decoder; each reopens on its next read.
Source code in src/deeperfly/gui/labeling.py
rig ¶
The active calibration applied to the project's views, None without one.
Also None when the active calibration is missing or disagrees with the
manifest, which rig_error then says; the Calibration panel repairs it. The
frame sizes are the session's own readers', so no video is probed again. The
first time a rig resolves, a thread starts compiling the kernels its shapes
need (_warm_up, ADR-0111).
Source code in src/deeperfly/gui/labeling.py
undo ¶
Reverse the most recent recorded edit, or None if there is none.
The labels are clean again once it returns to the saved step, and dirty
otherwise: an undo writes the sidecar and not labels.h5.
Source code in src/deeperfly/gui/labeling.py
unsaved_frames ¶
The frames whose labels differ from labels.h5's, sorted (ADR-0120).
Empty at the saved step. Away from it, an edit and its inverse edit leave the labels unsaved (ADR-0110) with no frame to show for it.
Source code in src/deeperfly/gui/labeling.py
view_precision ¶
Each view's measured precision over the project's detections, cached.
detection_precision, which the
solves weigh their fits by (ADR-0129); recomputed when the geometry or the
detections change, None without either.
Source code in src/deeperfly/gui/labeling.py
FrameRef ¶
HiddenIn ¶
Bases: BaseModel
Set or clear the hidden (exclude-from-loss) flag of one cell.
Source code in src/deeperfly/gui/labeling.py
InstanceIn ¶
Bases: ProjectRef
Add or remove one animal's instance in one frame (animals > 1 only).
Source code in src/deeperfly/gui/labeling.py
OverrideIn ¶
PointIn ¶
Bases: BaseModel
Set (xy given) or clear (xy null) one (view, keypoint) cell of a frame.
Source code in src/deeperfly/gui/labeling.py
ProjectRef ¶
ProjectsRef ¶
ReprojectIn ¶
Bases: BaseModel
A request to solve one keypoint of one frame and reproject it.
override stands a cursor pixel in for one view's label, so a drag in progress
previews where it puts the keypoint in every other view; it authors nothing.
Source code in src/deeperfly/gui/labeling.py
SessionClosed ¶
SessionRouter ¶
Bases: APIRouter
An APIRouter whose every route runs under its session store's lock.
Where requests are serialized (ADR-0090): a route added here, by decorator or by
add_api_route, holds the lock for its whole body, on the worker thread FastAPI
runs it on. Only a sync route can be added, so the lock never spans an await.
Source code in src/deeperfly/gui/labeling.py
__init__ ¶
add_api_route ¶
Add a route whose endpoint holds the store's lock while it runs.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in src/deeperfly/gui/labeling.py
SessionStore ¶
A registry of live EditorSessions, keyed by the resolved project folder.
lock serializes the requests that read or change a session (ADR-0090): FastAPI
runs the routes in its thread pool, and neither a session nor its labels are
thread-safe. A SessionRouter route holds it
for its whole body, and the store's own methods take it, so a session is opened,
refreshed or evicted between two requests, never during one. The suggest routes
hold it only to snapshot what they score and to write the answer (ADR-0111).
Source code in src/deeperfly/gui/labeling.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 | |
__init__ ¶
An empty store; sessions open lazily on first request.
Source code in src/deeperfly/gui/labeling.py
close_all ¶
Close every live session's readers (labels are not auto-saved).
evict ¶
Close a project's session after its skeleton or views were rewritten.
Its edits are in the recovery sidecar, which the edit rewrote too, so the next request reopens the session from it.
Source code in src/deeperfly/gui/labeling.py
folders ¶
get ¶
The session for a project, opening its labels and recording on first use.
Only the opening takes lock, so /frame, which runs without it, waits for
nothing but the opening of its own project.
Source code in src/deeperfly/gui/labeling.py
live ¶
refresh_geometry ¶
Re-resolve a live session's geometry after its calibration changed.
The manifest is read under lock, so a refresh that waited on it never
installs one older than a write that landed meanwhile.
Source code in src/deeperfly/gui/labeling.py
showing ¶
Note that session's frames are being read; release all but the latest.
Only the last HELD_PROJECTS sessions to serve a frame keep their decoders.
Source code in src/deeperfly/gui/labeling.py
SuggestAllIn ¶
Bases: SuggestParams
A request to compute the suggestions of every project of a collection.
Source code in src/deeperfly/gui/labeling.py
SuggestIn ¶
Bases: SuggestParams
A request to compute one project's suggestions and write suggestions.json.
Source code in src/deeperfly/gui/labeling.py
SuggestParams ¶
Bases: BaseModel
How to compute suggestions: the method and the controls it reads.
method="merged" scores the project's merged detections (ADR-0083), "run" one
run's 2D (run as /runs lists it), and "sample" spreads whole frames over
the unlabeled part and reads count only. gap is the frames between two
suggested frames, min_score the typical residuals a joint must be off by, and
per_frame the joints a frame lists at most (ADR-0073).
Source code in src/deeperfly/gui/labeling.py
UndoStep
dataclass
¶
One reversible edit: what it was, where it happened, and how to put it back.
id is the edit's own, never reused, and follows it from the undo stack to the
redo stack and back, so the step on top of the undo stack names a state of the
labels (ADR-0110). frame is where the editor should look to see the undo, None
for an edit that spans every frame. snapshot reads the slice the edit touches and
returns the closure that writes it back, so one record serves undo and redo alike.
Source code in src/deeperfly/gui/labeling.py
build_labeling_router ¶
The labeling routes, bound to a session store.
Every route is a SessionRouter's but
/frame, which only decodes video: outside the lock, a scrub's frames decode in
parallel and none waits behind a solve. The two suggest routes score outside it as
well, from a snapshot taken under it (ADR-0111), so a frame step or an edit made
while they score is served at once.
Source code in src/deeperfly/gui/labeling.py
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 | |
open_project ¶
The project in folder, a 404 naming what is wrong when there is none.
Source code in src/deeperfly/gui/labeling.py
run_summary ¶
One run as the panels list it (JSON-friendly).
written is the run's write time in unix seconds and written_at the same as
a local ISO stamp; stretches are the [start, stop) ranges its pose2d
covers; pose3d lists the 3D stages it holds, most refined first. A run that
cannot be a source of detections has usable false and says why.
Source code in src/deeperfly/gui/labeling.py
The Runs panel: a project's runs, where its detections come from (ADR-0084).
Each run is results/<name>.h5 beside the config it was run with (ADR-0082). The
panel lists every run with its coverage, write time and stretches, the config and
calibration text the file stores, and how many frames it wins in the merged
detections (ADR-0083); it saves a precedence override to the manifest, marks the
winners' track flags on the frame slider, draws a run's final 3D reprojected
through that run's own calibration, and imports that calibration into the project.
Runs are read-only apart from swap, which exchanges two animals of a run in place
and drops the stages computed from the old assignment. Every route names its
project by its folder, project=<folder>, as the labeling routes do.
PrecedenceIn ¶
RunRef ¶
SwapIn ¶
build_runs_router ¶
The Runs panel's routes, bound to the sessions' store, under its lock.
Source code in src/deeperfly/gui/runs.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 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 229 230 231 232 233 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 | |
Launch the GUI on a local port (deeperfly gui).
uvicorn is imported only when serve runs, bound to localhost (reach a headless host
with ssh -L), and run through uvicorn.Server so /api/quit can trip its exit flag.
The server process also keeps the kernels JAX compiles across runs (ADR-0111), and
is the user's only one: a second launch opens a tab on it (ADR-0123).
compilation_cache_dir ¶
Where the GUI server keeps the kernels JAX compiled.
jax/<version> in deeperfly's cache (cache_dir). A
JAX of another version starts an empty directory, so an empty one means the
kernels are not compiled yet (ADR-0111), and an old one can be deleted.
Source code in src/deeperfly/gui/server.py
enable_compilation_cache ¶
Keep the kernels JAX compiles in compilation_cache_dir(), for the next run.
A fresh server compiles a second and a half of them at a project's first frame;
a run that finds them cached skips it (ADR-0111). Only the GUI server does this,
so import deeperfly, build_app and the tests leave the user's cache alone. A
directory that cannot be made, or a home that cannot be found, only costs the
compiles it would have saved.
Source code in src/deeperfly/gui/server.py
serve ¶
serve(
host: str = "127.0.0.1",
port: int | None = None,
*,
open_browser: bool = True,
paths: Sequence[str | Path] = (),
) -> None
Run the GUI server until quit, the browser opening on start_page(paths).
A server of this user already running here gets the page instead, as a new tab,
and this returns at once (ADR-0123). port None is 8000 or the next free port.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If a server is up but does not answer. |
OSError
|
If no port could be bound. |
Source code in src/deeperfly/gui/server.py
start_page ¶
The page deeperfly gui PATH ... opens, as a path and query (ADR-0081).
No path is the launcher; one directory of videos without a project is the launcher's setup form over it, as the launcher offers it: video files, or folders of stills the form proposes as videos; paths that stand for projects, each a project or a directory of them, open the workspace on their collection.
Raises:
| Type | Description |
|---|---|
ValueError
|
If a path stands for no project and is not that directory. |
Source code in src/deeperfly/gui/server.py
The setup form's routes: make a project folder over some videos (ADR-0081).
The form replaces "create a project" and "add a recording" with one step: the
folder (<videos>/deeperfly by default), which videos it works on (grouped from a
directory, or typed as file patterns), which views each video carries and which are
mirrored, the skeleton (a preset or custom TOML) and the animal count. It writes the
folder's deeperfly.toml, and skeleton.toml for custom TOML, and never overwrites
either; a manifest whose videos do not open, or disagree on their frame count, is
taken back before the form answers.
SetupIn ¶
Bases: BaseModel
A project to create: the manifest's facts, as the setup form collects them.
videos maps each video name to its file patterns, each absolute or relative to
directory, the directory the form grouped them from, or to folder without
one. layout names the views each video carries; a video it leaves out, or
that carries one view of its own name, is one view per video. skeleton_toml,
custom TOML, takes precedence over the preset skeleton.
Source code in src/deeperfly/gui/setup.py
build_setup_router ¶
The /api/setup router: the form's defaults and the create step.
Source code in src/deeperfly/gui/setup.py
free_folder ¶
The default project folder for a directory's videos, holding no manifest yet.
deeperfly, else the first of deeperfly_2, deeperfly_3, ... that is free.
Source code in src/deeperfly/gui/setup.py
group_videos ¶
The videos a directory holds, as the form proposes them, in name order.
A video file is one video named by its stem; a subdirectory of stills of one file
type is one video named by the subdirectory, <sub>/*<ext>. The patterns are
relative to directory and glob-escaped; a second video of a name gets a
numbered one.
Source code in src/deeperfly/gui/setup.py
manifest_patterns ¶
File patterns as the manifest keeps them, relative to its folder when near.
A relative pattern is taken against directory when given, else it already is
the folder's. A pattern under the folder's parent is written relative to the
folder (a.mp4 from /data/rec for /data/rec/deeperfly is ../a.mp4), so
the project moves with its videos; any other is absolute.