Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -4,17 +4,8 @@ import sys
|
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
import huggingface_hub as hf_hub
|
| 7 |
-
import gradio as gr
|
| 8 |
-
import torch
|
| 9 |
-
import numpy as np
|
| 10 |
-
import pandas as pd
|
| 11 |
-
from sklearn.manifold import TSNE
|
| 12 |
-
from sklearn.decomposition import PCA
|
| 13 |
-
from sklearn.preprocessing import StandardScaler
|
| 14 |
-
from sklearn.metrics import confusion_matrix, f1_score
|
| 15 |
-
import matplotlib.pyplot as plt
|
| 16 |
|
| 17 |
-
# Gradio
|
| 18 |
if not hasattr(hf_hub, "HfFolder"):
|
| 19 |
class _HfFolderShim:
|
| 20 |
@staticmethod
|
|
@@ -27,6 +18,16 @@ if not hasattr(hf_hub, "HfFolder"):
|
|
| 27 |
|
| 28 |
hf_hub.HfFolder = _HfFolderShim # type: ignore[attr-defined]
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
# Repo root for local imports
|
| 31 |
REPO_ROOT = Path(__file__).resolve().parent
|
| 32 |
if str(REPO_ROOT) not in sys.path:
|
|
|
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
import huggingface_hub as hf_hub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
# Gradio imports HfFolder; add shim before importing gradio.
|
| 9 |
if not hasattr(hf_hub, "HfFolder"):
|
| 10 |
class _HfFolderShim:
|
| 11 |
@staticmethod
|
|
|
|
| 18 |
|
| 19 |
hf_hub.HfFolder = _HfFolderShim # type: ignore[attr-defined]
|
| 20 |
|
| 21 |
+
import gradio as gr
|
| 22 |
+
import torch
|
| 23 |
+
import numpy as np
|
| 24 |
+
import pandas as pd
|
| 25 |
+
from sklearn.manifold import TSNE
|
| 26 |
+
from sklearn.decomposition import PCA
|
| 27 |
+
from sklearn.preprocessing import StandardScaler
|
| 28 |
+
from sklearn.metrics import confusion_matrix, f1_score
|
| 29 |
+
import matplotlib.pyplot as plt
|
| 30 |
+
|
| 31 |
# Repo root for local imports
|
| 32 |
REPO_ROOT = Path(__file__).resolve().parent
|
| 33 |
if str(REPO_ROOT) not in sys.path:
|