subek commited on
Commit
1018e70
·
verified ·
1 Parent(s): eed1a3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -63,20 +63,22 @@ def show_image(image, title="Image"):
63
 
64
  # Function to download sample images
65
  def download_sample_images():
66
- sample_images_folder = "sample_images"
67
- sample_images = os.listdir(sample_images_folder)
68
 
69
  for image_name in sample_images:
70
- image_path = os.path.join(sample_images_folder, image_name)
71
- with open(image_path, "rb") as f:
72
- image_bytes = f.read()
73
- st.download_button(
74
- label=f"Download {image_name}",
75
- data=image_bytes,
76
- key=f"download_{image_name}",
77
- file_name=image_name,
78
- mime="image/jpeg",
79
- )
 
 
 
80
 
81
  # Streamlit app
82
  def main():
 
63
 
64
  # Function to download sample images
65
  def download_sample_images():
66
+ sample_images = ["sample_image1.jpg", "sample_image2.jpg", "sample_image3.jpg"] # Add the names of your sample images
 
67
 
68
  for image_name in sample_images:
69
+ image_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), image_name)
70
+ if os.path.exists(image_path):
71
+ with open(image_path, "rb") as f:
72
+ image_bytes = f.read()
73
+ st.download_button(
74
+ label=f"Download {image_name}",
75
+ data=image_bytes,
76
+ key=f"download_{image_name}",
77
+ file_name=image_name,
78
+ mime="image/jpeg",
79
+ )
80
+ else:
81
+ st.warning(f"Sample image {image_name} not found.")
82
 
83
  # Streamlit app
84
  def main():