NahuelCosta commited on
Commit
354059a
1 Parent(s): e23681c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -5,8 +5,8 @@ import matplotlib.pyplot as plt
5
  from matplotlib import cm
6
  from PIL import Image
7
  import pandas as pd
8
- from dtaidistance import dtw
9
-
10
  def getDTWImage(IC_reference, sample, size):
11
  d, paths = dtw.warping_paths(IC_reference, sample, window=int(size/2), psi=2)
12
  x = np.array(paths)
@@ -19,9 +19,10 @@ def getDTWImage(IC_reference, sample, size):
19
  # reshape the array
20
  x = np.expand_dims(x, -1).astype("float32")
21
  return x
22
-
23
- data = np.load('./data_LFP.npy')
24
- model = tf.keras.models.load_model('./models/model-bestLFP_V2.h5',compile = False)
 
25
 
26
  def predict(Cell_number, Duty_Cycle, Cycle_number):
27
  # ------------------------ Prediction ------------------------
@@ -33,7 +34,7 @@ def predict(Cell_number, Duty_Cycle, Cycle_number):
33
 
34
  IC_reference = data[0][0]
35
  sample = data[Duty_Cycle-1][cycle]
36
- sample_DTW = getDTWImage(IC_reference, sample, size)
37
  prediction = model.predict(np.expand_dims(sample_DTW, axis=0))
38
  pred = {"LLI ": str(prediction[0][0]), "LAMPE ": str(prediction[0][1]), "LAMNE ": str(prediction[0][2])}
39
 
 
5
  from matplotlib import cm
6
  from PIL import Image
7
  import pandas as pd
8
+ #from dtaidistance import dtw
9
+ '''
10
  def getDTWImage(IC_reference, sample, size):
11
  d, paths = dtw.warping_paths(IC_reference, sample, window=int(size/2), psi=2)
12
  x = np.array(paths)
 
19
  # reshape the array
20
  x = np.expand_dims(x, -1).astype("float32")
21
  return x
22
+ '''
23
+ data = np.load('./data.npy')
24
+ data_DTW = np.load('./data/data_DTW.npy')
25
+ model = tf.keras.models.load_model('./models/model.h5',compile = False)
26
 
27
  def predict(Cell_number, Duty_Cycle, Cycle_number):
28
  # ------------------------ Prediction ------------------------
 
34
 
35
  IC_reference = data[0][0]
36
  sample = data[Duty_Cycle-1][cycle]
37
+ sample_DTW = data_DTW[Duty_Cycle-1][cycle] #getDTWImage(IC_reference, sample, size)
38
  prediction = model.predict(np.expand_dims(sample_DTW, axis=0))
39
  pred = {"LLI ": str(prediction[0][0]), "LAMPE ": str(prediction[0][1]), "LAMNE ": str(prediction[0][2])}
40