ginipick commited on
Commit
2c6ea0f
·
verified ·
1 Parent(s): 7e2d78a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -1,3 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import torch
3
  from transformers import AutoModelForCausalLM, AutoTokenizer
 
1
+ import sys
2
+ import subprocess
3
+
4
+ # Try to import OpenCV; if not available, install it
5
+ try:
6
+ import cv2
7
+ print("OpenCV already installed.")
8
+ except ImportError:
9
+ print("OpenCV not found. Installing opencv-python-headless...")
10
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "opencv-python-headless"])
11
+ try:
12
+ import cv2
13
+ print("OpenCV successfully installed.")
14
+ except ImportError:
15
+ print("Failed to install OpenCV. Continuing without it...")
16
+
17
  import gradio as gr
18
  import torch
19
  from transformers import AutoModelForCausalLM, AutoTokenizer