Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,37 @@
|
|
1 |
|
|
|
2 |
import os
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
import streamlit as st
|
13 |
import re
|
|
|
1 |
|
2 |
+
|
3 |
import os
|
4 |
+
import pkg_resources
|
5 |
+
|
6 |
+
def is_installed(package_name, version):
|
7 |
+
try:
|
8 |
+
pkg = pkg_resources.get_distribution(package_name)
|
9 |
+
return pkg.version == version
|
10 |
+
except pkg_resources.DistributionNotFound:
|
11 |
+
return False
|
12 |
+
|
13 |
+
@st.cache_resource
|
14 |
+
def install_packages():
|
15 |
+
install_commands = []
|
16 |
+
|
17 |
+
if not is_installed("spaces", "0.12.0"):
|
18 |
+
install_commands.append("pip install spaces==0.12.0")
|
19 |
+
|
20 |
+
if not is_installed("pydantic", "1.8.2"):
|
21 |
+
install_commands.append("pip install pydantic==1.8.2")
|
22 |
+
|
23 |
+
if install_commands:
|
24 |
+
os.system(" && ".join(install_commands))
|
25 |
+
|
26 |
+
# Call the function to install packages if necessary
|
27 |
+
install_packages()
|
28 |
+
|
29 |
+
# os.system("pip uninstall -y spaces")
|
30 |
+
# os.system('pip install spaces==0.12.0')
|
31 |
+
# os.system("pip uninstall -y gradio")
|
32 |
+
# os.system("pip uninstall -y inflect")
|
33 |
+
# os.system("pip uninstall -y pydantic")
|
34 |
+
# os.system('pip install pydantic==1.8.2')
|
35 |
|
36 |
import streamlit as st
|
37 |
import re
|