LightClearNet
PyTorch
Model Details
Image dehazing is a crucial low-level vision task that recovers clear images from hazy ones. In recent years, immense progress has been made in recovering the original image as accurately as possible, without any consideration for efficiency and performance on low-end hardware, making it a mere relic for image beautification. Image dehazing could be very critical for enhanced visibility during indoor emergencies like fire hazards, utilization in surveillance and security cameras and in autonomous vehicles, and hence should be quick and easy to compute in order to be accessible. LightClearNet is a lightweight yet just as effective model for single image dehazing based around batch normalization and skip connections.
Data Overview
The model has been trained on RESIDE-6K.
Improvements
- Rewrote the dehazing logic without using PIL for better performance.
- Integrated PyTube to use any YouTube video without even downloading.
- Quick display and removal of frames feels like running a video natively (work-around as
cv2.imshow()
was not working).
To-do
- Listen to keyboard input to control video's flow.
- Implement frame skipping during video playback to maintain a stable video FPS when the number of frames getting dehazed per second is lower.
Out[7]:
In [8]:
Out[8]:
In [9]:
Out[9]:
In [10]:
linkcode
Model Files
cap = cv2.VideoCapture(stream_url)
RESIZE = True
start_after_secs = 80
init_pbar = start_after_secs != 0
total_frames_to_skip = start_after_secs * stream_fps
early_stop, stop_after_secs = True, 30
fps = stream_fps
frames = 0
while True:
start_time = timer()
ret, frame = cap.read()
if not ret:
print('No frames returned.')
break
frames += 1
if init_pbar:
pbar = tqdm(total=start_after_secs, desc='Skipping Start')
init_pbar = False
if frames < total_frames_to_skip:
if frames % stream_fps == stream_fps-1:
pbar.update(1)
continue
dehazed_frame = frame_dehazer(frame, resize=RESIZE)
cv2.putText(
dehazed_frame,
text = f'FPS: {fps:.2f} | Video Time: {round(frames / stream_fps, 2)}s',
org = (10, 20),
fontFace = cv2.FONT_HERSHEY_SIMPLEX,
fontScale = 0.5,
color = (255, 255, 255), # white
thickness = 2
)
display(cv2_frame_to_img(dehazed_frame))
clear_output(wait=True)
end_time = timer()
processing_time = end_time - start_time
sleep_time = (stream_fps ** -1) - processing_time
time.sleep(max(sleep_time, 0))
total_time = timer() - start_time
fps = total_time ** -1
if early_stop and frames > (stop_after_secs * stream_fps) + total_frames_to_skip:
break
cap.release()
0 comments
No comments yet.