Open rozumden opened 3 years ago
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
@rozumden could you provide somewhere the data needed to run this example ? If you could send or share a link - don't add in the PR
@rozumden could you provide somewhere the data needed to run this example ? If you could send or share a link - don't add in the PR
Hi, you can download it here: https://polybox.ethz.ch/index.php/s/SQuVjC6iy8QHsWi
@rozumden I'm checking this and I believe that we could structure better the code and first create a more high-level class (that might go in the direction of the library from now). This is my initial proposal (I can spend some time coding this):
/cc @ducha-aiki please, review this proposal
class VideoDeblurring(nn.Module):
def __init__(selfresolution_x: int, resolution_y: int):
self.render = K.features.DefMO(...)
...
def initialize(cap: cv2.VideoCapture) -> torch.Tensor:
# compute median
...
def _preprocess(...):
bbox, radius = fmo_detect_maxarea(I,B)
# make the cropping and so here
...
def _postprocess(...):
# rgba2hs, etc
...
def forward(self, frame: torch.Tensor) -> torch.Tensor:
""" Grab one frame compute """
### do whatever with median etc
self._update_median(frame)
frame_prep = self._preprocess(frame)
frame_inter = self.render(frame_prep)
frame_post = self._postprocess(frame_inter)
return out
Then to use it
cap = cv2.VideoCapture(...)
deblur = VideoDeblurring(...)
deblur.initialized(cap)
while cap.isOpened():
ret, frame = cap.read()
out = deblur(frame)
To keep in mind for future too (not for now)
deblur.fine_tune(...)
@edgarriba this looks good to me. It would definitely make the code more user-friendly and understandable.
Simple examples to use DeFMO. Images are yet to be uploaded.