Dani786 commited on
Commit
ff570bd
·
verified ·
1 Parent(s): b6fd11b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  import cv2
3
  import numpy as np
4
  from PIL import Image
 
5
 
6
  st.set_page_config(page_title="Image to Sketch", layout="centered")
7
  st.title("🖼️ Image to Sketch Converter")
@@ -27,3 +28,19 @@ if uploaded_file is not None:
27
  st.subheader("Sketch Output")
28
  st.image(sketch, use_container_width=True, channels="GRAY")
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import cv2
3
  import numpy as np
4
  from PIL import Image
5
+ from io import BytesIO
6
 
7
  st.set_page_config(page_title="Image to Sketch", layout="centered")
8
  st.title("🖼️ Image to Sketch Converter")
 
28
  st.subheader("Sketch Output")
29
  st.image(sketch, use_container_width=True, channels="GRAY")
30
 
31
+ # Convert sketch to PIL image
32
+ sketch_pil = Image.fromarray(sketch)
33
+
34
+ # Save image to memory
35
+ buf = BytesIO()
36
+ sketch_pil.save(buf, format="PNG")
37
+ byte_im = buf.getvalue()
38
+
39
+ # Download button
40
+ st.download_button(
41
+ label="📥 Download Sketch",
42
+ data=byte_im,
43
+ file_name="sketch.png",
44
+ mime="image/png"
45
+ )
46
+