pratyyush commited on
Commit
80307ea
·
verified ·
1 Parent(s): 4699de3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -15
app.py CHANGED
@@ -4,7 +4,7 @@ import io
4
  import numpy as np
5
  import cv2
6
 
7
- # Add custom CSS for black background and non-draggable images
8
  st.markdown(
9
  """
10
  <style>
@@ -20,7 +20,7 @@ st.markdown(
20
  color: white !important;
21
  }
22
  .stButton>button {
23
- background-color: #4CAF50; /* Green button */
24
  color: white;
25
  border: none;
26
  padding: 10px 20px;
@@ -36,17 +36,25 @@ st.markdown(
36
  background-color: #45a049;
37
  }
38
  .stDownloadButton>button {
39
- background-color: #008CBA; /* Blue button */
40
  color: white;
41
  }
42
  .stDownloadButton>button:hover {
43
  background-color: #007bb5;
44
  }
45
- /* Make images non-draggable */
46
  img {
47
  pointer-events: none;
48
  -webkit-user-drag: none;
49
  }
 
 
 
 
 
 
 
 
50
  </style>
51
  """,
52
  unsafe_allow_html=True
@@ -61,18 +69,18 @@ uploaded_file = st.file_uploader("Upload an Image", type=["jpg", "jpeg", "png"])
61
  if uploaded_file:
62
  # Load image
63
  image = Image.open(uploaded_file)
64
- st.image(image, caption="Uploaded Image", use_container_width=True)
65
 
66
  # Sidebar Tools
67
  st.sidebar.title("Editing Tools")
68
 
69
- # Slightly enhanced default values
70
- brightness = st.sidebar.slider("Brightness", 0.1, 3.0, 1.2) # Default 1.2 (slightly brighter)
71
- contrast = st.sidebar.slider("Contrast", 0.1, 3.0, 1.1) # Default 1.1 (slightly higher contrast)
72
- sharpness = st.sidebar.slider("Sharpness", 0.1, 3.0, 1.3) # Default 1.3 (more sharpness)
73
- color = st.sidebar.slider("Color Saturation", 0.1, 3.0, 1.1) # Default 1.1 (richer color)
74
 
75
- # Filters
76
  if st.sidebar.checkbox("Apply Filters"):
77
  filter_option = st.sidebar.selectbox("Select a Filter", ["None", "BLUR", "DETAIL", "EDGE_ENHANCE", "SMOOTH"])
78
  if filter_option == "BLUR":
@@ -112,13 +120,13 @@ if uploaded_file:
112
  enhancer = ImageEnhance.Sharpness(image)
113
  image = enhancer.enhance(sharpness)
114
  enhancer = ImageEnhance.Color(image)
115
- image = enhancer.enhance(color) # Enhance color saturation
116
 
117
  except Exception as e:
118
- st.write(f"Error during enhancement: {e}")
119
 
120
  # Display Enhanced Image
121
- st.image(image, caption="Enhanced Image", use_container_width=True)
122
 
123
  # Download Button
124
  buf = io.BytesIO()
@@ -130,4 +138,4 @@ if uploaded_file:
130
  data=byte_im,
131
  file_name="enhanced_image.png",
132
  mime="image/png"
133
- )
 
4
  import numpy as np
5
  import cv2
6
 
7
+ # Custom CSS for black background, non-draggable images, and removed three-dot menu
8
  st.markdown(
9
  """
10
  <style>
 
20
  color: white !important;
21
  }
22
  .stButton>button {
23
+ background-color: #4CAF50;
24
  color: white;
25
  border: none;
26
  padding: 10px 20px;
 
36
  background-color: #45a049;
37
  }
38
  .stDownloadButton>button {
39
+ background-color: #008CBA;
40
  color: white;
41
  }
42
  .stDownloadButton>button:hover {
43
  background-color: #007bb5;
44
  }
45
+ /* Make images non-draggable */
46
  img {
47
  pointer-events: none;
48
  -webkit-user-drag: none;
49
  }
50
+ /* Remove three-dot menu */
51
+ .stActionMenu, [data-testid="stActionButton"] {
52
+ display: none !important;
53
+ }
54
+ /* Remove Streamlit footer */
55
+ footer {visibility: hidden;}
56
+ /* Remove Streamlit hamburger menu */
57
+ #MainMenu {visibility: hidden;}
58
  </style>
59
  """,
60
  unsafe_allow_html=True
 
69
  if uploaded_file:
70
  # Load image
71
  image = Image.open(uploaded_file)
72
+ st.image(image, caption="Uploaded Image", use_column_width=True)
73
 
74
  # Sidebar Tools
75
  st.sidebar.title("Editing Tools")
76
 
77
+ # Enhanced default values
78
+ brightness = st.sidebar.slider("Brightness", 0.1, 3.0, 1.2)
79
+ contrast = st.sidebar.slider("Contrast", 0.1, 3.0, 1.1)
80
+ sharpness = st.sidebar.slider("Sharpness", 0.1, 3.0, 1.3)
81
+ color = st.sidebar.slider("Color Saturation", 0.1, 3.0, 1.1)
82
 
83
+ # Basic Filters
84
  if st.sidebar.checkbox("Apply Filters"):
85
  filter_option = st.sidebar.selectbox("Select a Filter", ["None", "BLUR", "DETAIL", "EDGE_ENHANCE", "SMOOTH"])
86
  if filter_option == "BLUR":
 
120
  enhancer = ImageEnhance.Sharpness(image)
121
  image = enhancer.enhance(sharpness)
122
  enhancer = ImageEnhance.Color(image)
123
+ image = enhancer.enhance(color)
124
 
125
  except Exception as e:
126
+ st.error(f"Error during enhancement: {e}")
127
 
128
  # Display Enhanced Image
129
+ st.image(image, caption="Enhanced Image", use_column_width=True)
130
 
131
  # Download Button
132
  buf = io.BytesIO()
 
138
  data=byte_im,
139
  file_name="enhanced_image.png",
140
  mime="image/png"
141
+ )