awacke1 commited on
Commit
0b0f7c9
·
1 Parent(s): 0f25660

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -38
app.py CHANGED
@@ -37,42 +37,6 @@ 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
- # cut--
41
-
42
- def remove_duplicates_csv(file_path):
43
- with open(file_path, mode='r') as f:
44
- rows = list(csv.reader(f))
45
- unique_rows = list(set(tuple(row) for row in rows))
46
-
47
- with open(file_path, mode='w', newline='') as f:
48
- writer = csv.writer(f)
49
- for row in unique_rows:
50
- writer.writerow(row)
51
-
52
- csv_file_path = "Resources.csv"
53
-
54
- if not os.path.exists(csv_file_path):
55
- with open(csv_file_path, mode='w', newline='') as f:
56
- writer = csv.writer(f)
57
- writer.writerow(['Name', 'File Name', 'Image Type'])
58
-
59
- remove_duplicates_csv(csv_file_path)
60
-
61
- with open(csv_file_path, mode='r') as f:
62
- rows = list(csv.reader(f))
63
-
64
- if rows:
65
- headers = ["Name", "File Name", "Image Type"]
66
- rows.insert(0, headers)
67
- table = "|".join(headers) + "|\n"
68
- table += "|".join(['---'] * len(headers)) + "|\n"
69
- for row in rows[1:]:
70
- table += "|".join(row) + "|\n"
71
- st.markdown(table)
72
- else:
73
- st.write("No files found.")
74
- # cut --
75
-
76
  image_type = st.selectbox('Choose image type:', options=['characters', 'terrain'])
77
  name = st.text_input('Enter a name for the image:')
78
  uploaded_files = st.file_uploader('Upload image(s)', type=['png', 'jpg'], accept_multiple_files=True)
@@ -108,5 +72,4 @@ else:
108
  while True:
109
  time.sleep(20)
110
  st.empty()
111
- remove_duplicates_csv(csv_file_path)
112
- 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
  while True:
73
  time.sleep(20)
74
  st.empty()
75
+ display_images_from_csv()