yolac commited on
Commit
884fb83
·
verified ·
1 Parent(s): 90f9e66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -41,17 +41,20 @@ st.markdown(
41
  "This app classifies bacterial morphology into **Cocci**, **Bacilli**, or **Spirilla** using a fine-tuned PyTorch model."
42
  )
43
 
44
- # Example Images
45
  st.subheader("Example Images")
46
- example_images = [
47
- "https://huggingface.co/datasets/yolac/BacterialMorphologyClassification/resolve/main/img%20290.jpg", # Replace with actual paths to example images
48
  "https://huggingface.co/datasets/yolac/BacterialMorphologyClassification/resolve/main/img%20565.jpg",
49
  "https://huggingface.co/datasets/yolac/BacterialMorphologyClassification/resolve/main/img%208.jpg"
50
  ]
51
 
52
- for img_path in example_images:
53
- img = Image.open(img_path).convert("RGB")
54
- st.image(img, caption=f"Example Image: {img_path}", use_column_width=True)
 
 
 
55
 
56
  # File Upload
57
  uploaded_file = st.file_uploader("Upload a bacterial image for classification:", type=["jpg", "jpeg", "png"])
 
41
  "This app classifies bacterial morphology into **Cocci**, **Bacilli**, or **Spirilla** using a fine-tuned PyTorch model."
42
  )
43
 
44
+ # Display example images from local files
45
  st.subheader("Example Images")
46
+ example_image_paths = [
47
+ "https://huggingface.co/datasets/yolac/BacterialMorphologyClassification/resolve/main/img%20290.jpg",
48
  "https://huggingface.co/datasets/yolac/BacterialMorphologyClassification/resolve/main/img%20565.jpg",
49
  "https://huggingface.co/datasets/yolac/BacterialMorphologyClassification/resolve/main/img%208.jpg"
50
  ]
51
 
52
+ for img_path in example_image_paths:
53
+ try:
54
+ img = Image.open(img_path).convert("RGB")
55
+ st.image(img, caption=f"Example Image: {img_path}", use_column_width=True)
56
+ except FileNotFoundError:
57
+ st.error(f"Example image {img_path} not found. Please ensure the image exists in the app directory.")
58
 
59
  # File Upload
60
  uploaded_file = st.file_uploader("Upload a bacterial image for classification:", type=["jpg", "jpeg", "png"])