Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import cv2
|
|
3 |
import numpy as np
|
4 |
from PIL import Image
|
5 |
|
|
|
6 |
def image_to_sketch(image):
|
7 |
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
8 |
inverted_image = 255 - gray_image
|
@@ -11,10 +12,21 @@ def image_to_sketch(image):
|
|
11 |
sketch = cv2.divide(gray_image, inverted_blurred, scale=256.0)
|
12 |
return sketch
|
13 |
|
14 |
-
|
|
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
17 |
|
|
|
|
|
|
|
|
|
|
|
18 |
if uploaded_file is not None:
|
19 |
image = np.array(Image.open(uploaded_file))
|
20 |
st.image(image, caption='Uploaded Image', use_column_width=True)
|
@@ -36,3 +48,23 @@ if uploaded_file is not None:
|
|
36 |
file_name="sketch.png",
|
37 |
mime="image/png"
|
38 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import numpy as np
|
4 |
from PIL import Image
|
5 |
|
6 |
+
# Function to convert image to sketch
|
7 |
def image_to_sketch(image):
|
8 |
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
9 |
inverted_image = 255 - gray_image
|
|
|
12 |
sketch = cv2.divide(gray_image, inverted_blurred, scale=256.0)
|
13 |
return sketch
|
14 |
|
15 |
+
# Streamlit app layout
|
16 |
+
st.set_page_config(page_title="Image to Sketch Converter", page_icon="🎨", layout="centered")
|
17 |
|
18 |
+
# Title and description
|
19 |
+
st.title("🎨 Image to Sketch Converter")
|
20 |
+
st.markdown("""
|
21 |
+
Convert your images into beautiful sketches with this simple app.
|
22 |
+
Upload an image, and get the sketch version instantly!
|
23 |
+
""")
|
24 |
|
25 |
+
# Sidebar for user input
|
26 |
+
st.sidebar.header("Upload Your Image")
|
27 |
+
uploaded_file = st.sidebar.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
28 |
+
|
29 |
+
# Main content
|
30 |
if uploaded_file is not None:
|
31 |
image = np.array(Image.open(uploaded_file))
|
32 |
st.image(image, caption='Uploaded Image', use_column_width=True)
|
|
|
48 |
file_name="sketch.png",
|
49 |
mime="image/png"
|
50 |
)
|
51 |
+
else:
|
52 |
+
st.sidebar.info("Please upload an image to convert.")
|
53 |
+
|
54 |
+
# Footer
|
55 |
+
st.markdown("""
|
56 |
+
<style>
|
57 |
+
.footer {
|
58 |
+
position: fixed;
|
59 |
+
left: 0;
|
60 |
+
bottom: 0;
|
61 |
+
width: 100%;
|
62 |
+
background-color: #f1f1f1;
|
63 |
+
text-align: center;
|
64 |
+
padding: 10px;
|
65 |
+
}
|
66 |
+
</style>
|
67 |
+
<div class="footer">
|
68 |
+
Made with ❤️ by [Your Name](https://yourwebsite.com)
|
69 |
+
</div>
|
70 |
+
""", unsafe_allow_html=True)
|