”’I’m running this as an app on stream lit i need two

Publish By: Admin,
Last Updated: 18-Apr-24
Price: $120

”’I’m running this as an app on stream lit i need two new filters for my images in the sidebar. one for changing the image color from the original to blue and the other filter being anything you deem fit. Please attach the code for these on the bottom on the attached code where there’s a line of elif filters. and also Include a download button that will allow users to download the filtered image to their device. ‘I’m also attaching the instructions for this as reference to make the changes I listed. It also contains examples.import streamlit as stimport numpy as npimport cv2from PIL import Image, ImageEnhanceimage = Image.open(r’spirit-mark1.png’) #Brand logo image (optional)#Create two columns with different widthcol1, col2 = st.columns( [0.8, 0.2])with col1: # To display the header text using css stylest.markdown(“””
“””, unsafe_allow_html=True)st.markdown(‘
Final Project COP2034
‘, unsafe_allow_html=True)with col2: # To display brand logost.image(image, width=150)#Add a header and expander in side barst.sidebar.markdown(‘
Steven Pierren May 3rd
‘, unsafe_allow_html=True)with st.sidebar.expander(“About the App”):st.write(“””Use this simple app to convert your favorite photo to a pencil sketch, a grayscale image or an image with blurring effect. n nThis app was created by Sharone Li as a side project to learn Streamlit and computer vision. Hope you enjoy!“””)uploaded_file = st.file_uploader(“”, type=[‘jpg’,’png’,’jpeg’])#Add ‘before’ and ‘after’ columnsif uploaded_file is not None:image = Image.open(uploaded_file)col1, col2 = st.columns( [0.5, 0.5])with col1:st.markdown(‘
Before
‘,unsafe_allow_html=True)st.image(image,width=300)with col2:st.markdown(‘
After
‘,unsafe_allow_html=True)filter = st.sidebar.radio(‘Covert your photo to:’, [‘ROTATE EFFECT’,’Gray Image’, ‘Black and White’, ‘Pencil Sketch’, ‘Blur Effect’])with col2:st.markdown(‘
After
‘,unsafe_allow_html=True)if filter == ‘Gray Image’:converted_img = np.array(image.convert(‘RGB’))gray_scale = cv2.cvtColor(converted_img, cv2.COLOR_RGB2GRAY)st.image(gray_scale, width=300)elif filter == ‘Black and White’:converted_img = np.array(image.convert(‘RGB’))gray_scale = cv2.cvtColor(converted_img, cv2.COLOR_RGB2GRAY)slider = st.sidebar.slider(‘Adjust the intensity’, 1, 255, 127, step=1)(thresh, blackAndWhiteImage) = cv2.threshold(gray_scale, slider, 255, cv2.THRESH_BINARY)st.image(blackAndWhiteImage, width=300)elif filter == ‘Pencil Sketch’:converted_img = np.array(image.convert(‘RGB’))gray_scale = cv2.cvtColor(converted_img, cv2.COLOR_RGB2GRAY)inv_gray = 255 – gray_scaleslider = st.sidebar.slider(‘Adjust the intensity’, 25, 255, 125, step=2)blur_image = cv2.GaussianBlur(inv_gray, (slider,slider), 0, 0)sketch = cv2.divide(gray_scale, 255 – blur_image, scale=256)st.image(sketch, width=300)elif filter == ‘Blur Effect’:converted_img = np.array(image.convert(‘RGB’))slider = st.sidebar.slider(‘Adjust the intensity’, 5, 81, 33, step=2)converted_img = cv2.cvtColor(converted_img, cv2.COLOR_RGB2BGR)blur_image = cv2.GaussianBlur(converted_img, (slider,slider), 0, 0)st.image(blur_image, channels=’BGR’, width=300)else:st.image(image, width=300)