mallelapreethi commited on
Commit
e481a24
·
verified ·
1 Parent(s): 89bcbb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -33
app.py CHANGED
@@ -46,8 +46,7 @@ st.markdown("""
46
  Upload an image, and get the sketch version instantly!
47
  """)
48
 
49
- # Example conversions
50
- st.subheader("Example Conversions")
51
  col1, col2 = st.columns(2)
52
 
53
  # Replace 'Dog.jpg' with the path to an example image if running locally
@@ -55,43 +54,37 @@ example_image = cv2.imread('Dog.jpg')
55
  example_sketch = image_to_sketch(example_image)
56
 
57
  with col1:
 
58
  st.image(example_image, caption='Original Image', use_column_width=True)
59
- with col2:
60
  st.image(example_sketch, caption='Sketch Image', use_column_width=True)
61
 
62
- # Main content with padding at the bottom to prevent overlap with footer
63
- st.markdown('<div class="content">', unsafe_allow_html=True)
64
-
65
- # Sidebar for user input
66
- st.sidebar.header("Upload Your Image")
67
- uploaded_file = st.sidebar.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
68
-
69
- # Main content
70
- if uploaded_file is not None:
71
- image = np.array(Image.open(uploaded_file))
72
- st.image(image, caption='Uploaded Image', use_column_width=True)
73
-
74
- st.write("")
75
- st.write("Converting...")
76
 
77
- sketch = image_to_sketch(image)
78
-
79
- st.image(sketch, caption='Sketch', use_column_width=True)
 
 
 
80
 
81
- # Provide a download link for the sketch image
82
- im_pil = Image.fromarray(sketch)
83
- im_pil.save("sketch.png")
84
- with open("sketch.png", "rb") as file:
85
- btn = st.download_button(
86
- label="Download Sketch",
87
- data=file,
88
- file_name="sketch.png",
89
- mime="image/png"
90
- )
91
- else:
92
- st.sidebar.info("Please upload an image to convert.")
93
 
94
- st.markdown('</div>', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
95
 
96
  # Footer
97
  st.markdown("""
 
46
  Upload an image, and get the sketch version instantly!
47
  """)
48
 
49
+ # Example conversions and user input side by side
 
50
  col1, col2 = st.columns(2)
51
 
52
  # Replace 'Dog.jpg' with the path to an example image if running locally
 
54
  example_sketch = image_to_sketch(example_image)
55
 
56
  with col1:
57
+ st.subheader("Example Conversions")
58
  st.image(example_image, caption='Original Image', use_column_width=True)
 
59
  st.image(example_sketch, caption='Sketch Image', use_column_width=True)
60
 
61
+ with col2:
62
+ st.subheader("Upload Your Image")
63
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
 
 
 
 
 
 
 
 
 
 
 
64
 
65
+ if uploaded_file is not None:
66
+ image = np.array(Image.open(uploaded_file))
67
+ st.image(image, caption='Uploaded Image', use_column_width=True)
68
+
69
+ st.write("")
70
+ st.write("Converting...")
71
 
72
+ sketch = image_to_sketch(image)
73
+
74
+ st.image(sketch, caption='Sketch', use_column_width=True)
 
 
 
 
 
 
 
 
 
75
 
76
+ # Provide a download link for the sketch image
77
+ im_pil = Image.fromarray(sketch)
78
+ im_pil.save("sketch.png")
79
+ with open("sketch.png", "rb") as file:
80
+ btn = st.download_button(
81
+ label="Download Sketch",
82
+ data=file,
83
+ file_name="sketch.png",
84
+ mime="image/png"
85
+ )
86
+ else:
87
+ st.info("Please upload an image to convert.")
88
 
89
  # Footer
90
  st.markdown("""