Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,7 +53,7 @@ def plot_anomalies(df_test_value, data, anomalies):
|
|
| 53 |
df_subset = data.iloc[anomalous_data_indices]
|
| 54 |
fig, ax = plt.subplots(figsize=(12, 6))
|
| 55 |
data.plot(legend=False, ax=ax)
|
| 56 |
-
df_subset.plot(legend=False, ax=ax, color="r"
|
| 57 |
ax.set_xlabel("Time")
|
| 58 |
ax.set_ylabel("Value")
|
| 59 |
ax.set_title("Anomalous Data Points")
|
|
@@ -65,24 +65,13 @@ def master(file):
|
|
| 65 |
df_test_value = normalize_data(data)
|
| 66 |
# plot input test data
|
| 67 |
plot1 = plot_test_data(df_test_value)
|
| 68 |
-
|
| 69 |
-
# Update Gradio interface to show progress message
|
| 70 |
-
iface.set_interface_inline("""
|
| 71 |
-
<div style="text-align: center;">
|
| 72 |
-
<h3>Anomaly detection in progress...</h3>
|
| 73 |
-
</div>
|
| 74 |
-
""")
|
| 75 |
-
|
| 76 |
# predict
|
| 77 |
anomalies = get_anomalies(df_test_value)
|
| 78 |
-
|
| 79 |
# plot anomalous data points
|
| 80 |
plot2, anomalous_indices = plot_anomalies(df_test_value, data, anomalies)
|
| 81 |
-
|
| 82 |
-
# Update Gradio interface to show the resulting plot
|
| 83 |
return plot2, anomalous_indices
|
| 84 |
|
| 85 |
-
outputs = gr.outputs.Image()
|
| 86 |
|
| 87 |
iface = gr.Interface(
|
| 88 |
fn=master,
|
|
@@ -93,5 +82,5 @@ iface = gr.Interface(
|
|
| 93 |
description="Anomaly detection of timeseries data."
|
| 94 |
)
|
| 95 |
|
|
|
|
| 96 |
iface.launch()
|
| 97 |
-
|
|
|
|
| 53 |
df_subset = data.iloc[anomalous_data_indices]
|
| 54 |
fig, ax = plt.subplots(figsize=(12, 6))
|
| 55 |
data.plot(legend=False, ax=ax)
|
| 56 |
+
df_subset.plot(legend=False, ax=ax, color="r")
|
| 57 |
ax.set_xlabel("Time")
|
| 58 |
ax.set_ylabel("Value")
|
| 59 |
ax.set_title("Anomalous Data Points")
|
|
|
|
| 65 |
df_test_value = normalize_data(data)
|
| 66 |
# plot input test data
|
| 67 |
plot1 = plot_test_data(df_test_value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
# predict
|
| 69 |
anomalies = get_anomalies(df_test_value)
|
|
|
|
| 70 |
# plot anomalous data points
|
| 71 |
plot2, anomalous_indices = plot_anomalies(df_test_value, data, anomalies)
|
|
|
|
|
|
|
| 72 |
return plot2, anomalous_indices
|
| 73 |
|
| 74 |
+
outputs = [gr.outputs.Image(), "text"]
|
| 75 |
|
| 76 |
iface = gr.Interface(
|
| 77 |
fn=master,
|
|
|
|
| 82 |
description="Anomaly detection of timeseries data."
|
| 83 |
)
|
| 84 |
|
| 85 |
+
# Display the interface
|
| 86 |
iface.launch()
|
|
|