Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import numpy as np
|
|
| 4 |
from PIL import Image
|
| 5 |
import io
|
| 6 |
|
| 7 |
-
st.title("
|
| 8 |
|
| 9 |
uploaded_files = st.file_uploader(
|
| 10 |
"Upload one or more images",
|
|
@@ -28,9 +28,10 @@ if uploaded_files:
|
|
| 28 |
|
| 29 |
for uploaded_file in uploaded_files:
|
| 30 |
st.markdown("---")
|
| 31 |
-
st.subheader(f"
|
| 32 |
|
| 33 |
-
|
|
|
|
| 34 |
img_array = np.array(image)
|
| 35 |
|
| 36 |
transformed_img = img_array.copy()
|
|
@@ -61,18 +62,17 @@ if uploaded_files:
|
|
| 61 |
col1, col2 = st.columns(2)
|
| 62 |
|
| 63 |
with col1:
|
| 64 |
-
st.image(
|
| 65 |
-
|
| 66 |
|
| 67 |
with col2:
|
| 68 |
if option != "None":
|
| 69 |
if len(transformed_img.shape) == 2:
|
| 70 |
-
st.image(transformed_img, caption=f"Transformed: {option}",
|
| 71 |
else:
|
| 72 |
-
st.image(transformed_img, caption=f"Transformed: {option}",
|
| 73 |
|
| 74 |
# Download button
|
| 75 |
-
result = Image.fromarray(transformed_img)
|
| 76 |
buf = io.BytesIO()
|
| 77 |
result.save(buf, format="PNG")
|
| 78 |
byte_im = buf.getvalue()
|
|
|
|
| 4 |
from PIL import Image
|
| 5 |
import io
|
| 6 |
|
| 7 |
+
st.title(" Image Augmentation Tool (Multi-image Support)")
|
| 8 |
|
| 9 |
uploaded_files = st.file_uploader(
|
| 10 |
"Upload one or more images",
|
|
|
|
| 28 |
|
| 29 |
for uploaded_file in uploaded_files:
|
| 30 |
st.markdown("---")
|
| 31 |
+
st.subheader(f" {uploaded_file.name}")
|
| 32 |
|
| 33 |
+
# Open and convert image
|
| 34 |
+
image = Image.open(uploaded_file).convert("RGB")
|
| 35 |
img_array = np.array(image)
|
| 36 |
|
| 37 |
transformed_img = img_array.copy()
|
|
|
|
| 62 |
col1, col2 = st.columns(2)
|
| 63 |
|
| 64 |
with col1:
|
| 65 |
+
st.image(image, caption="Original Image", use_container_width=True)
|
|
|
|
| 66 |
|
| 67 |
with col2:
|
| 68 |
if option != "None":
|
| 69 |
if len(transformed_img.shape) == 2:
|
| 70 |
+
st.image(transformed_img, caption=f"Transformed: {option}", use_container_width=True, channels="GRAY")
|
| 71 |
else:
|
| 72 |
+
st.image(transformed_img, caption=f"Transformed: {option}", use_container_width=True)
|
| 73 |
|
| 74 |
# Download button
|
| 75 |
+
result = Image.fromarray(transformed_img if len(transformed_img.shape) == 3 else cv2.cvtColor(transformed_img, cv2.COLOR_GRAY2RGB))
|
| 76 |
buf = io.BytesIO()
|
| 77 |
result.save(buf, format="PNG")
|
| 78 |
byte_im = buf.getvalue()
|