DHEIVER commited on
Commit
f8c0662
·
1 Parent(s): 246c955

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -23,8 +23,11 @@ def normalize_data(data):
23
  return df_test_value
24
 
25
  def plot_test_data(df_test_value):
26
- fig, ax = plt.subplots()
27
  df_test_value.plot(legend=False, ax=ax)
 
 
 
28
  return fig
29
 
30
  def get_anomalies(df_test_value):
@@ -48,9 +51,12 @@ def plot_anomalies(df_test_value, data, anomalies):
48
  if np.all(anomalies[data_idx - TIME_STEPS + 1 : data_idx]):
49
  anomalous_data_indices.append(data_idx)
50
  df_subset = data.iloc[anomalous_data_indices]
51
- fig, ax = plt.subplots()
52
  data.plot(legend=False, ax=ax)
53
  df_subset.plot(legend=False, ax=ax, color="r")
 
 
 
54
  return fig
55
 
56
  def master(file):
@@ -65,13 +71,13 @@ def master(file):
65
  plot2 = plot_anomalies(df_test_value, data, anomalies)
66
  return plot2
67
 
68
- outputs = gr.Plot()
69
 
70
-
71
- iface = gr.Interface(master,
72
- gr.inputs.File(label="csv file"),
73
- outputs=outputs,
74
- examples=["art_daily_jumpsup.csv"], title="Timeseries Anomaly Detection Using an Autoencoder",
75
  description = "Anomaly detection of timeseries data.",
76
  article = "Space by: <a href=\"https://www.linkedin.com/in/olohireme-ajayi/\">Reme Ajayi</a> <br> Keras Example by <a href=\"https://github.com/pavithrasv/\"> Pavithra Vijay</a>")
77
 
 
23
  return df_test_value
24
 
25
  def plot_test_data(df_test_value):
26
+ fig, ax = plt.subplots(figsize=(12, 6))
27
  df_test_value.plot(legend=False, ax=ax)
28
+ ax.set_xlabel("Time")
29
+ ax.set_ylabel("Value")
30
+ ax.set_title("Input Test Data")
31
  return fig
32
 
33
  def get_anomalies(df_test_value):
 
51
  if np.all(anomalies[data_idx - TIME_STEPS + 1 : data_idx]):
52
  anomalous_data_indices.append(data_idx)
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")
60
  return fig
61
 
62
  def master(file):
 
71
  plot2 = plot_anomalies(df_test_value, data, anomalies)
72
  return plot2
73
 
74
+ outputs = gr.outputs.Image()
75
 
76
+ iface = gr.Interface(
77
+ fn=master,
78
+ inputs=gr.inputs.File(label="CSV File"),
79
+ outputs=outputs,
80
+ examples=["art_daily_jumpsup.csv"], title="Timeseries Anomaly Detection Using an Autoencoder",
81
  description = "Anomaly detection of timeseries data.",
82
  article = "Space by: <a href=\"https://www.linkedin.com/in/olohireme-ajayi/\">Reme Ajayi</a> <br> Keras Example by <a href=\"https://github.com/pavithrasv/\"> Pavithra Vijay</a>")
83