Upload README.md
Browse files
README.md
CHANGED
|
@@ -1,105 +1,106 @@
|
|
| 1 |
-
# π§ KKT-HF-TransferLearning-Models
|
| 2 |
-
### Transfer Learning Models Collection for Image Classification
|
| 3 |
-
Created by **Thyagharajan K K**
|
| 4 |
-
|
| 5 |
-
---
|
| 6 |
-
|
| 7 |
-
## π Repository Structure
|
| 8 |
-
```
|
| 9 |
-
|
| 10 |
-
KKT-HF-TransferLearning-Models/ β Root directory (your HF repo root)
|
| 11 |
-
β
|
| 12 |
-
βββ Insect_Inception_V3/ β Model 1 directory
|
| 13 |
-
β βββ insect_inception_v3_model.keras β Saved model file
|
| 14 |
-
β βββ class_names.txt β Corresponding class labels
|
| 15 |
-
β βββ InsectTest/ β Test image folder
|
| 16 |
-
β βββ image_001.jpg
|
| 17 |
-
β βββ image_002.jpg
|
| 18 |
-
β βββ ...
|
| 19 |
-
β
|
| 20 |
-
βββ
|
| 21 |
-
β βββ
|
| 22 |
-
β βββ class_names.txt
|
| 23 |
-
β βββ InsectTest/
|
| 24 |
-
β βββ test1.jpg
|
| 25 |
-
β βββ test2.jpg
|
| 26 |
-
β βββ ...
|
| 27 |
-
β
|
| 28 |
-
βββ Insect_ResNet50/
|
| 29 |
-
β βββ insect_resnet50_model.keras
|
| 30 |
-
β βββ class_names.txt
|
| 31 |
-
β βββ InsectTest/
|
| 32 |
-
β βββ imgA.jpg
|
| 33 |
-
β βββ imgB.jpg
|
| 34 |
-
β βββ ...
|
| 35 |
-
β
|
| 36 |
-
βββ README.md β (optional, highly recommended)
|
| 37 |
-
|
| 38 |
-
```
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
- A `
|
| 42 |
-
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 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 |
-
The local
|
| 96 |
-
The
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
| 1 |
+
# π§ KKT-HF-TransferLearning-Models
|
| 2 |
+
### Transfer Learning Models Collection for Image Classification
|
| 3 |
+
Created by **Thyagharajan K K**
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## π Repository Structure
|
| 8 |
+
```
|
| 9 |
+
|
| 10 |
+
KKT-HF-TransferLearning-Models/ β Root directory (your HF repo root)
|
| 11 |
+
β
|
| 12 |
+
βββ Insect_Inception_V3/ β Model 1 directory
|
| 13 |
+
β βββ insect_inception_v3_model.keras β Saved model file
|
| 14 |
+
β βββ class_names.txt β Corresponding class labels
|
| 15 |
+
β βββ InsectTest/ β Test image folder
|
| 16 |
+
β βββ image_001.jpg
|
| 17 |
+
β βββ image_002.jpg
|
| 18 |
+
β βββ ...
|
| 19 |
+
β
|
| 20 |
+
βββ Insect_MobileNetV2/ β Model 2 directory (example)
|
| 21 |
+
β βββ insect_mobilenet_v2_model.keras
|
| 22 |
+
β βββ class_names.txt
|
| 23 |
+
β βββ InsectTest/
|
| 24 |
+
β βββ test1.jpg
|
| 25 |
+
β βββ test2.jpg
|
| 26 |
+
β βββ ...
|
| 27 |
+
β
|
| 28 |
+
βββ Insect_ResNet50/
|
| 29 |
+
β βββ insect_resnet50_model.keras
|
| 30 |
+
β βββ class_names.txt
|
| 31 |
+
β βββ InsectTest/
|
| 32 |
+
β βββ imgA.jpg
|
| 33 |
+
β βββ imgB.jpg
|
| 34 |
+
β βββ ...
|
| 35 |
+
β
|
| 36 |
+
βββ README.md β (optional, highly recommended)
|
| 37 |
+
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
Each subfolder contains:
|
| 41 |
+
- A `.keras` TensorFlow model
|
| 42 |
+
- A `class_names.txt` file listing class labels
|
| 43 |
+
- An `Test/` folder with example test images
|
| 44 |
+
|
| 45 |
+
---
|
| 46 |
+
|
| 47 |
+
## βοΈ Programmatic Usage
|
| 48 |
+
|
| 49 |
+
You can load any model from this repository directly in Python using the helper functions in **`KKT_DL_Package`**.
|
| 50 |
+
|
| 51 |
+
### π§© Example Code
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
# -*- coding: utf-8 -*-
|
| 55 |
+
"""
|
| 56 |
+
Created on Sat Nov 8 14:07:38 2025
|
| 57 |
+
@author: Thyagharajan
|
| 58 |
+
|
| 59 |
+
Example: Using a Hugging Face model programmatically
|
| 60 |
+
"""
|
| 61 |
+
|
| 62 |
+
from KKT_DL_Package.utils.KKT_predictions import (
|
| 63 |
+
multiclass_prediction_return,
|
| 64 |
+
display_images_gui,
|
| 65 |
+
get_hf_model_img_labels_local_path
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
# Define image input size (must match the model's input)
|
| 69 |
+
IMG_SIZE = (300, 300)
|
| 70 |
+
|
| 71 |
+
# Load model, class labels, and test images from Hugging Face
|
| 72 |
+
model_full_path, test_folder_path, class_names = get_hf_model_img_labels_local_path(
|
| 73 |
+
"kkthyagharajan/KKT-HF-TransferLearning-Models",
|
| 74 |
+
IMG_SIZE,
|
| 75 |
+
force_refresh=False # Set True to force re-download
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
# Run predictions
|
| 79 |
+
all_image_paths, all_predicted_labels, all_confidences = multiclass_prediction_return(
|
| 80 |
+
model_full_path, test_folder_path, class_names, IMG_SIZE
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
# Display results in a simple GUI window
|
| 84 |
+
display_images_gui(all_image_paths, all_predicted_labels, IMG_SIZE)
|
| 85 |
+
|
| 86 |
+
π§ About the Helper Function
|
| 87 |
+
get_hf_model_img_labels_local_path(repoid, img_size, force_refresh=False)
|
| 88 |
+
|
| 89 |
+
This function:
|
| 90 |
+
|
| 91 |
+
Downloads (or reuses cached) model and class label files from Hugging Face
|
| 92 |
+
Loads test images from the repo
|
| 93 |
+
|
| 94 |
+
Returns:
|
| 95 |
+
The full local path to the model file
|
| 96 |
+
The local test folder path
|
| 97 |
+
The list of class names
|
| 98 |
+
|
| 99 |
+
Parameters
|
| 100 |
+
Argument Description
|
| 101 |
+
repoid Hugging Face repo ID (e.g. "kkthyagharajan/KKT-HF-TransferLearning-Models")
|
| 102 |
+
img_size Tuple, e.g. (300, 300) matching model input
|
| 103 |
+
force_refresh If True, forces re-download even if cached locally
|
| 104 |
+
|
| 105 |
+
Returns:
|
| 106 |
+
`model_full_path, test_folder_path, class_names`
|