Lightning Flash 0.3 Introduces New Tasks, Visualization Tools, Data Pipelines, and Registry API
Lightning Flash 0.3 expands the PyTorch Lightning ecosystem with eight new computer‑vision and NLP tasks, modular API design, integrated model hubs, visualisation callbacks, customizable data‑source hooks, and a central registry for model backbones, all illustrated with concrete code examples.
Lightning Flash is a library built on PyTorch Lightning that provides baseline models and experimental pipelines for deep‑learning tasks. Version 0.3 focuses on a modular API design and adds eight new tasks spanning computer vision and natural‑language processing.
The new computer‑vision tasks include multi‑label image classification, object detection, video classification, semantic segmentation, style transfer, and image embedding. Each task is demonstrated with code snippets that show how to instantiate the corresponding Flash class (e.g., ImageClassifier, ObjectDetector, VideoClassifier, SemanticSegmentation, ImageEmbedder) and fine‑tune a pretrained backbone such as a ResNet, RetinaNet, or FCN model.
For NLP, Flash now offers summarisation (condensing long documents into short sentences) and translation (converting text from one language to another, e.g., English to Romanian), again using ready‑made models accessed through the same task‑based API.
Version 0.3 also integrates several model hubs—Hugging Face, TIMM, and PyTorch Video—so that thousands of state‑of‑the‑art models can be trained, fine‑tuned, or used for inference out of the box.
A new visualisation callback lets users inspect how data transformations affect inputs before training. Custom visualisations can be added by subclassing BaseVisualization and overriding any show_{preprocess_hook_name} method.
The task API is extensible: developers can create reusable, modular data‑processing pipelines without boilerplate code. The pipeline consists of four main routines—train, validate, test, and predict—each driven by hook methods that can be overridden. The DataSource hook provides load_data (returning a list or iterator of samples) and load_sample (loading an individual sample into a dictionary).
Preprocess objects encapsulate all data‑processing logic before the model receives inputs. They map hook names to callable transforms (e.g., Kornia batch transforms) and inject a series of transforms ( pre_tensor_transform, to_tensor_transform, post_tensor_transform, collate, per_batch_transform) directly into the PyTorch DataLoader collate function, allowing parallel execution when num_workers > 0. Device‑side transforms ( per_sample_transform_on_device, collate, per_batch_transform_on_device) run after data is moved to GPU/TPU.
Postprocess mirrors Preprocess for the inference side, providing hooks that convert model outputs into final predictions. For example, in semantic segmentation the original image shape is stored as metadata, and the post‑process step rescales the segmentation map back to that size.
Prediction serialization is handled by a Flash Serializer, which can be overridden to output predictions in custom formats such as probability vectors.
Finally, the Flash Registry acts as an internal key‑value store for model backbones, enabling tasks to register and retrieve models (e.g., registering all TIMM backbones in TIMM_BACKBONES_REGISTRY). Documentation links are provided for deeper exploration of these features.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Code DAO
We deliver AI algorithm tutorials and the latest news, curated by a team of researchers from Peking University, Shanghai Jiao Tong University, Central South University, and leading AI companies such as Huawei, Kuaishou, and SenseTime. Join us in the AI alchemy—making life better!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
