JEPHONETORRE commited on
Commit
25cfe8d
·
1 Parent(s): c8760db
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -134,8 +134,8 @@ def main():
134
 
135
  for uploaded_file in uploaded_files:
136
  try:
137
- st.image(uploaded_file, caption=f"Uploaded Image: {uploaded_file.name}", use_container_width=True)
138
  file_path = save_uploaded_image(uploaded_file)
 
139
 
140
  prediction = classify_image(file_path)
141
  results[file_path] = prediction
@@ -160,8 +160,8 @@ def main():
160
 
161
  for training_file in training_files:
162
  try:
163
- st.image(training_file, caption=f"Uploaded Training Image: {training_file.name}", use_container_width=True)
164
  file_path = save_uploaded_image(training_file)
 
165
 
166
  label = st.radio(
167
  f"Classify {training_file.name}", ["Human", "Alien"], index=0, key=training_file.name
@@ -203,10 +203,10 @@ def main():
203
  if human_images:
204
  st.info("These images have already been trained.")
205
  for image_path in human_images:
206
- try:
207
- st.image(image_path, caption=f"Image: {os.path.basename(image_path)}", use_container_width=True)
208
- except Exception as e:
209
- st.error(f"Error displaying image {os.path.basename(image_path)}: {e}")
210
  else:
211
  st.warning("No human images found for training.")
212
 
@@ -219,10 +219,10 @@ def main():
219
  if alien_images:
220
  st.info("These images have already been trained.")
221
  for image_path in alien_images:
222
- try:
223
- st.image(image_path, caption=f"Image: {os.path.basename(image_path)}", use_container_width=True)
224
- except Exception as e:
225
- st.error(f"Error displaying image {os.path.basename(image_path)}: {e}")
226
  else:
227
  st.warning("No alien images found for training.")
228
 
 
134
 
135
  for uploaded_file in uploaded_files:
136
  try:
 
137
  file_path = save_uploaded_image(uploaded_file)
138
+ st.image(file_path, caption=f"Uploaded Image: {uploaded_file.name}", use_column_width=True)
139
 
140
  prediction = classify_image(file_path)
141
  results[file_path] = prediction
 
160
 
161
  for training_file in training_files:
162
  try:
 
163
  file_path = save_uploaded_image(training_file)
164
+ st.image(file_path, caption=f"Uploaded Training Image: {training_file.name}", use_column_width=True)
165
 
166
  label = st.radio(
167
  f"Classify {training_file.name}", ["Human", "Alien"], index=0, key=training_file.name
 
203
  if human_images:
204
  st.info("These images have already been trained.")
205
  for image_path in human_images:
206
+ if os.path.exists(image_path):
207
+ st.image(image_path, caption=f"Image: {os.path.basename(image_path)}", use_column_width=True)
208
+ else:
209
+ st.error(f"File not found: {os.path.basename(image_path)}")
210
  else:
211
  st.warning("No human images found for training.")
212
 
 
219
  if alien_images:
220
  st.info("These images have already been trained.")
221
  for image_path in alien_images:
222
+ if os.path.exists(image_path):
223
+ st.image(image_path, caption=f"Image: {os.path.basename(image_path)}", use_column_width=True)
224
+ else:
225
+ st.error(f"File not found: {os.path.basename(image_path)}")
226
  else:
227
  st.warning("No alien images found for training.")
228