-
Notifications
You must be signed in to change notification settings - Fork 12
Sourcery refactored master branch #13
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,8 +12,7 @@ def pencilsketch(inp_img): | |
| img_gray = cv2.cvtColor(inp_img, cv2.COLOR_BGR2GRAY) | ||
| img_invert = cv2.bitwise_not(img_gray) | ||
| img_smoothing = cv2.GaussianBlur(img_invert, (21, 21),sigmaX=0, sigmaY=0) | ||
| final_img = dodgeV2(img_gray, img_smoothing) | ||
| return(final_img) | ||
| return dodgeV2(img_gray, img_smoothing) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| st.title("PencilSketcher App") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,8 +46,9 @@ def videoUserDefined(src: str, width="100%", height=315): | |
| # @cache | ||
| @st.cache | ||
| def load_data(): | ||
| df = pd.read_csv("https://github.com/SurendraRedd/StreamlitProjects/raw/master/lang.csv") | ||
| return df | ||
| return pd.read_csv( | ||
| "https://github.com/SurendraRedd/StreamlitProjects/raw/master/lang.csv" | ||
| ) | ||
|
Comment on lines
-49
to
+51
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| # In[ ]: | ||
|
|
@@ -75,7 +76,7 @@ def main(): | |
|
|
||
| """ | ||
| st.markdown(html_temp,unsafe_allow_html=True) | ||
| st.markdown('<i class="material-icons">{}</i>'.format("people"), unsafe_allow_html=True) | ||
| st.markdown('<i class="material-icons">people</i>', unsafe_allow_html=True) | ||
|
Comment on lines
-78
to
+79
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| st.latex(r''' e^{i\pi} + 1 = 0 ''') | ||
| st.latex(r''' | ||
| ... a + ar + a r^2 + a r^3 + \cdots + a r^{n-1} = | ||
|
|
@@ -92,8 +93,7 @@ def main(): | |
| my_table = st.table(df1) | ||
|
|
||
| df = st.cache(pd.read_csv)("https://github.com/SurendraRedd/StreamlitProjects/raw/master/lang.csv") | ||
| is_check = st.checkbox("Display Data") | ||
| if is_check: | ||
| if is_check := st.checkbox("Display Data"): | ||
| st.write(df) | ||
|
|
||
| st.write('Dataframe example') | ||
|
|
@@ -116,7 +116,7 @@ def main(): | |
|
|
||
| data = {'1':"True",'2':"True",'3':"False"} | ||
| st.json(data) | ||
|
|
||
| # Exception handling | ||
| st.exception("IndexError('list out of index')") | ||
|
|
||
|
|
@@ -163,7 +163,7 @@ def main(): | |
| ["SamaraSimhaReddy", "Simha", | ||
| "NarasimhaNaidu", "Legend"]) | ||
|
|
||
|
|
||
| # Will only run once if already cached | ||
| df = load_data() | ||
| st.write(df) | ||
|
|
@@ -187,7 +187,7 @@ def main(): | |
| with st.echo(): | ||
| text = 's="Happy Learning!" for i in range(0,10): print(s)' | ||
| st.write(text) | ||
|
|
||
|
|
||
| #Image opening | ||
| #img = Image.open("download.jfif") #open the image stored in specified location | ||
|
|
@@ -230,7 +230,7 @@ def main(): | |
| for percent_complete in range(100): | ||
| time.sleep(0.1) | ||
| my_bar.progress(percent_complete + 1) | ||
|
|
||
| with st.spinner('Wait for it...'): | ||
| time.sleep(5) | ||
| st.success('Done!') | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,24 +19,23 @@ def imageConversion(inputImage): | |
| grayScaleImg = cv2.cvtColor(inputImage, cv2.COLOR_BGR2GRAY) | ||
| invertImg = cv2.bitwise_not(grayScaleImg) | ||
| smoothImg = cv2.GaussianBlur(invertImg, (21,21),sigmaX=0, sigmaY=0) | ||
| finalImg = dodgeV2(grayScaleImg,smoothImg) | ||
| return finalImg | ||
| return dodgeV2(grayScaleImg,smoothImg) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def main(): | ||
| # Documentation - Main Function to process | ||
| # Title of the web page | ||
| st.title("Convert an image in to pencil sketch") | ||
| st.subheader("This application has options to select the image either from sidebar or in mainpage.") | ||
| html_temp = """ | ||
| st.title("Convert an image in to pencil sketch") | ||
| st.subheader("This application has options to select the image either from sidebar or in mainpage.") | ||
| html_temp = """ | ||
| <body style="background-color:red;"> | ||
| <div style="background-color:teal ;padding:10px"> | ||
| <h2 style="color:white;text-align:center;">Image to Pencil Sketch App</h2> | ||
| </div> | ||
| </body> | ||
| """ | ||
| st.markdown(html_temp, unsafe_allow_html=True) | ||
| st.write("-----------------------------------------------------------------------") | ||
| st.write(""" | ||
| st.markdown(html_temp, unsafe_allow_html=True) | ||
| st.write("-----------------------------------------------------------------------") | ||
| st.write(""" | ||
|
Comment on lines
-28
to
+38
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ): |
||
| ## Packages: | ||
| - Streamlit, Opencv, Pillow & numpy | ||
| - How to install? | ||
|
|
@@ -45,70 +44,61 @@ def main(): | |
| > 3. **pip install numpy** | ||
| > 4. **pip install Pillow** | ||
| """) | ||
| st.write("-----------------------------------------------------------------------") | ||
| st.write("-----------------------------------------------------------------------") | ||
|
|
||
| # To avoid the deprecation warning while using the file uploader | ||
| st.set_option('deprecation.showfileUploaderEncoding', False) | ||
| # To avoid the deprecation warning while using the file uploader | ||
| st.set_option('deprecation.showfileUploaderEncoding', False) | ||
|
|
||
| # Selection box | ||
| image_option = st.sidebar.selectbox( | ||
| 'Image Option', | ||
| ('None','Sidebar', 'Mainpage') | ||
| ) | ||
| # Selection box | ||
| image_option = st.sidebar.selectbox( | ||
| 'Image Option', | ||
| ('None','Sidebar', 'Mainpage') | ||
| ) | ||
|
|
||
| # Side bar Selection | ||
| if image_option == 'Sidebar': | ||
| input_sidebar_image = st.sidebar.file_uploader("Select an image file", type=['jpeg','jpg','png']) | ||
| if input_sidebar_image is None: | ||
| pass | ||
| #st.error("Select the image to proceed!") | ||
| else: | ||
| st.write("**Side bar Image selected is **") | ||
| st.image(input_sidebar_image,use_column_width=True) | ||
| input_img = Image.open(input_sidebar_image) | ||
| skecthImage = imageConversion(np.array(input_img)) | ||
| st.write("**Skecthed Image is **") | ||
| st.image(skecthImage,use_column_width=True) | ||
| # Side bar Selection | ||
| if image_option == 'Sidebar': | ||
| input_sidebar_image = st.sidebar.file_uploader("Select an image file", type=['jpeg','jpg','png']) | ||
| if input_sidebar_image is not None: | ||
| st.write("**Side bar Image selected is **") | ||
| st.image(input_sidebar_image,use_column_width=True) | ||
| input_img = Image.open(input_sidebar_image) | ||
| skecthImage = imageConversion(np.array(input_img)) | ||
| st.write("**Skecthed Image is **") | ||
| st.image(skecthImage,use_column_width=True) | ||
|
|
||
| elif image_option == 'Mainpage': | ||
| input_image = st.file_uploader("Select an image file to process", type=['jpeg','jpg','png']) | ||
| if input_image is None: | ||
| pass | ||
| #st.error("Select the image to proceed!") | ||
| else: | ||
| st.write("**Main page Image selected is **") | ||
| st.image(input_image,use_column_width=True) | ||
| input_img = Image.open(input_image) | ||
| skecthImage = imageConversion(np.array(input_img)) | ||
| st.write("**Skecthed Image is **") | ||
| st.image(skecthImage,use_column_width=True) | ||
| else: | ||
| pass | ||
|
|
||
| st.sidebar.title("Tip - Run app directly from GitHubLink") | ||
| st.sidebar.info(""" streamlit run | ||
| elif image_option == 'Mainpage': | ||
| input_image = st.file_uploader("Select an image file to process", type=['jpeg','jpg','png']) | ||
| if input_image is not None: | ||
| st.write("**Main page Image selected is **") | ||
| st.image(input_image,use_column_width=True) | ||
| input_img = Image.open(input_image) | ||
| skecthImage = imageConversion(np.array(input_img)) | ||
| st.write("**Skecthed Image is **") | ||
| st.image(skecthImage,use_column_width=True) | ||
| st.sidebar.title("Tip - Run app directly from GitHubLink") | ||
| st.sidebar.info(""" streamlit run | ||
| https://github.com/SurendraRedd/ | ||
| StreamlitProjects/blob/master | ||
| /sketcher.py | ||
| """) | ||
| st.sidebar.title("Logic") | ||
| st.sidebar.info(""" | ||
| st.sidebar.title("Logic") | ||
| st.sidebar.info(""" | ||
| - Convert the color image to grayscale - ```gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)``` | ||
| - Invert the grayscale image to get a negative - ```imagem = cv2.bitwise_not(imagem)``` | ||
| - Apply a Gaussian blur to the negative from step 2 - ```blur = cv.GaussianBlur()``` | ||
| - Blend the grayscale image from step 1 with the blurred negative from step 3 using a color dodge - ```dodgeV2(mg_gray, img_blur)``` | ||
| > [Sketch Reference](https://www.askaswiss.com/2016/01/how-to-create-pencil-sketch-opencv-python.html) | ||
| """) | ||
| st.sidebar.title("About") | ||
| st.sidebar.info("**App version 1.0**") | ||
| st.sidebar.title("About") | ||
| st.sidebar.info("**App version 1.0**") | ||
|
|
||
| if st.checkbox("ShowDemo?"): | ||
| st.video(open("Demo.mp4","rb").read()) | ||
| if st.checkbox("ShowDemo?"): | ||
| st.video(open("Demo.mp4","rb").read()) | ||
|
|
||
| if st.checkbox("Show source code? "): | ||
| st.code(open("./sketcher.py", encoding="utf-8").read()) | ||
| if st.checkbox("Show source code? "): | ||
| st.code(open("./sketcher.py", encoding="utf-8").read()) | ||
|
|
||
| st.info(""" | ||
| st.info(""" | ||
| [GitHubLink](https://github.com/SurendraRedd/StreamlitProjects/blob/master/sketcher.py) | ||
| """) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
inputFeaturesrefactored with the following changes:inline-immediately-returned-variable)