The manifest distinguishes paper/a.png from screen/a.png. Default class order maps paper to zero and screen to one; the explicit reverse maps paper to one and screen to zero. The local inspector recomputes each path’s expected label and batch-count expectation without pretending to load Keras tensors.

Work through the example
Select Reverse classes to see screen index zero and paper index one. Each of the four full relative paths is remapped independently; the page does not assume a native loader preserves the old batch order. Set batch size to three and Inspect expectations: four images imply two batches, with sizes three and one. Actual paths, arrays and dtypes must still be checked after the native loader runs.
Bind every label to its full path and actual batch position before interpreting the label list. The same basename can refer to different files. Class-order changes need a new path-to-index audit; the browser manifest does not establish the loader’s reordered iteration. After creating the four PNGs, check decoded color identity, channels-last shape and integer dtype in the confirmed native environment.
Prepare an unambiguous directory manifest
Create this four-file layout under your dataset root:
fixture-images/
paper/
a.png
b.png
screen/
a.png
b.png
Use opaque 8 × 8 RGB PNGs for all four images:
| Root-relative path | Original color fixture | RGB channels | Actual resolved full path / hash |
|---|---|---|---|
| paper/a.png | Red | (255, 0, 0) | |
| paper/b.png | Green | (0, 255, 0) | |
| screen/a.png | Blue | (0, 0, 255) | |
| screen/b.png | Yellow | (255, 255, 0) |
The colors are authored identity aids, not examples of real paper or screens. The folder names are class labels for the loader exercise. They do not describe the semantic content of a solid-color tile.
Keep root-relative paths and actual resolved full paths as separate fields. paper/a.png and screen/a.png are different records even though their basenames match. Do not invent image hashes until bytes exist.
Before loading, verify the exact four-file inventory and file format/dimensions. If a fixture is missing or corrupt, repair that file before loading; do not substitute another a.png or a generated black image.
Declare the loader configuration
Keras documents inferred folder labels, configurable class order, image sizing/color mode, and integer-label batches. This packet uses those facts with an original directory and checks. Keras image loading API.
Load the fixture with:
import keras
dataset = keras.utils.image_dataset_from_directory(
fixture_root,
labels="inferred",
label_mode="int",
color_mode="rgb",
shuffle=False,
batch_size=2,
image_size=(8, 8),
format="tf",
)
The expected shape below assumes confirmed channels_last configuration. If the native environment differs, do not keep the old expectation without reviewing the configuration and actual output.
The selected tf format requires TensorFlow. This design does not assume that another installed backend or an imported keras name establishes that dependency or executes the call.
There is no validation split, shuffle, training, prediction, or augmentation in this packet. Keep the small loading test focused on data correspondence.
Inspect default class order and two full batches
For the authored default case, expect:
| Class name | Expected inferred index |
|---|---|
| paper | 0 |
| screen | 1 |
Under the fixture's default ordered paths, the intended sequence is paper/a.png, paper/b.png, screen/a.png, screen/b.png. With four images and batch size two, expect two full batches.
Each image batch has expected shape (2, 8, 8, 3): two images, height eight, width eight, three channels. Each integer-label batch has expected shape (2,) and dtype int32.
| Default-case batch | Intended path identities | Expected labels |
|---|---|---|
| 1 | paper/a.png, paper/b.png | [0, 0] |
| 2 | screen/a.png, screen/b.png | [1, 1] |
Recreate this example
Build one self-contained responsive HTML example titled “Loading images in Python: audit each path and label” for readers completing the stated task. Return the complete HTML with embedded CSS and JavaScript. Use no remote fonts, libraries, images, requests, account connections, or saved-state claims.
Use four opaque 8 × 8 RGB PNG fixtures: paper/a.png red (255,0,0), paper/b.png green (0,255,0), screen/a.png blue (0,0,255), screen/b.png yellow (255,255,0). Default class order is paper, screen, with indices 0,1; Reverse classes uses screen, paper, with indices 0,1. Remap each full path without assuming the old native iteration order. Batch size accepts integers 1–4. Inspect expectations computes ceil(4/batch) and the final batch size. Reject missing or invalid sizes. The copyable Keras call must reflect the selected batch_size and explicit class_names order, with labels="inferred", label_mode="int", color_mode="rgb", shuffle=False, image_size=(8,8), format="tf". Retire the manifest and call on batch edits until inspection. Keep native tensors and batch order unobserved.
Use a dataset manifest inspector with full paths, class indices and configuration-specific expectations design with a compact header. Keep the actual sample data, controls, and useful default result visible early on a 360px-wide screen. Use readable text at least 16px, generous paragraph spacing, strong contrast, semantic labels, visible keyboard focus, and wrapping source blocks. Stack records on narrow screens rather than forcing a wide table.
Wire each action to an explicit type=button click handler using element selectors; the host permits scripts but blocks form submission. Update the visible result when the described action occurs. Show specific error feedback for invalid or missing input and clear stale feedback after dependent inputs change. Use plain text when displaying user values.
This manifest inspector does not create PNGs, run Keras/TensorFlow or establish native batch order. Keep the source fixture and worked teacher or developer example distinct from actual user records. Include the domain-specific explanation and next check beside the result. Provide no fake download, send, deployment, approval, or persistence button. Everything operates locally for the current page session.
Review the prepared copy in NOS
Run the native loader before training and retain its actual path-bound observations. If an HTML manifest aids review, NOS can display it; eligible static class-mapping notes can be changed visually. Treat the real PNG bytes and observed tensors as the evidence for the loading check.