File size: 1,505 Bytes
f4f4778
 
aa1deb6
f4f4778
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80ff741
f4f4778
80ff741
 
f4f4778
80ff741
f4f4778
aa1deb6
f4f4778
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from PIL import Image
import streamlit as st
from tensorflow.keras import utils, backend

from enhance_me.mirnet import MIRNet


def get_mirnet_object() -> MIRNet:
    mirnet = MIRNet()
    mirnet.build_model()
    utils.get_file(
        "weights_lol_128.h5",
        "https://github.com/soumik12345/enhance-me/releases/download/v0.2/weights_lol_128.h5",
        cache_dir=".",
        cache_subdir="weights",
    )
    mirnet.load_weights("./weights/weights_lol_128.h5")
    return mirnet


def main():
    st.markdown("# Enhance Me")
    st.markdown("Made with :heart: by [geekyRakshit](http://github.com/soumik12345)")
    application = st.sidebar.selectbox(
        "Please select the application:", ("", "Low-light enhancement")
    )
    if application != "":
        if application == "Low-light enhancement":
            uploaded_file = st.sidebar.file_uploader("Select your image:")
            if uploaded_file is not None:
                original_image = Image.open(uploaded_file)
                st.image(original_image, caption="original image")
                st.sidebar.info("Loading MIRNet...")
                mirnet = get_mirnet_object()
                st.sidebar.info("Done!")
                st.sidebar.info("Processing Image...")
                enhanced_image = mirnet.infer(original_image)
                st.sidebar.info("Done!")
                st.image(enhanced_image, caption="enhanced image")
                backend.clear_session()


if __name__ == "__main__":
    main()