|
1 | | -# Xircuits Comprehensive Keras Library |
| 1 | +<p align="center"> |
| 2 | + <a href="https://github.com/XpressAI/xircuits/tree/master/xai_components#xircuits-component-library-list">Component Libraries</a> • |
| 3 | + <a href="https://github.com/XpressAI/xircuits/tree/master/project-templates#xircuits-project-templates-list">Project Templates</a> |
| 4 | + <br> |
| 5 | + <a href="https://xircuits.io/">Docs</a> • |
| 6 | + <a href="https://xircuits.io/docs/Installation">Install</a> • |
| 7 | + <a href="https://xircuits.io/docs/category/tutorials">Tutorials</a> • |
| 8 | + <a href="https://xircuits.io/docs/category/developer-guide">Developer Guides</a> • |
| 9 | + <a href="https://github.com/XpressAI/xircuits/blob/master/CONTRIBUTING.md">Contribute</a> • |
| 10 | + <a href="https://www.xpress.ai/blog/">Blog</a> • |
| 11 | + <a href="https://discord.com/invite/vgEg2ZtxCw">Discord</a> |
| 12 | +</p> |
2 | 13 |
|
3 | | -This comprehensive library for Xircuits encompasses a wide range of functionalities involving Keras datasets, model management, model instantiation, prediction, and transfer learning. It's designed to facilitate various machine learning tasks within the Xircuits visual programming interface. |
4 | 14 |
|
5 | | -### Prerequisites |
6 | 15 |
|
7 | | -- Python 3.8 or higher |
8 | | -- TensorFlow 2.x |
9 | 16 |
|
10 | | -### Installation |
11 | 17 |
|
12 | | -```bash |
13 | | -xircuits install tensorflow_keras |
14 | | -``` |
| 18 | +<p align="center"><i>Xircuits Component Library to interface with TensorFlow Keras! Build and deploy deep learning solutions with ease.</i></p> |
15 | 19 |
|
16 | | -You may also install it manually via |
| 20 | +--- |
| 21 | +## Xircuits Component Library for TensorFlow Keras |
| 22 | + |
| 23 | +Integrates TensorFlow Keras into Xircuits for streamlined deep learning workflows. Simplifies model design, training, and deployment with reusable components. Reduces complexity and accelerates development for scalable AI solutions. |
| 24 | + |
| 25 | +## Table of Contents |
| 26 | + |
| 27 | +- [Preview](#preview) |
| 28 | + |
| 29 | +- [Prerequisites](#prerequisites) |
| 30 | +- [Main Xircuits Components](#main-xircuits-components) |
| 31 | +- [Try The Examples](#try-the-examples) |
| 32 | +- [Installation](#installation) |
| 33 | + |
| 34 | +## Preview |
| 35 | + |
| 36 | +### TFKerasTransferLearning Example |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +### TFKerasTransferLearning Result |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +### TFKerasTrainImageClassifier Example |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +### TFKerasTrainImageClassifier Result |
| 52 | + |
| 53 | +<img src="https://github.com/user-attachments/assets/6fd41596-aa0e-45bd-98e2-34b2baf0b5dd" alt="TFKerasTrainImageClassifier_Result" /> |
| 54 | + |
| 55 | +### TFKerasModelPredict Example |
| 56 | + |
| 57 | + |
17 | 58 |
|
18 | | -```bash |
19 | | -pip install -r requirements.txt |
20 | | -``` |
21 | 59 |
|
22 | | -## Keras Dataset and Model Management |
| 60 | +### TFKerasModelPredict Result |
23 | 61 |
|
24 | | -For tasks from dataset preparation to model training and evaluation. |
| 62 | +<img src="https://github.com/user-attachments/assets/c9b863b4-6b66-42a2-94a3-0c9d027dec9a" alt="TFKerasModelPredict_result" /> |
25 | 63 |
|
26 | | -### Components |
27 | 64 |
|
28 | | -- **`ReadKerasDataSet`**: Loads Keras datasets or creates datasets from directories. Supports MNIST, CIFAR-10/100, and custom datasets. |
29 | | -- **`FlattenImageData`**: Converts 2D dataset tuples to 1D, suitable for 1D neural networks. |
30 | | -- **`TrainTestSplit`**: Splits datasets into training and testing sets with configurable parameters. |
31 | | -- **`KerasCreate1DInputModel`**: Creates 1D Keras models for 1D input datasets. |
32 | | -- **`KerasCreate2DInputModel`**: Assembles 2D Keras models, perfect for image-based datasets. |
33 | | -- **`KerasTrainImageClassifier`**: Trains Keras models for image classification. |
34 | | -- **`KerasEvaluateAccuracy`**: Evaluates Keras models against datasets for accuracy and loss. |
35 | | -- **`ShouldStop`**: Decides if training should stop based on accuracy targets or max retries. |
36 | | -- **`SaveKerasModel`**: Saves Keras models as `.h5` files for later use. |
| 65 | +## Prerequisites |
37 | 66 |
|
38 | | -## Keras Model Instantiation and Prediction |
| 67 | +Before you begin, you will need the following: |
39 | 68 |
|
40 | | -These components support a range of model architectures for image classification. |
| 69 | +1. Python3.9+. |
| 70 | +2. Xircuits. |
41 | 71 |
|
42 | | -### Components |
| 72 | +## Main Xircuits Components |
43 | 73 |
|
44 | | -- **`LoadKerasModel`**: Loads Keras models with customizable configurations. |
45 | | -- **`KerasPredict`**: Performs predictions with Keras models on images. |
46 | | -- **`ResNet50`, `ResNet101`, `ResNet152`**: Instantiates various ResNet models with customizable configurations. |
47 | | -- **`VGG16`, `VGG19`**: Provides VGG model architectures for image classification. |
48 | | -- **`Xception`**: Implements the Xception architecture for image classification. |
49 | | -- **`MobileNet`**: Offers MobileNet architecture with adjustable parameters. |
| 74 | +### KerasCreate1DInputModel: |
| 75 | +Creates 1D Keras models for datasets with 1D input structures. |
50 | 76 |
|
51 | | -## TensorFlow Keras Transfer Learning |
| 77 | +<img src="https://github.com/user-attachments/assets/cf3c5bf4-b2ea-48e3-b964-e3fe2dbffd38" alt="KerasCreate1DInputModel" width="200" height="75" /> |
52 | 78 |
|
53 | | -Designed for easy integration into Xircuits workflows for transfer learning scenarios, suitable for both beginners and experienced ML practitioners. |
54 | 79 |
|
55 | | -### Components |
| 80 | +### KerasCreate2DInputModel: |
| 81 | +Assembles 2D Keras models, ideal for image-based datasets. |
56 | 82 |
|
57 | | -- **`KerasTransferLearningModel`**: Fetches TensorFlow Keras Models for transfer learning. |
58 | | -- **`TFDataset`**: Retrieves datasets from TensorFlow Datasets. |
59 | | -- **`TrainKerasModel`**: Trains compiled Keras models with training data. |
60 | | -- **`TFDSEvaluateAccuracy`**: Evaluates Keras models' accuracy using TensorFlow Datasets. |
61 | | -- **`KerasModelCompiler`**: Compiles TensorFlow Keras models with custom configurations. |
62 | | -- **`SaveKerasModel`**: Saves TensorFlow Keras models for future use. |
| 83 | +<img src="https://github.com/user-attachments/assets/def84826-5549-4de4-90c2-d01eaad9dc36" alt="KerasCreate2DInputModel" width="200" height="75" /> |
| 84 | + |
| 85 | +### KerasTransferLearningModel: |
| 86 | +Fetches TensorFlow Keras Models for transfer learning. |
| 87 | + |
| 88 | +<img src="https://github.com/user-attachments/assets/5b98def2-87fe-4a92-8680-a2a5822210d6" alt="KerasTransferLearningModel" width="200" height="250" /> |
| 89 | + |
| 90 | +### KerasTrainImageClassifier: |
| 91 | +Trains Keras models for image classification tasks. |
| 92 | + |
| 93 | +### KerasEvaluateAccuracy: |
| 94 | +Evaluates Keras models for accuracy and loss using test datasets. |
| 95 | + |
| 96 | +### TrainKerasModel: |
| 97 | +Trains compiled Keras models with training data. |
| 98 | + |
| 99 | +## Try The Examples |
| 100 | + |
| 101 | +We have provided an example workflow to help you get started with the TensorFlow Keras component library. Give it a try and see how you can create custom TensorFlow Keras components for your applications. |
| 102 | + |
| 103 | +### TFKerasTransferLearning |
| 104 | + |
| 105 | +Demonstrates transfer learning with MobileNetV2 pre-trained on ImageNet to classify the "cats_vs_dogs" dataset, evaluate accuracy, and save the model. |
| 106 | + |
| 107 | +### TFKerasTrainImageClassifier |
| 108 | + |
| 109 | +This workflow trains a 2D convolutional model on a dataset, evaluates its accuracy, and demonstrates basic image classification. |
| 110 | + |
| 111 | +### TFKerasModelPredict |
| 112 | + |
| 113 | +Uses the pre-trained ResNet50 model to classify an input image and predict its class label. |
| 114 | + |
| 115 | +## Installation |
| 116 | +To use this component library, ensure that you have an existing [Xircuits setup](https://xircuits.io/docs/main/Installation). You can then install the TensorFlow Keras library using the [component library interface](https://xircuits.io/docs/component-library/installation#installation-using-the-xircuits-library-interface), or through the CLI using: |
| 117 | + |
| 118 | +``` |
| 119 | +xircuits install tensorflow_keras |
| 120 | +``` |
| 121 | +You can also do it manually by cloning and installing it: |
| 122 | +``` |
| 123 | +# base Xircuits directory |
| 124 | +git clone https://github.com/XpressAI/xai-tensorflow-keras xai_components/xai_tensorflow_keras |
| 125 | +pip install -r xai_components/xai_tensorflow_keras/requirements.txt |
| 126 | +``` |
0 commit comments