sdafd commited on
Commit
e471491
·
verified ·
1 Parent(s): 99d22e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -19,6 +19,7 @@ async def predict(model: UploadFile = File(...), data: str = None):
19
 
20
  # Load the model
21
  model = load_model(temp_model_path, compile=False)
 
22
 
23
  # Process the data
24
  data = np.array(eval(data)).reshape(1, 12, 1)
@@ -37,12 +38,11 @@ async def retrain(model: UploadFile = File(...), data: str = None):
37
  temp_model_file.write(await model.read())
38
  temp_model_path = temp_model_file.name
39
 
40
- with tempfile.NamedTemporaryFile(delete=False, suffix=".npy") as temp_data_file:
41
- temp_data_file.write(await data.read())
42
- temp_data_path = temp_data_file.name
43
 
44
  # Load the model and data
45
  model = load_model(temp_model_path, compile=False)
 
 
46
  dataset = np.array(eval(data)).reshape(1, 12, 1)
47
 
48
  # Normalize the data
@@ -60,7 +60,7 @@ async def retrain(model: UploadFile = File(...), data: str = None):
60
  y_train = np.array(y_train)
61
 
62
  model.compile(optimizer=Adam(learning_rate=0.001), loss="mse", run_eagerly=True)
63
- model.fit(x_train, y_train, epochs=10, batch_size=32)
64
 
65
  # Save the updated model to a temporary file
66
  updated_model_path = temp_model_path.replace(".h5", "_updated.h5")
 
19
 
20
  # Load the model
21
  model = load_model(temp_model_path, compile=False)
22
+ model.compile(optimizer=Adam(learning_rate=0.001), loss='mse', run_eagerly=True)
23
 
24
  # Process the data
25
  data = np.array(eval(data)).reshape(1, 12, 1)
 
38
  temp_model_file.write(await model.read())
39
  temp_model_path = temp_model_file.name
40
 
 
 
 
41
 
42
  # Load the model and data
43
  model = load_model(temp_model_path, compile=False)
44
+ model.compile(optimizer=Adam(learning_rate=0.001), loss='mse', run_eagerly=True)
45
+
46
  dataset = np.array(eval(data)).reshape(1, 12, 1)
47
 
48
  # Normalize the data
 
60
  y_train = np.array(y_train)
61
 
62
  model.compile(optimizer=Adam(learning_rate=0.001), loss="mse", run_eagerly=True)
63
+ model.fit(x_train, y_train, epochs=1, batch_size=32)
64
 
65
  # Save the updated model to a temporary file
66
  updated_model_path = temp_model_path.replace(".h5", "_updated.h5")