File size: 1,856 Bytes
1c0922f
0ba222d
 
38dd61c
0ba222d
 
 
 
 
 
 
 
 
38dd61c
 
 
0ba222d
38dd61c
0ba222d
38dd61c
 
 
 
 
 
 
 
 
0ba222d
 
38dd61c
 
 
 
 
 
0ba222d
 
38dd61c
 
 
 
0ba222d
38dd61c
 
 
 
 
 
 
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
46
47
48
49
50
import streamlit as st
from io import BytesIO
from PIL import Image
# from utils import convert_to_bw, load_colorization_model, colorize_bw_image

st.set_page_config(page_title="Image Colorizer", layout="centered")

st.title("Convert B&W images to Colored and vice versa")

uploaded_file = st.sidebar.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])



# if uploaded_file:
#     # Open and convert the uploaded image to RGB format
#     image = Image.open(uploaded_file).convert("RGB")

#     option = st.sidebar.selectbox("Choose an action", ("Convert to Black & White", "Colorize Black & White"))

#     if st.sidebar.button("Process"):
#         #Convert the uploaded image to black and white
#         if option == "Convert to Black & White":
#             result_img = convert_to_bw(image)
#         #Colorize a black and white image using a pre-trained model
#         elif option == "Colorize Black & White":
#             with st.spinner("Colorizing..."):
#                 net = load_colorization_model()
#                 result_img = colorize_bw_image(image, net)
            

#         # Display both images in columns
#         col1, col2 = st.columns(2)
#         with col1:
#             st.image(image, caption="Original Image", use_container_width=True)
#         with col2:
#             st.image(result_img, caption="Processed Image", use_container_width=True)
            
            
#         # Create a buffer to store image bytes
#         buffer = BytesIO()
#         result_img.save(buffer, format="JPEG")  
#         buffer.seek(0)  # Reset cursor to the beginning
        
#         #Download Image in Jpeg
#         st.download_button(
#             label="Download Output Image",
#             data=buffer ,#result_img.tobytes()
#             file_name="output.jpeg",
#             mime="image/jpeg"
#         )