Here's the English translation of your README.md while preserving all code blocks and markdown formatting:
An image dehazing toolkit that utilizes Deep Convolutional Neural Networks (DNN) for haze removal.
- ---
Install `dehazing` and `image` using `cargo`:
```bash
cargo add dehazing image
Example Code
Below is a complete example demonstrating how to use dehazing for image dehazing:
let device = cuda_if_available.unwrap;
let base_dir = env!;
// Load pre-trained model
let model = with_device.unwrap;
// Open input image
let img = open.unwrap;
// Convert image to RGB8 format and transform to Tensor
let raw = img.to_rgb8.into_vec;
let data = from_vec
.unwrap
.to_dtype
.unwrap
.broadcast_div
.unwrap
.permute
.unwrap
.unsqueeze
.unwrap;
println!;
// Perform dehazing inference
let out = model.forward.unwrap;
// Process output tensor
let out = out.squeeze.unwrap; // Remove batch dimension [c, h, w]
let = out.dims3.unwrap;
// Convert output tensor to image data
let image_data: = out
.permute
.unwrap // [H, W, C] matches image layout
.flatten_all
.unwrap
.
.unwrap
.iter
.map
.collect;
// Save image
let img_out =
from_raw.expect;
img_out.save.expect;
println!;
Model Description
This project implements an end-to-end dehazing model based on the DehazeNet architecture. The model uses deep convolutional neural networks to predict atmospheric light and transmission maps for image restoration.
Device Support
- CPU: Supported by default
- GPU (CUDA): Enabled via
features = ['cuda']with CUDA support
Ensure your system has proper CUDA drivers installed and enable cuda feature during compilation.
Contribution
PRs and Issues are welcome! Please follow the project's coding style and documentation standards.
License
MIT Licensed. See LICENSE for details.