EngrNarmeen commited on
Commit
19daa99
·
verified ·
1 Parent(s): e8db9b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -4,15 +4,15 @@ from PIL import Image
4
  import io
5
 
6
  # Streamlit App Title
7
- st.title("Picture Background Remover")
8
- st.write("Upload an image, and this tool will remove its background.")
9
 
10
  # File Uploader
11
- uploaded_file = st.file_uploader("Upload an image (PNG or JPG):", type=["png", "jpg", "jpeg"])
12
 
13
  if uploaded_file is not None:
14
  # Display Original Image
15
- original_image = Image.open(uploaded_file)
16
  st.subheader("Original Image")
17
  st.image(original_image, use_column_width=True)
18
 
@@ -23,10 +23,10 @@ if uploaded_file is not None:
23
  input_bytes = input_bytes.getvalue()
24
 
25
  output_bytes = remove(input_bytes)
26
- output_image = Image.open(io.BytesIO(output_bytes))
27
 
28
  # Display Image Without Background
29
- st.subheader("Image Without Background")
30
  st.image(output_image, use_column_width=True)
31
 
32
  # Download Button
@@ -35,8 +35,8 @@ if uploaded_file is not None:
35
  output_buffer.seek(0)
36
 
37
  st.download_button(
38
- label="Download Image Without Background",
39
  data=output_buffer,
40
- file_name="output.png",
41
  mime="image/png",
42
  )
 
4
  import io
5
 
6
  # Streamlit App Title
7
+ st.title("HD Picture Background Remover")
8
+ st.write("Upload an HD image, and this tool will remove its background while retaining high quality.")
9
 
10
  # File Uploader
11
+ uploaded_file = st.file_uploader("Upload an HD image (PNG or JPG):", type=["png", "jpg", "jpeg"])
12
 
13
  if uploaded_file is not None:
14
  # Display Original Image
15
+ original_image = Image.open(uploaded_file).convert("RGBA") # Ensure transparency support
16
  st.subheader("Original Image")
17
  st.image(original_image, use_column_width=True)
18
 
 
23
  input_bytes = input_bytes.getvalue()
24
 
25
  output_bytes = remove(input_bytes)
26
+ output_image = Image.open(io.BytesIO(output_bytes)).convert("RGBA")
27
 
28
  # Display Image Without Background
29
+ st.subheader("Image Without Background (HD Quality)")
30
  st.image(output_image, use_column_width=True)
31
 
32
  # Download Button
 
35
  output_buffer.seek(0)
36
 
37
  st.download_button(
38
+ label="Download HD Image Without Background",
39
  data=output_buffer,
40
+ file_name="output_hd.png",
41
  mime="image/png",
42
  )