# asteroid_detector **Repository Path**: aster/asteroid_detector ## Basic Information - **Project Name**: asteroid_detector - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-13 - **Last Updated**: 2025-08-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Quantum Asteroid Detector This project uses quantum computing via Qiskit to detect asteroids in space images, demonstrating how quantum algorithms can be applied to image classification tasks. ## Key Components 1. **Image Generator**: Creates synthetic space images with and without asteroids 2. **Quantum Classifier**: Uses quantum computing principles to train a model for asteroid detection 3. **Detector**: Command-line tool to detect asteroids in new images using quantum similarity ## Requirements - Python 3.7+ - Qiskit - NumPy - Matplotlib - Pillow (PIL) - scikit-image - scikit-learn Install dependencies: ```bash pip install qiskit matplotlib numpy pillow scikit-image scikit-learn ``` ## Usage ### 1. Run the Complete Pipeline For convenience, you can run the entire pipeline with a single command: ```bash python run_pipeline.py ``` This will generate the dataset, train the quantum model, and test it on a sample image. ### 2. Generate Training Images Generate a dataset of synthetic space images: ```bash python generate_images.py ``` This creates a `dataset` directory with: - `with_asteroid`: Images containing asteroids - `without_asteroid`: Images without asteroids ### 3. Train the Quantum Classifier Train the quantum classifier on the generated dataset: ```bash python quantum_asteroid_detector.py ``` This will: - Process the dataset and reduce dimensions for quantum processing - Train a quantum classifier using quantum similarity measurements - Evaluate model performance and generate a confusion matrix - Save the trained model as `quantum_asteroid_model.pkl` ### 4. Detect Asteroids in New Images Use the trained model to detect asteroids in new images: ```bash python detect_asteroid.py path/to/your/image.png ``` The detector will: - Create a quantum circuit to encode the image features - Use quantum similarity to compare with training examples - Display the detection result with confidence score - Show the quantum circuit used for detection ## Quantum Computing Approach ### Quantum Feature Encoding - Images are processed and reduced to fit in a quantum system - Features are encoded into quantum states using multiple rotation gates (RX, RY, RZ) - Quantum superposition allows processing all feature combinations simultaneously ### Quantum Entanglement - All-to-all connectivity between qubits creates a fully entangled quantum state - Entanglement enables quantum advantage by creating correlations impossible in classical systems ### Quantum Similarity Measurement - The quantum swap test algorithm measures similarity between quantum states - This quantum algorithm provides a way to calculate inner products between quantum states - Similarity scores determine the most similar training examples for classification ## Technical Details - Feature dimension is determined by the number of qubits (2^n_qubits features) - Multiple rotation gates create rich quantum state representations - The quantum classifier uses k-nearest neighbors with quantum similarity metrics - Confidence scores are calculated based on quantum similarity measurements ## Limitations and Future Work - Limited number of qubits (default: 2) due to simulator constraints - Image resolution is significantly reduced for quantum processing - Future improvements could include: - Implementing variational quantum circuits for feature learning - Testing on real quantum hardware - Exploring quantum neural networks for image classification - Applying quantum phase estimation for enhanced feature extraction ## Visualization The project generates several visualizations: - `sample_images.png`: Examples of generated images - `quantum_circuit.png`: Visualization of the quantum circuit - `confusion_matrix.png`: Model performance evaluation - `prediction_results.png`: Sample predictions - `quantum_circuit_detection.png`: Circuit used for detection - `asteroid_detection_result.png`: Detection results with confidence