Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,8 @@ import matplotlib.gridspec as gridspec
|
|
| 15 |
import seaborn as sns
|
| 16 |
import io
|
| 17 |
import gradio as gr
|
|
|
|
|
|
|
| 18 |
|
| 19 |
from statsmodels.tsa.stattools import adfuller
|
| 20 |
from statsmodels.tsa.arima.model import ARIMA
|
|
@@ -168,13 +170,13 @@ def detect_anomalies(actual, fitted, k=2.5):
|
|
| 168 |
# ─────────────────────────────────────────────
|
| 169 |
# PLOT HELPERS
|
| 170 |
# ─────────────────────────────────────────────
|
|
|
|
| 171 |
def _fig_to_pil(fig):
|
| 172 |
-
"""
|
| 173 |
-
|
| 174 |
-
fig.savefig(
|
| 175 |
facecolor=fig.get_facecolor())
|
| 176 |
-
|
| 177 |
-
return buf
|
| 178 |
|
| 179 |
|
| 180 |
def plot_overview(df):
|
|
|
|
| 15 |
import seaborn as sns
|
| 16 |
import io
|
| 17 |
import gradio as gr
|
| 18 |
+
import tempfile
|
| 19 |
+
|
| 20 |
|
| 21 |
from statsmodels.tsa.stattools import adfuller
|
| 22 |
from statsmodels.tsa.arima.model import ARIMA
|
|
|
|
| 170 |
# ─────────────────────────────────────────────
|
| 171 |
# PLOT HELPERS
|
| 172 |
# ─────────────────────────────────────────────
|
| 173 |
+
|
| 174 |
def _fig_to_pil(fig):
|
| 175 |
+
"""Save matplotlib figure to temp file and return filepath (Gradio-compatible)."""
|
| 176 |
+
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".png")
|
| 177 |
+
fig.savefig(tmp.name, dpi=130, bbox_inches="tight",
|
| 178 |
facecolor=fig.get_facecolor())
|
| 179 |
+
return tmp.name
|
|
|
|
| 180 |
|
| 181 |
|
| 182 |
def plot_overview(df):
|