Ghmustafa11 commited on
Commit
c733130
·
verified ·
1 Parent(s): f0d3742

Create App. Py

Browse files
Files changed (1) hide show
  1. App. Py +42 -0
App. Py CHANGED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image, ImageOps
3
+
4
+ # 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
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
+ # Display the uploaded image
23
+ image = Image.open(uploaded_file)
24
+ st.image(image, caption="Uploaded Image", use_column_width=True)
25
+
26
+ # Select an effect
27
+ effect = st.selectbox("Choose an effect", ["kiss", "sepia", "invert"])
28
+
29
+ # Apply effect
30
+ if st.button("Apply Effect"):
31
+ processed_image = apply_effect(image, effect)
32
+ st.image(processed_image, caption="Processed Image", use_column_width=True)
33
+
34
+ # Download button
35
+ processed_image.save("processed_image.png")
36
+ with open("processed_image.png", "rb") as file:
37
+ st.download_button(
38
+ label="Download Image",
39
+ data=file,
40
+ file_name="processed_image.png",
41
+ mime="image/png"
42
+ )