ClearSight-RL is a Reinforcement Learning pipeline that dynamically enhances degraded images (e.g., heavy fog) to maximize YOLOv8 object detection accuracy. It trains a PPO agent to intelligently sequence OpenCV filters and uses inference-time guardrails to guarantee the enhancement never degrades baseline performance.
Comparison of standard YOLOv8 detection on a foggy image (left) vs. ClearSight-RL enhanced detection (right).
ClearSight-RL/
├── README.md
├── inference.py
├── requirements.txt
├── yolov8n.pt
└── model/
└── clearsight_agent_ots_oracle.zip
Due to the size of the datasets (RTTS, SOTS, Foggy Cityscapes) and the compute resources required, the primary training pipeline is designed to be run in cloud environments like Kaggle.
- Training Notebook: https://www.kaggle.com/code/kkm121121/train-clearsight/notebook
Training Details:
- Algorithm: Proximal Policy Optimization (PPO) via stable-baselines3
- Reward Signal: Change in YOLOv8 Confidence and Bounding Box Intersection over Union (IoU)
- Optimization: Subprocess Vectorization for parallel environment rollout
A local Streamlit dashboard is provided to test the trained agent on custom images and visualize the filter sequencing in real-time.
Ensure you have Python 3.9+ installed. Clone this repository and install the dependencies:
pip install -r requirements.txt
- Ensure the pre-trained agent (clearsight_agent_ots_oracle.zip) is located in the model/ directory.
- Launch the Streamlit application:
streamlit run inference.py
The project includes benchmarking scripts to evaluate the agent against standard datasets (e.g., Foggy Cityscapes). To accurately simulate real-world constraints (like autonomous driving safety thresholds), the benchmark filters out object detections with low confidence scores (e.g., < 0.60).
To prevent the agent from over-processing images, two primary constraints are applied during inference:
- Action Masking: Prevents the RL agent from recursively applying the same high-contrast filter, avoiding image degradation (noise/artifacts).
- Confidence Rollbacks: Compares the YOLO detection confidence of the raw image against the AI-enhanced image. If the enhancement reduces the overall detection confidence (e.g., due to domain shift), the system reverts to the raw image. This ensures the pipeline's output is strictly greater than or equal to the baseline performance.
Evaluated on 500 images with a strict 0.60 confidence threshold:
- Raw Foggy Detections: 1,126 objects
- RL Enhanced Detections: 1,228 objects
- Performance Delta: +9.1% increase in high-confidence object detections
