Update app.py
Browse files
app.py
CHANGED
@@ -37,6 +37,38 @@ def display_images_from_csv():
|
|
37 |
img_path = f"data/uploadedImages/{row[2]}/{row[0]}/{row[1]}"
|
38 |
st.image(img_path, width=100, caption=row[0])
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
image_type = st.selectbox('Choose image type:', options=['characters', 'terrain'])
|
41 |
name = st.text_input('Enter a name for the image:')
|
42 |
uploaded_files = st.file_uploader('Upload image(s)', type=['png', 'jpg'], accept_multiple_files=True)
|
@@ -72,4 +104,5 @@ else:
|
|
72 |
while True:
|
73 |
time.sleep(20)
|
74 |
st.empty()
|
|
|
75 |
display_images_from_csv()
|
|
|
37 |
img_path = f"data/uploadedImages/{row[2]}/{row[0]}/{row[1]}"
|
38 |
st.image(img_path, width=100, caption=row[0])
|
39 |
|
40 |
+
# cut--
|
41 |
+
import streamlit as st
|
42 |
+
import csv
|
43 |
+
|
44 |
+
def remove_duplicates_csv(file_path):
|
45 |
+
with open(file_path, mode='r') as f:
|
46 |
+
rows = list(csv.reader(f))
|
47 |
+
unique_rows = list(set(tuple(row) for row in rows))
|
48 |
+
|
49 |
+
with open(file_path, mode='w', newline='') as f:
|
50 |
+
writer = csv.writer(f)
|
51 |
+
for row in unique_rows:
|
52 |
+
writer.writerow(row)
|
53 |
+
|
54 |
+
csv_file_path = "Resources.csv"
|
55 |
+
remove_duplicates_csv(csv_file_path)
|
56 |
+
|
57 |
+
with open(csv_file_path, mode='r') as f:
|
58 |
+
rows = list(csv.reader(f))
|
59 |
+
|
60 |
+
if rows:
|
61 |
+
headers = ["Name", "File Name", "Image Type"]
|
62 |
+
rows.insert(0, headers)
|
63 |
+
table = "|".join(headers) + "|\n"
|
64 |
+
table += "|".join(['---'] * len(headers)) + "|\n"
|
65 |
+
for row in rows[1:]:
|
66 |
+
table += "|".join(row) + "|\n"
|
67 |
+
st.markdown(table)
|
68 |
+
else:
|
69 |
+
st.write("No files found.")
|
70 |
+
# cut --
|
71 |
+
|
72 |
image_type = st.selectbox('Choose image type:', options=['characters', 'terrain'])
|
73 |
name = st.text_input('Enter a name for the image:')
|
74 |
uploaded_files = st.file_uploader('Upload image(s)', type=['png', 'jpg'], accept_multiple_files=True)
|
|
|
104 |
while True:
|
105 |
time.sleep(20)
|
106 |
st.empty()
|
107 |
+
remove_duplicates_csv(csv_file_path)
|
108 |
display_images_from_csv()
|