Create pages/2_Image_To_Sketch.py
Browse files- pages/2_Image_To_Sketch.py +36 -0
pages/2_Image_To_Sketch.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from PIL import Image
|
| 3 |
+
from utils import dodge_sketch, sobel_sketch, lattice_sketch, canny_sketch, get_image_caption
|
| 4 |
+
|
| 5 |
+
st.title("🎨 Image to Sketch Styles")
|
| 6 |
+
|
| 7 |
+
uploaded = st.file_uploader("Upload an Image", type=["jpg", "jpeg", "png"])
|
| 8 |
+
if uploaded:
|
| 9 |
+
image = Image.open(uploaded).convert("RGB")
|
| 10 |
+
fixed_size = (450, 450)
|
| 11 |
+
caption = get_image_caption(image)
|
| 12 |
+
|
| 13 |
+
st.subheader("Original Image")
|
| 14 |
+
st.image(image.resize(fixed_size), width=fixed_size[0])
|
| 15 |
+
st.markdown(f"<h4 style='text-align: left; color: white;'>Caption: <em>{caption}</em></h4><br>", unsafe_allow_html=True)
|
| 16 |
+
|
| 17 |
+
dodge_img = dodge_sketch(image).resize(fixed_size)
|
| 18 |
+
sobel_img = sobel_sketch(image).resize(fixed_size)
|
| 19 |
+
lattice_img = lattice_sketch(image).resize(fixed_size)
|
| 20 |
+
canny_img = canny_sketch(image).resize(fixed_size)
|
| 21 |
+
|
| 22 |
+
row1 = st.columns(2)
|
| 23 |
+
with row1[0]:
|
| 24 |
+
st.subheader("Dodge Sketch")
|
| 25 |
+
st.image(dodge_img, width=fixed_size[0])
|
| 26 |
+
with row1[1]:
|
| 27 |
+
st.subheader("Sobel Sketch")
|
| 28 |
+
st.image(sobel_img, width=fixed_size[0])
|
| 29 |
+
|
| 30 |
+
row2 = st.columns(2)
|
| 31 |
+
with row2[0]:
|
| 32 |
+
st.subheader("Lattice Sketch")
|
| 33 |
+
st.image(lattice_img, width=fixed_size[0])
|
| 34 |
+
with row2[1]:
|
| 35 |
+
st.subheader("Canny Sketch")
|
| 36 |
+
st.image(canny_img, width=fixed_size[0])
|