Ghmustafa11 commited on
Commit
466b748
·
verified ·
1 Parent(s): ed27113

Create App. Py

Browse files
Files changed (1) hide show
  1. App. Py +41 -0
App. Py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image, ImageOps
3
+
4
+ # Define the function to apply effects
5
+ def apply_effect(image, effect):
6
+ if effect == "kiss":
7
+ image = image.convert("L") # Convert to grayscale
8
+ elif effect == "sepia":
9
+ sepia_img = ImageOps.colorize(image.convert("L"), black="black", white="orange")
10
+ image = sepia_img
11
+ elif effect == "invert":
12
+ image = ImageOps.invert(image.convert("RGB"))
13
+ return image
14
+
15
+ # Streamlit app UI
16
+ st.title("Image Effect Converter")
17
+
18
+ # Upload image
19
+ uploaded_file = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
20
+
21
+ if uploaded_file is not None:
22
+ image = Image.open(uploaded_file)
23
+ st.image(image, caption="Uploaded Image", use_column_width=True)
24
+
25
+ # Effect options
26
+ effect = st.selectbox("Choose an effect", ["kiss", "sepia", "invert"])
27
+
28
+ # Apply effect
29
+ if st.button("Apply Effect"):
30
+ processed_image = apply_effect(image, effect)
31
+ st.image(processed_image, caption="Processed Image", use_column_width=True)
32
+
33
+ # Download option
34
+ processed_image.save("processed_image.png")
35
+ with open("processed_image.png", "rb") as file:
36
+ st.download_button(
37
+ label="Download Image",
38
+ data=file,
39
+ file_name="processed_image.png",
40
+ mime="image/png"
41
+ )