Spaces:
Sleeping
A newer version of the Gradio SDK is available: 6.20.0
title: QuantumHarvest Cotton Defoliation Intelligence
emoji: πΏ
colorFrom: purple
colorTo: blue
sdk: gradio
sdk_version: 5.22.0
app_file: app.py
pinned: false
πΏ QuantumHarvest: Cotton Defoliation Intelligence
QuantumHarvest is a Hybrid Quantum-Classical Machine Learning application designed to evaluate the defoliation readiness of cotton fields using UAV (drone) RGB imagery.
By utilizing advanced quantum variational circuits (VQC) and computer vision, this tool accurately classifies fields into Pre-Defoliation or Post-Defoliation stages, alongside a robust algorithm to physically count visible cotton bolls.
For full research details, data access, and codebase, please visit the main project repository: harshitha-8/SPIE.
β¨ Key Features
Hybrid Classification Engine
- Extracts 12 spectral and textural (GLCM) features classically.
- Leverages a Qiskit
ZZFeatureMapandRealAmplitudesAnsatz to rank and select the 4 most robust, noise-agnostic features (e.g., Green Variability, Red-Blue Ratio). - Achieves near-perfect accuracy using a fine-tuned RBF Support Vector Machine (SVM) on the quantum-selected feature subset.
Advanced Boll Detection & Counting
- Uses multi-scale Top-Hat transformations and CLAHE (Contrast Limited Adaptive Histogram Equalization) to aggressively detect cotton bolls.
- Dynamically handles the severe camouflage of pre-defoliation bolls (hidden under green canopies and shadows) versus fully exposed post-defoliation bolls.
- Outputs an annotated image plotting every localized boll.
Interactive Gradio Workspace
- A highly customized, cyberpunk-inspired dark theme UI.
- Real-time generation of confidence metrics, feature distribution bar charts, and quantum subset rankings.
π How to Run Locally
You will need Python 3.10+ (or newer). We recommend using a virtual environment.
1. Clone the Repository
git clone https://github.com/harshitha-8/SPIE.git
cd SPIE/CottonDefoliationApp # Or your local path to this UI code
2. Install Dependencies
pip install -r requirements.txt
Note: Make sure you have qiskit, opencv-python-headless, gradio, and scikit-learn installed.
3. Run the Application
python app.py
Once the server starts, open your browser and navigate to the local address provided (usually http://127.0.0.1:7860).
On Hugging Face Spaces, the app now uses the platform-provided PORT automatically and binds to 0.0.0.0, which is required for hosted deployment.
Deploy To Hugging Face Space
Hugging Face Spaces uses its own git repository. Updating this GitHub repository alone does not update the live Space app.
To publish this exact app to your Space, push the same files to the Space repo:
git clone https://github.com/harshitha-8/SPIE.git
cd SPIE
git remote add hf https://huggingface.co/spaces/Harshitha09/quantum_Harvest
git push hf main
If hf already exists as a remote, update it instead:
git remote set-url hf https://huggingface.co/spaces/Harshitha09/quantum_Harvest
git push hf main
You will be prompted for your Hugging Face credentials or access token with write permission.
πΈ Using the Application
- Upload an Image: Click the "π CHOOSE IMAGE FILE" button and select an aerial RGB drone photo of a cotton field.
- Analyze: Click "β RUN QUANTUM ANALYSIS".
- Review Results:
- Verdict: Immediate confirmation of Pre/Post Defoliation status.
- Boll Count: Estimated count of visible or camouflaged cotton bolls.
- Detection Map: Download or enlarge the annotated image showing the physical detection hit-boxes.
- Metrics: Review the Quantum Subset charts and the confidence spectrum.
π§ Model Training
If you are using new data and wish to retrain the underlying SVM model:
- Prepare your extracted features using the methods laid out in the main SPIE repository.
- Run
python train_model.pyto regenerate themodel.pklfile used by the application.
π€ Citation & Credits
If you use this codebase or application for research, please reference the main repository: https://github.com/harshitha-8/SPIE.
Built with β₯ using Qiskit, Gradio, OpenCV, and Scikit-Learn.