Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeFMO notebook example #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

rozumden
Copy link

Simple examples to use DeFMO. Images are yet to be uploaded.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@edgarriba
Copy link
Member

@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
Copy link
Author

@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

@edgarriba
Copy link
Member

edgarriba commented Sep 1, 2021

@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(...)

@rozumden
Copy link
Author

rozumden commented Sep 1, 2021

@edgarriba this looks good to me. It would definitely make the code more user-friendly and understandable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants