Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,18 +9,17 @@ def install(package):
|
|
9 |
try:
|
10 |
import numpy as np
|
11 |
import pandas as pd
|
12 |
-
if not (np.__version__.startswith("1.
|
13 |
-
print(f"Detected incompatible versions. Reinstalling NumPy
|
14 |
-
install("numpy==1.
|
15 |
-
install("pandas==1.5.3")
|
16 |
except ImportError:
|
17 |
print("NumPy or pandas not found. Installing compatible versions...")
|
18 |
-
install("numpy==1.
|
19 |
-
install("pandas==1.5.3")
|
20 |
|
21 |
-
# Ensure other dependencies are installed
|
22 |
try:
|
23 |
import torch
|
|
|
24 |
except ImportError:
|
25 |
install("torch==2.0.1")
|
26 |
install("torchvision==0.15.2")
|
@@ -30,6 +29,11 @@ try:
|
|
30 |
except ImportError:
|
31 |
install("Pillow==9.5.0")
|
32 |
|
|
|
|
|
|
|
|
|
|
|
33 |
# Import libraries after ensuring installations
|
34 |
import torch
|
35 |
import torch.nn as nn
|
@@ -94,4 +98,4 @@ interface = gr.Interface(
|
|
94 |
|
95 |
# Launch the interface
|
96 |
if __name__ == "__main__":
|
97 |
-
interface.launch(
|
|
|
9 |
try:
|
10 |
import numpy as np
|
11 |
import pandas as pd
|
12 |
+
if not (np.__version__.startswith("1.24")):
|
13 |
+
print(f"Detected incompatible versions. Reinstalling NumPy...")
|
14 |
+
install("numpy==1.24.3")
|
|
|
15 |
except ImportError:
|
16 |
print("NumPy or pandas not found. Installing compatible versions...")
|
17 |
+
install("numpy==1.24.3")
|
|
|
18 |
|
19 |
+
# Ensure other dependencies are installed with specific versions
|
20 |
try:
|
21 |
import torch
|
22 |
+
import torchvision
|
23 |
except ImportError:
|
24 |
install("torch==2.0.1")
|
25 |
install("torchvision==0.15.2")
|
|
|
29 |
except ImportError:
|
30 |
install("Pillow==9.5.0")
|
31 |
|
32 |
+
try:
|
33 |
+
import gradio as gr
|
34 |
+
except ImportError:
|
35 |
+
install("gradio==3.50.2")
|
36 |
+
|
37 |
# Import libraries after ensuring installations
|
38 |
import torch
|
39 |
import torch.nn as nn
|
|
|
98 |
|
99 |
# Launch the interface
|
100 |
if __name__ == "__main__":
|
101 |
+
interface.launch() # Removed share=True for Hugging Face Spaces
|