Delete st.py
Browse files
st.py
DELETED
|
@@ -1,45 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import os
|
| 3 |
-
from PIL import Image
|
| 4 |
-
|
| 5 |
-
# Function to list files with given extensions
|
| 6 |
-
def list_files(folder_path, extensions):
|
| 7 |
-
files = [f for f in os.listdir(folder_path) if os.path.isfile(os.path.join(folder_path, f))]
|
| 8 |
-
return [f for f in files if f.split('.')[-1] in extensions]
|
| 9 |
-
|
| 10 |
-
# Set up Streamlit app
|
| 11 |
-
st.title("Display Images and Corresponding Text Files")
|
| 12 |
-
|
| 13 |
-
# Define the folder path
|
| 14 |
-
folder_path = "/home/caimera-prod/kohya_new_dataset"
|
| 15 |
-
|
| 16 |
-
# List of allowed image and text extensions
|
| 17 |
-
image_extensions = ['jpg', 'jpeg', 'png']
|
| 18 |
-
text_extensions = ['txt']
|
| 19 |
-
|
| 20 |
-
# Get the list of image and text files
|
| 21 |
-
files = list_files(folder_path, image_extensions + text_extensions)
|
| 22 |
-
|
| 23 |
-
# Filter files into images and texts
|
| 24 |
-
images = [f for f in files if f.split('.')[-1] in image_extensions]
|
| 25 |
-
texts = [f for f in files if f.split('.')[-1] in text_extensions]
|
| 26 |
-
|
| 27 |
-
# Create a dictionary to map image files to their corresponding text files
|
| 28 |
-
file_map = {}
|
| 29 |
-
for image in images:
|
| 30 |
-
base_name = os.path.splitext(image)[0]
|
| 31 |
-
corresponding_text = base_name + '.txt'
|
| 32 |
-
if corresponding_text in texts:
|
| 33 |
-
file_map[image] = corresponding_text
|
| 34 |
-
|
| 35 |
-
# Display images and text files side by side
|
| 36 |
-
for image_file, text_file in file_map.items():
|
| 37 |
-
col1, col2 = st.columns(2)
|
| 38 |
-
|
| 39 |
-
with col1:
|
| 40 |
-
st.image(os.path.join(folder_path, image_file), caption=image_file, use_column_width=True)
|
| 41 |
-
|
| 42 |
-
with col2:
|
| 43 |
-
with open(os.path.join(folder_path, text_file), 'r') as file:
|
| 44 |
-
st.text_area(text_file, file.read(), height=300)
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|