Anustup commited on
Commit
1111c8d
·
verified ·
1 Parent(s): 139a792

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -50
app.py DELETED
@@ -1,50 +0,0 @@
1
- import os
2
- import streamlit as st
3
- from PIL import Image
4
-
5
-
6
- # Function to delete the image and its caption
7
- def delete_file(image_path):
8
- txt_path = os.path.splitext(image_path)[0] + '.txt'
9
- if os.path.exists(image_path):
10
- os.remove(image_path)
11
- if os.path.exists(txt_path):
12
- os.remove(txt_path)
13
- st.success(f"Deleted: {os.path.basename(image_path)} and {os.path.basename(txt_path)}")
14
-
15
-
16
- # Streamlit app
17
- def main():
18
- st.title("Image and Caption Viewer")
19
-
20
- # Input for folder path
21
- folder_path = st.text_input("Enter the path to your folder:", "")
22
-
23
- if folder_path:
24
- # Check if the folder exists
25
- if os.path.exists(folder_path):
26
- # List all image files in the folder
27
- image_files = [f for f in os.listdir(folder_path) if f.endswith(('.png', '.jpg', '.jpeg'))]
28
-
29
- if image_files:
30
- for image_file in image_files:
31
- image_path = os.path.join(folder_path, image_file)
32
-
33
- # Display the image
34
- image = Image.open(image_path)
35
- st.image(image, caption=image_file)
36
-
37
- # Display image resolution
38
- st.write(f"Resolution: {image.size}")
39
-
40
- # Delete button
41
- if st.button(f"Delete {image_file}", key=image_file):
42
- delete_file(image_path)
43
- else:
44
- st.warning("No image files found in the folder.")
45
- else:
46
- st.error("Folder path does not exist.")
47
-
48
-
49
- if __name__ == "__main__":
50
- main()