Spaces:
Sleeping
Sleeping
App Deployer commited on
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,195 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
-
#
|
| 3 |
-
|
| 4 |
-
## Overview
|
| 5 |
-
|
| 6 |
-
This project "Dependable FungAI" implements an **Enhanced Hybrid Concept-Based Mushroom Classification System** using advanced machine learning techniques including **CLIP (ViT-L/14)** for visual feature extraction and **Multi-Layer Perceptron (MLP)** networks. The system classifies mushrooms as either **edible** or **poisonous** based on both visual features and textual concept descriptions. The project generates comprehensive **Training Bill of Materials (TBOM)** and **Inference Bill of Materials (IBOM)** for complete transparency, traceability, and explainability.
|
| 7 |
-
|
| 8 |
-
## Key Features
|
| 9 |
-
|
| 10 |
-
- **Enhanced IBOM Analysis**: Interactive inference with concept categorization by morphological features
|
| 11 |
-
- **TBOM Visualization**: Comprehensive training documentation and performance metrics
|
| 12 |
-
- **Interactive Concept Modification**: Real-time adjustment of concept scores with impact visualization
|
| 13 |
-
- **Educational Mode**: Detailed explanations, safety guidance, and identification tips
|
| 14 |
-
- **DSSE Signature Support**: Supply chain security with in-toto attestation
|
| 15 |
-
- **Export Functionality**: Multiple download formats (JSON, CSV, comprehensive reports)
|
| 16 |
-
- **Advanced Safety Features**: Conflict detection and biological impossibility validation
|
| 17 |
-
|
| 18 |
-
## System Architecture
|
| 19 |
-
|
| 20 |
-
### Training Components (TBOM)
|
| 21 |
-
- **Enhanced Hybrid MLP Classifier** with concept-based learning
|
| 22 |
-
- **CLIP ViT-L/14** backbone for visual feature extraction
|
| 23 |
-
- **117 mushroom-specific concepts** generated from morphological features
|
| 24 |
-
- **Cross-validation** with comprehensive performance tracking
|
| 25 |
-
|
| 26 |
-
### Inference Components (IBOM)
|
| 27 |
-
- **Interactive concept categorization** by morphological features:
|
| 28 |
-
- Cap properties (color, shape, surface)
|
| 29 |
-
- Gill properties (color, spacing, attachment)
|
| 30 |
-
- Stalk properties (shape, color, texture)
|
| 31 |
-
- Sensory properties (odor detection)
|
| 32 |
-
- Environmental context (habitat, growth patterns)
|
| 33 |
-
- Reproductive features (spore characteristics)
|
| 34 |
-
|
| 35 |
-
## Key Terms Defined
|
| 36 |
-
|
| 37 |
-
- **TBOM (Training Bill of Materials)**: Comprehensive documentation of the training process, model architecture, performance metrics, and validation results
|
| 38 |
-
- **IBOM (Inference Bill of Materials)**: Detailed analysis of individual predictions including concept contributions, uncertainty visualization, and safety assessments
|
| 39 |
-
- **DSSE (Dead Simple Signing Envelope)**: Cryptographic signing standard for supply chain security and integrity verification
|
| 40 |
-
- **Concept Categorization**: Organization of mushroom identification features by morphological categories for educational clarity
|
| 41 |
-
- **Uncertainty Visualization**: Interactive charts showing prediction confidence, decision boundaries, and risk assessment
|
| 42 |
-
- **Conflict Detection**: Automated identification of biologically impossible feature combinations
|
| 43 |
-
|
| 44 |
-
## Requirements
|
| 45 |
-
|
| 46 |
-
### Data Set
|
| 47 |
-
|
| 48 |
-
1. For **CSV Dataset**: https://www.kaggle.com/datasets/uciml/mushroom-classification
|
| 49 |
-
2. For **Image Classification:** https://www.kaggle.com/datasets/maysee/mushrooms-classification-common-genuss-images
|
| 50 |
-
3. For **Multi- Modal Approach** (Images dataset):
|
| 51 |
-
git clone: https://www.kaggle.com/datasets/derekkunowilliams/mushrooms
|
| 52 |
-
|
| 53 |
-
This has four folders: Edible, Conditionally Edible, Poisonous, and Deadly Poisonous. Merge Edible and Conditionally Edible into one Edible folder, and Poisonous and Deadly Poisonous into one Poisonous folder, for a binary classification setup.
|
| 54 |
-
|
| 55 |
-
### Core Dependencies
|
| 56 |
-
|
| 57 |
-
pip install streamlit torch clip-by-openai pillow plotly pandas numpy scikit-learn opencv-python
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
### System Requirements
|
| 61 |
-
- Python 3.8+
|
| 62 |
-
- CUDA-compatible GPU (optional, falls back to CPU)
|
| 63 |
-
- 8GB+ RAM recommended for CLIP model loading
|
| 64 |
-
|
| 65 |
-
## Installation & Setup
|
| 66 |
-
|
| 67 |
-
1. **Clone the repository**:
|
| 68 |
-
|
| 69 |
-
git clone https://github.com/umaima786/dependable-fungai.git
|
| 70 |
-
cd dependable-fungai
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
2. **Install dependencies**:
|
| 74 |
-
|
| 75 |
-
pip install -r requirements.txt
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
3. **Set up environment variables** (optional but recommended):
|
| 79 |
-
|
| 80 |
-
export TBOM_PATH="/path/to/TBOM.json"
|
| 81 |
-
export MODEL_PATH="/path/to/final_model.pt"
|
| 82 |
-
export CSV_PATH="/path/to/mushrooms.csv"
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
## Usage Instructions
|
| 86 |
-
|
| 87 |
-
### 1. Training the Model (TBOM Generation)
|
| 88 |
-
|
| 89 |
-
**Run the training script**:
|
| 90 |
-
|
| 91 |
-
python TBOM.py
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
**Interactive prompts will ask for**:
|
| 95 |
-
- Path to mushroom CSV dataset (or press Enter for default)
|
| 96 |
-
- Path to mushroom image dataset (or press Enter for default)
|
| 97 |
-
|
| 98 |
-
**Outputs**:
|
| 99 |
-
- `TBOM.json`: Complete training documentation
|
| 100 |
-
- `final_model.pt`: Trained model weights
|
| 101 |
-
- Comprehensive performance metrics and validation results
|
| 102 |
-
|
| 103 |
-
### 2. Running the Interactive Dashboard
|
| 104 |
-
|
| 105 |
-
**Start the Streamlit application**:
|
| 106 |
-
|
| 107 |
-
streamlit run app.py
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
**Features available**:
|
| 111 |
-
- **TBOM Analysis Tabs**:
|
| 112 |
-
- Data Summary: Dataset statistics and class distribution
|
| 113 |
-
- Overview: Performance metrics and comparison charts
|
| 114 |
-
- Performance: Confusion matrices, ROC/PR curves, training progress
|
| 115 |
-
- Architecture: Model structure and component visualization
|
| 116 |
-
- Concepts: Concept analysis and model interpretation
|
| 117 |
-
- Technical: Environment details and raw TBOM data
|
| 118 |
-
|
| 119 |
-
- **Enhanced IBOM Tab**:
|
| 120 |
-
- Interactive image upload and analysis
|
| 121 |
-
- Real-time concept score modification by category
|
| 122 |
-
- Uncertainty visualization with confidence intervals
|
| 123 |
-
- Educational mode with safety guidance
|
| 124 |
-
- Export functionality for analysis results
|
| 125 |
-
|
| 126 |
-
### 3. Running Inference with IBOM Generation
|
| 127 |
-
|
| 128 |
-
**Command-line inference**:
|
| 129 |
-
|
| 130 |
-
python IBOM.py --image_file mushroom.jpg --dsse --educational_mode
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
**Batch processing**:
|
| 134 |
-
|
| 135 |
-
python IBOM.py --image_dir images/ --output analysis.json --export_summary
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
**Parameters**:
|
| 139 |
-
- `--image_file`: Single mushroom image for analysis
|
| 140 |
-
- `--image_dir`: Directory containing multiple images
|
| 141 |
-
- `--output`: Custom output filename
|
| 142 |
-
- `--dsse`: Include DSSE signature for security
|
| 143 |
-
- `--educational_mode`: Enable detailed explanations
|
| 144 |
-
- `--export_summary`: Generate additional summary report
|
| 145 |
-
|
| 146 |
-
## Safety & Educational Features
|
| 147 |
-
|
| 148 |
-
### Critical Safety Notices
|
| 149 |
-
- **NEVER consume any mushroom based solely on AI analysis**
|
| 150 |
-
- Always consult certified mycologists for positive identification
|
| 151 |
-
- Misidentification can be fatal
|
| 152 |
-
|
| 153 |
-
### Educational Enhancements
|
| 154 |
-
- **Morphological categorization** with biological context
|
| 155 |
-
- **Interactive learning** through concept modification
|
| 156 |
-
- **Conflict detection** for impossible feature combinations
|
| 157 |
-
- **Uncertainty quantification** with confidence interpretation
|
| 158 |
-
- **Safety guidance** with risk assessment
|
| 159 |
-
|
| 160 |
-
## Advanced Features
|
| 161 |
-
|
| 162 |
-
### Security & Traceability
|
| 163 |
-
- **DSSE signatures** for supply chain integrity
|
| 164 |
-
- **Cryptographic hashing** of analysis results
|
| 165 |
-
- **Complete audit trail** from training to inference
|
| 166 |
-
|
| 167 |
-
### Export & Integration
|
| 168 |
-
- **JSON exports** for programmatic access
|
| 169 |
-
- **CSV data** for spreadsheet analysis
|
| 170 |
-
- **Comprehensive reports** for documentation
|
| 171 |
-
- **API-ready format** for system integration
|
| 172 |
-
|
| 173 |
-
## Troubleshooting
|
| 174 |
-
|
| 175 |
-
### Common Issues
|
| 176 |
-
|
| 177 |
-
1. **Model files not found**:
|
| 178 |
-
- Run `python TBOM.py` first to generate required files
|
| 179 |
-
- Set environment variables for custom paths
|
| 180 |
-
|
| 181 |
-
2. **Memory errors**:
|
| 182 |
-
- Reduce batch size in training
|
| 183 |
-
- Use CPU instead of GPU if VRAM insufficient
|
| 184 |
-
|
| 185 |
-
3. **Interactive prompts in production**:
|
| 186 |
-
- Set all environment variables to avoid prompts
|
| 187 |
-
- Use `--no_interactive` flag for automated deployment
|
| 188 |
-
|
| 189 |
-
### Getting Help
|
| 190 |
-
|
| 191 |
-
- Check the **Technical Details** tab in the dashboard for system information
|
| 192 |
-
- Enable **detailed error display** in the IBOM interface for debugging
|
| 193 |
-
- Consult the **Educational Mode** for feature explanations
|
| 194 |
-
|
| 195 |
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Fungi Classifier
|
| 3 |
+
emoji: 🍄
|
| 4 |
+
colorFrom: green
|
| 5 |
+
sdk: streamlit
|
| 6 |
+
app_file: app.py
|
| 7 |
+
---
|
| 8 |
|
| 9 |
+
# Fungi Classifier Application
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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