Giter VIP home page Giter VIP logo

rishit-dagli / mirnet-tfjs Goto Github PK

View Code? Open in Web Editor NEW
348.0 8.0 39.0 15.57 MB

TensorFlow JS models for MIRNet for low-lightπŸ’‘ image enhancement

Home Page: https://rishit-dagli.github.io/MIRNet-TFJS/

License: Apache License 2.0

Jupyter Notebook 99.90% JavaScript 0.07% HTML 0.02% CSS 0.01%
tensorflow tfjs computer-vision madewithtfjs deep-learning image-restoration image-super-resolution javascript nodejs mirnet-tfjs machinelearning multi-resolution-streams tfjs-converter mirnet-model tfjs-model

mirnet-tfjs's Introduction

MIRNet-TFJS Twitter URL

Deploy Node.js app Open TF Hub Binder Open In Colab

GitHub license GitHub followers GitHub stars GitHub forks Twitter Follow

Featured on TensorFlow.JS Show And Tell

This repository shows the TFJS model conversion and inference processes for the for the MIRNet model as proposed by Learning Enriched Features for Real Image Restoration and Enhancement by Zamir et al. This model is capable of enhancing low-light images upto a great extent.

Examples

Model training code and pre-trained weights are provided by Soumik through this repository.

Table of contents

A bit about the architecture

The MIRNet presents a novel architecture with the collective goals of maintaining high-resolution representations through the entire network, and receiving strong contextual information from the low-resolution representations.

The core of this approach is a multi-scale residual block containing the following key elements:

  • parallel multi-resolution convolution streams for extracting multi-scale features
  • information exchange across the multi-resolution streams
  • spatial and channel attention mechanisms for capturing contextual information
  • attention based multi-scale feature aggregation.

Framework of MIRNet

The figure above shows the framework of the proposed network MIRNet that learns enriched feature representations for image restoration and enhancement.

About the notebooks

Binder Open In Colab

This notebook shows the the process of downloading pre-trained weights for the MIRNet model and saving it as a SavedModel.

Binder Open In Colab

This notebook shows the the process of converting the SavedModel to the TFJS format we built in the prequel notebook for the MIRNet model. It also shows performing optimizations on this.

Binder Open In Colab

This notebook shows the the process of inferencing for the MIRNet model on a couple of low light photos.

Running the TFJS Model, An example

The code for the example can be found under the example folder in this repo. As of now this example is a very minimalistic one as you can see in the below image. The example website is deployed on the free tier of Azure App Services so inferences could take quite some time (90 seconds or so) when a lot of folks might be using it at the same time. Since this project deploys on the free tier of Azure App Services, the hosted website couldd go down when a lot of users might be trying it out and the easiest way would be to follow the instructions to do so on a GitHub Codespace or on your own machine where inferences would be a lot more faster.

Getting Started

To get up and running with this example, run the following commands, make sure you have Node.js installed.

git clone [email protected]:Rishit-dagli/MIRNet-TFJS.git # or clone your own fork
cd MIRNet-TFJS

After cloning the repository you would need to download the model variables file Download and place it at example/model/variables/variables.data-00000-of-00001, this step has been covered in the below commands however you can also do this through GUI. Run these commands after doing so:

wget -O ./example/model/variables/variables.data-00000-of-00001 https://github.com/Rishit-dagli/MIRNet-TFJS/releases/download/v0.1.0/variables.data-00000-of-00001
cd example # switch to the example folder
npm install
npm start

Your app should now be running on localhost:3000 πŸš€.

Run online on Repl.it

Alternatively you could also get up and running with this example with the free to use online service Repl.it. Get started by clicking on this button Run on Repl.it after which you would click the Run button on the top or run npm start and voila your app is now running πŸš€.

Troubleshooting

The example folder has a standalone modeltest.js file, which tries to run the model on a specified file and then save the output to test the model. You can test the model with this file through:

git clone [email protected]:Rishit-dagli/MIRNet-TFJS.git # or clone your own fork
cd MIRNet-TFJS
cd example # switch to the example folder
npm install
node modeltest.js

The modeltest.js uses the input.PNG image file in the root directory and outputs a output.Png image file.

Want to Contribute πŸ™‹β€β™‚οΈ?

Awesome! If you want to contribute to this project, you're always welcome! See Contributing Guidelines. You can also take a look at MIRNet-TFJS' Project Status Tracker for getting more information about current or upcoming tasks.

Want to discuss? πŸ’¬

