NayabShakeel commited on
Commit
e9ed3ed
·
verified ·
1 Parent(s): 92afe10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -3,18 +3,22 @@ import streamlit as st
3
  from PIL import Image, ImageEnhance
4
  import numpy as np
5
 
6
- # Check and ensure OpenCV (cv2) is installed
7
  try:
8
  import cv2
9
- except ModuleNotFoundError:
10
- st.warning("OpenCV not found. Attempting to install OpenCV headless...")
11
- os.system("pip uninstall opencv-python opencv-python-headless -y && pip install opencv-python-headless==4.8.0.74")
12
  try:
13
  import cv2
14
- except ModuleNotFoundError:
15
- st.error("Failed to install OpenCV. Please ensure 'opencv-python-headless' is in requirements.txt.")
16
  st.stop()
17
 
 
 
 
 
18
  # Title and Description
19
  st.title("Image Enhancer App")
20
  st.markdown("""
 
3
  from PIL import Image, ImageEnhance
4
  import numpy as np
5
 
6
+ # Check and ensure OpenCV (cv2) is installed with compatible NumPy
7
  try:
8
  import cv2
9
+ except ImportError:
10
+ st.warning("OpenCV not found or incompatible. Attempting to fix...")
11
+ os.system("pip install numpy==1.24.3 opencv-python-headless==4.8.0.74")
12
  try:
13
  import cv2
14
+ except ImportError:
15
+ st.error("Failed to fix OpenCV installation. Check requirements.txt for compatibility.")
16
  st.stop()
17
 
18
+ # Verify Versions
19
+ st.sidebar.write(f"OpenCV Version: {cv2.__version__}")
20
+ st.sidebar.write(f"NumPy Version: {np.__version__}")
21
+
22
  # Title and Description
23
  st.title("Image Enhancer App")
24
  st.markdown("""