Update app.py
Browse files
app.py
CHANGED
|
@@ -6,22 +6,22 @@ Arquivo único para Hugging Face Spaces (sem imports locais)
|
|
| 6 |
|
| 7 |
import subprocess, sys, os
|
| 8 |
|
| 9 |
-
def _install(
|
| 10 |
-
subprocess.check_call([sys.executable, "-m", "pip", "install",
|
| 11 |
"-q", "--root-user-action=ignore"])
|
| 12 |
|
| 13 |
# Instala dependências que podem estar faltando no container
|
| 14 |
_deps = {
|
| 15 |
-
"torch":
|
| 16 |
-
"plotly":
|
| 17 |
-
"sklearn":
|
| 18 |
}
|
| 19 |
-
for _mod,
|
| 20 |
try:
|
| 21 |
__import__(_mod)
|
| 22 |
except ImportError:
|
| 23 |
-
print(f"Installing {
|
| 24 |
-
_install(
|
| 25 |
|
| 26 |
import gradio as gr
|
| 27 |
import pandas as pd
|
|
|
|
| 6 |
|
| 7 |
import subprocess, sys, os
|
| 8 |
|
| 9 |
+
def _install(*args):
|
| 10 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", *args,
|
| 11 |
"-q", "--root-user-action=ignore"])
|
| 12 |
|
| 13 |
# Instala dependências que podem estar faltando no container
|
| 14 |
_deps = {
|
| 15 |
+
"torch": ["torch", "--index-url", "https://download.pytorch.org/whl/cpu"],
|
| 16 |
+
"plotly": ["plotly"],
|
| 17 |
+
"sklearn": ["scikit-learn"],
|
| 18 |
}
|
| 19 |
+
for _mod, _args in _deps.items():
|
| 20 |
try:
|
| 21 |
__import__(_mod)
|
| 22 |
except ImportError:
|
| 23 |
+
print(f"Installing {_args[0]}...", flush=True)
|
| 24 |
+
_install(*_args)
|
| 25 |
|
| 26 |
import gradio as gr
|
| 27 |
import pandas as pd
|