louiecerv commited on
Commit
1f68d20
·
1 Parent(s): 7ee901b

sync with remote

Browse files
app.py CHANGED
@@ -8,6 +8,8 @@ from tensorflow.keras.models import Sequential
8
  from tensorflow.keras.layers import Flatten, Dense, Reshape
9
  from tensorflow.keras.losses import SparseCategoricalCrossentropy
10
  from io import StringIO
 
 
11
 
12
  # Constants for dataset information
13
  TRAIN_FILE = "train_images.tfrecords"
@@ -127,6 +129,12 @@ def show_predictions(dataset=None, num=1):
127
  prediction = create_mask(model.predict(sample_image[tf.newaxis, ...]))
128
  display([sample_image, sample_label, prediction])
129
 
 
 
 
 
 
 
130
  # Streamlit app interface
131
  st.title("Cardiac Images Dataset")
132
 
@@ -170,4 +178,20 @@ st.title("Model Architecture")
170
  st.image(plot_filename, caption="Neural Network Architecture", use_container_width=True)
171
 
172
  # show a predection, as an example
173
- show_predictions(test_dataset)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  from tensorflow.keras.layers import Flatten, Dense, Reshape
9
  from tensorflow.keras.losses import SparseCategoricalCrossentropy
10
  from io import StringIO
11
+ import datetime
12
+
13
 
14
  # Constants for dataset information
15
  TRAIN_FILE = "train_images.tfrecords"
 
129
  prediction = create_mask(model.predict(sample_image[tf.newaxis, ...]))
130
  display([sample_image, sample_label, prediction])
131
 
132
+ # define a callback that shows image predictions on the test set
133
+ class DisplayCallback(tf.keras.callbacks.Callback):
134
+ def on_epoch_end(self, epoch, logs=None):
135
+ show_predictions()
136
+ st.write('\nSample Prediction after epoch {}\n'.format(epoch+1))
137
+
138
  # Streamlit app interface
139
  st.title("Cardiac Images Dataset")
140
 
 
178
  st.image(plot_filename, caption="Neural Network Architecture", use_container_width=True)
179
 
180
  # show a predection, as an example
181
+ show_predictions(test_dataset)
182
+
183
+ # setup a tensorboard callback
184
+ logdir = os.path.join("logs", datetime.datetime.now().strftime("%Y%m%d-%H%M%S"))
185
+ tensorboard_callback = tf.keras.callbacks.TensorBoard(logdir, histogram_freq=1)
186
+
187
+ if st.button("Run Model"):
188
+ # setup and run the model
189
+ EPOCHS = 20
190
+ STEPS_PER_EPOCH = len(list(parsed_training_dataset))
191
+ VALIDATION_STEPS = 26
192
+
193
+ model_history = model.fit(train_dataset, epochs=EPOCHS,
194
+ steps_per_epoch=STEPS_PER_EPOCH,
195
+ validation_steps=VALIDATION_STEPS,
196
+ validation_data=test_dataset,
197
+ callbacks=[DisplayCallback(), tensorboard_callback])
logs/20250131-045843/train/events.out.tfevents.1738270723.DESKTOP-EALR51U.17584.0.v2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc8d68eaa942a1f918afd63630d5ccb87db8d585c731feccb683322b2d9338cf
3
+ size 72247
logs/20250131-045843/validation/events.out.tfevents.1738270743.DESKTOP-EALR51U.17584.1.v2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb39a13b41d0b6efd4309c3868640b6095fa087afe4b0344332e6d6cfe03a778
3
+ size 6474