Have any questions, doubts or want to present your opinions, views? You're always welcome. You can start discussions.

Contributors

License

Copyright 2020 Rishit Dagli

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

mirnet-tfjs's People

Contributors

rishit-dagli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mirnet-tfjs's Issues

Updating Deploy Workflows for LFS Objects

As of now, the repository contains a LFS object, the workflow to deploy the example application runs on every commit using up a lot of LFS Bandwidth. The LFS object is also provided in the releases and it seems to be a better idea to download the LFS object from the release on running the deploy workflow.

Status code 501

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

git clone [email protected]:Rishit-dagli/MIRNet-TFJS.git # or clone your own fork
cd MIRNet-TFJS
cd example # switch to the example folder
npm install
npm start

Expected behavior
A clear and concise description of what you expected to happen.

Error: Failed to load SavedModel: Read less bytes than requested
         [[{{node RestoreV2}}]]
    at NodeJSKernelBackend.loadSavedModelMetaGraph (/home/myname/MIRNet-TFJS/example/node_modules/@tensorflow/tfjs-node/dist/nodejs_kernel_backend.js:401:29)
    at Object.<anonymous> (/home/myname/MIRNet-TFJS/example/node_modules/@tensorflow/tfjs-node/dist/saved_model.js:446:45)
    at step (/home/myname/MIRNet-TFJS/example/node_modules/@tensorflow/tfjs-node/dist/saved_model.js:48:23)
    at Object.next (/home/myname/MIRNet-TFJS/example/node_modules/@tensorflow/tfjs-node/dist/saved_model.js:29:53)
    at fulfilled (/home/myname/MIRNet-TFJS/example/node_modules/@tensorflow/tfjs-node/dist/saved_model.js:20:58)
undefined
Inside predict
TypeError: Cannot read property 'predict' of undefined
    at predict (/home/myname/MIRNet-TFJS/example/app.js:70:36)
    at async /home/myname/MIRNet-TFJS/example/app.js:125:22
POST /submit 501 9022.197 ms - 5

node modeltest.js

Error: Failed to load SavedModel: Read less bytes than requested
         [[{{node RestoreV2}}]]
    at NodeJSKernelBackend.loadSavedModelMetaGraph (/home/myname/MIRNet-TFJS/example/node_modules/@tensorflow/tfjs-node/dist/nodejs_kernel_backend.js:401:29)
    at Object.<anonymous> (/home/myname/MIRNet-TFJS/example/node_modules/@tensorflow/tfjs-node/dist/saved_model.js:446:45)
    at step (/home/myname/MIRNet-TFJS/example/node_modules/@tensorflow/tfjs-node/dist/saved_model.js:48:23)
    at Object.next (/home/myname/MIRNet-TFJS/example/node_modules/@tensorflow/tfjs-node/dist/saved_model.js:29:53)
    at fulfilled (/home/myname/MIRNet-TFJS/example/node_modules/@tensorflow/tfjs-node/dist/saved_model.js:20:58)
Inside predict
TypeError: Cannot read property 'predict' of undefined
    at predict (/home/myname/MIRNet-TFJS/example/modeltest.js:43:46)
    at async /home/myname/MIRNet-TFJS/example/modeltest.js:74:5
DONE

Desktop (please complete the following information):

  • Browser chrome
  • Version 87

Discussions Are Now Open!

πŸ‘‹ Welcome!

We’re using Discussions as a place to connect with other members of our community. We hope that you:

  • Ask questions you’re wondering about.
  • Share ideas.
  • Engage with other community members.
  • Welcome others and are open-minded. Remember that this is a community we
    build together πŸ’ͺ.

To get started, open the Discussions Tab above and tell us about what you do with this community.

Any idea on inference with TFJS?

The code looks good and the converted models look good too. But, how do we perform inference with TFJS? Seems like you have performed inference, not on the TFJS models and it uses a function from mirnet. So I am guessing we have to implement something similar for TFJS.

If anyone has any idea or implementation for that it would be really helpful!

@Rishit-dagli Great work!

Change location and structure of sample example

The sample example with this repo has been well tested to now move it under an examples folder in the main branch. It would be a good time to do this. Having said that an update to the README and an update on the Repl page from my end would also be required.

Update GitHub Actions

This does not affect the functionality or the web app in any way. The Web App Deployment action prod_mirnet-tfjs.yml as of now has the following trigger:

on:
  push:
    branches:
      - prod

Since as of #8 we are shifting the example to the main branch, the pipeline should run on the main branch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.