Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,31 @@
|
|
| 1 |
"""Entry to launch gradio app."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from src.demo.gradio_utils import *
|
| 4 |
|
|
|
|
| 1 |
"""Entry to launch gradio app."""
|
| 2 |
+
import sys
|
| 3 |
+
import spaces
|
| 4 |
+
import torch
|
| 5 |
+
import importlib
|
| 6 |
+
import gradio as gr
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
# Walk around container build-up
|
| 10 |
+
package_name = "huggingface_hub"
|
| 11 |
+
required_version = "0.25.1"
|
| 12 |
+
try:
|
| 13 |
+
huggingface_hub = importlib.import_module(package_name)
|
| 14 |
+
if huggingface_hub.__version__ != required_version:
|
| 15 |
+
raise ImportError
|
| 16 |
+
except ImportError:
|
| 17 |
+
import subprocess
|
| 18 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", f"{package_name}=={required_version}"])
|
| 19 |
+
|
| 20 |
+
# Remove old version from memory
|
| 21 |
+
if package_name in sys.modules:
|
| 22 |
+
del sys.modules[package_name]
|
| 23 |
+
|
| 24 |
+
importlib.invalidate_caches()
|
| 25 |
+
huggingface_hub = importlib.import_module(package_name)
|
| 26 |
+
importlib.reload(huggingface_hub)
|
| 27 |
+
print(f"Now the `huggingface_hub` version is {huggingface_hub.__version__}")
|
| 28 |
+
|
| 29 |
import gradio as gr
|
| 30 |
from src.demo.gradio_utils import *
|
| 31 |
|