Krishnaveni11 commited on
Commit
f397615
ยท
verified ยท
1 Parent(s): f290d87

Update python.py

Browse files
Files changed (1) hide show
  1. python.py +20 -13
python.py CHANGED
@@ -45,25 +45,25 @@ def main():
45
  """
46
  <style>
47
  body {
48
- background-color: #F5E1DA;
49
  }
50
  .stTitle {
51
- color: #5E3C1E;
52
  text-align: center;
53
  font-family: 'Arial', sans-serif;
54
  }
55
  .stButton>button {
56
- background-color: #C19A6B;
57
  color: white;
58
  border-radius: 8px;
59
  }
60
  .stDownloadButton>button {
61
- background-color: #8B5E3C;
62
  color: white;
63
  border-radius: 8px;
64
  }
65
  .stSlider {
66
- color: #5E3C1E;
67
  }
68
  </style>
69
  """,
@@ -91,7 +91,7 @@ def main():
91
  uploaded_file = st.file_uploader("๐Ÿ“ค Upload an Image", type=['jpg', 'jpeg', 'png'])
92
  if uploaded_file:
93
  image = Image.open(uploaded_file)
94
- st.image(image, caption="Original Image", use_column_width=True)
95
 
96
  st.subheader("๐ŸŽ›๏ธ Transformation Controls")
97
 
@@ -102,32 +102,39 @@ def main():
102
  )
103
 
104
  # --- Default Transformations ---
 
 
105
  if transformation_mode == "All Transformations":
106
  st.write("### ๐ŸŒŸ Adjust All Transformations")
107
 
108
  # Translation
109
  x_offset = st.slider("X Offset", -100, 100, 0)
110
  y_offset = st.slider("Y Offset", -100, 100, 0)
111
- image = translate_image(image, x_offset, y_offset)
 
112
 
113
  # Rotation
114
  angle = st.slider("Rotation Angle", 0, 360, 0)
115
- image = rotate_image(image, angle)
 
116
 
117
  # Scaling
118
  scale = st.slider("Scale Factor", 0.5, 2.0, 1.0)
119
- image = scale_image(image, scale)
 
120
 
121
  # Cropping
122
  left = st.slider("Crop Left", 0, image.width, 0)
123
  upper = st.slider("Crop Upper", 0, image.height, 0)
124
  right = st.slider("Crop Right", left, image.width, image.width)
125
  lower = st.slider("Crop Lower", upper, image.height, image.height)
126
- image = crop_image(image, left, upper, right, lower)
 
127
 
128
  # Flipping
129
  flip_type = st.selectbox("Flip Image", ["None", "Horizontal", "Vertical"])
130
- image = flip_image(image, flip_type)
 
131
 
132
  # --- Specific Transformation ---
133
  elif transformation_mode == "Specific Transformation":
@@ -160,8 +167,8 @@ def main():
160
  flip_type = st.selectbox("Flip Type", ["None", "Horizontal", "Vertical"])
161
  image = flip_image(image, flip_type)
162
 
163
- # --- Display Transformed Image ---
164
- st.image(image, caption="Transformed Image", use_column_width=True)
165
 
166
  # --- Download Transformed Image ---
167
  img_buffer = io.BytesIO()
 
45
  """
46
  <style>
47
  body {
48
+ background-color: #F2D1B3; /* Soft nude beige */
49
  }
50
  .stTitle {
51
+ color: #5F3B26; /* Warm brown */
52
  text-align: center;
53
  font-family: 'Arial', sans-serif;
54
  }
55
  .stButton>button {
56
+ background-color: #D1A39A; /* Muted pinkish nude */
57
  color: white;
58
  border-radius: 8px;
59
  }
60
  .stDownloadButton>button {
61
+ background-color: #A87C61; /* Warm sand color */
62
  color: white;
63
  border-radius: 8px;
64
  }
65
  .stSlider {
66
+ color: #5F3B26; /* Warm brown */
67
  }
68
  </style>
69
  """,
 
91
  uploaded_file = st.file_uploader("๐Ÿ“ค Upload an Image", type=['jpg', 'jpeg', 'png'])
92
  if uploaded_file:
93
  image = Image.open(uploaded_file)
94
+ st.image(image, caption="Original Image", use_container_width=True)
95
 
96
  st.subheader("๐ŸŽ›๏ธ Transformation Controls")
97
 
 
102
  )
103
 
104
  # --- Default Transformations ---
105
+ transformed_image = image.copy() # Keep a copy for showing all intermediate transformations
106
+
107
  if transformation_mode == "All Transformations":
108
  st.write("### ๐ŸŒŸ Adjust All Transformations")
109
 
110
  # Translation
111
  x_offset = st.slider("X Offset", -100, 100, 0)
112
  y_offset = st.slider("Y Offset", -100, 100, 0)
113
+ translated_image = translate_image(transformed_image, x_offset, y_offset)
114
+ st.image(translated_image, caption="After Translation", use_container_width=True)
115
 
116
  # Rotation
117
  angle = st.slider("Rotation Angle", 0, 360, 0)
118
+ rotated_image = rotate_image(transformed_image, angle)
119
+ st.image(rotated_image, caption="After Rotation", use_container_width=True)
120
 
121
  # Scaling
122
  scale = st.slider("Scale Factor", 0.5, 2.0, 1.0)
123
+ scaled_image = scale_image(transformed_image, scale)
124
+ st.image(scaled_image, caption="After Scaling", use_container_width=True)
125
 
126
  # Cropping
127
  left = st.slider("Crop Left", 0, image.width, 0)
128
  upper = st.slider("Crop Upper", 0, image.height, 0)
129
  right = st.slider("Crop Right", left, image.width, image.width)
130
  lower = st.slider("Crop Lower", upper, image.height, image.height)
131
+ cropped_image = crop_image(transformed_image, left, upper, right, lower)
132
+ st.image(cropped_image, caption="After Cropping", use_container_width=True)
133
 
134
  # Flipping
135
  flip_type = st.selectbox("Flip Image", ["None", "Horizontal", "Vertical"])
136
+ flipped_image = flip_image(transformed_image, flip_type)
137
+ st.image(flipped_image, caption="After Flipping", use_container_width=True)
138
 
139
  # --- Specific Transformation ---
140
  elif transformation_mode == "Specific Transformation":
 
167
  flip_type = st.selectbox("Flip Type", ["None", "Horizontal", "Vertical"])
168
  image = flip_image(image, flip_type)
169
 
170
+ # --- Display Final Transformed Image ---
171
+ st.image(image, caption="Transformed Image", use_container_width=True)
172
 
173
  # --- Download Transformed Image ---
174
  img_buffer = io.BytesIO()