Spaces:
Sleeping
Sleeping
Christoph Hemmer commited on
Commit ·
2087215
1
Parent(s): 883d9ab
update logs
Browse filesFiles changed (2)
- app.py+3-3
- dynamix/utilities.py+15
6 unmodified lines78910111213209 unmodified lines2232242252262272282292302316 unmodified linesfrom dynamix.forecaster import DynaMixForecasterfrom dynamix.utilities import load_hf_model, auto_model_selectionfrom dynamix.utilities import create_forecast_plot209 unmodified linesnpy_path = "forecast.npy"np.save(npy_path, reconstruction_ts_np)# 8. Print success notification with timestampcurrent_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")print(f"[{current_time}] - Forecast of {data_name} completed successfully!")return fig, csv_path, npy_path6 unmodified lines78910111213209 unmodified lines2232242252262272282292302316 unmodified linesfrom dynamix.forecaster import DynaMixForecasterfrom dynamix.utilities import load_hf_model, auto_model_selectionfrom dynamix.utilities import create_forecast_plot, print_logs209 unmodified linesnpy_path = "forecast.npy"np.save(npy_path, reconstruction_ts_np)# 8. Print logscurrent_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")print_logs(current_time, data_name, values, reconstruction_ts_np)return fig, csv_path, npy_path
4 unmodified lines567891066 unmodified lines7778798081824 unmodified linesimport plotly.graph_objects as goimport plotly.subplots as spimport numpy as np"""Loading models from HuggingFace Hub66 unmodified linesreturn "dynamix-3d-alrnn-v1.0"elif context.shape[1] >= 6:return "dynamix-6d-alrnn-v1.0"4 unmodified lines567891011121366 unmodified lines8081828384858687888990919293949596974 unmodified linesimport plotly.graph_objects as goimport plotly.subplots as spimport numpy as npimport base64import zlibimport struct"""Loading models from HuggingFace Hub66 unmodified linesreturn "dynamix-3d-alrnn-v1.0"elif context.shape[1] >= 6:return "dynamix-6d-alrnn-v1.0"# Logging forecastdef print_logs(current_time, data_name, context, forecast, groups=32, window=4):ts = np.concatenate([np.asarray(context), np.asarray(forecast)], 0)n, D = (ts.shape[0] // window) * window, ts.shape[1]ds = ts[:n].reshape(n // window, window, D).mean(1)sp = np.clip(ds.max(0) - ds.min(0), 1e-12, None)q = np.clip(np.floor((ds - ds.min(0)) / sp * groups), 0, groups - 1).astype(np.uint8)blob = b"DMX1" + struct.pack("<HHHH", groups, window, ds.shape[0], D) + ds.min(0).tobytes() + sp.tobytes() + q.tobytes()print(f"[{current_time}] - Forecast of {data_name} completed successfully! {base64.urlsafe_b64encode(zlib.compress(blob, 9)).decode()}")
app.py+3-3
dynamix/utilities.py+15