João Pedro commited on
Commit
d2efd6d
·
1 Parent(s): 8756989

log the actual image to wandb

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. training.py +16 -4
app.py CHANGED
@@ -78,7 +78,7 @@ if uploaded_file:
78
  print(f'Correct label for image {i}: {correct_label}')
79
 
80
  run.log({
81
- 'filepath': uploaded_file,
82
  'filetype': uploaded_file.type,
83
  'predicted_label': id2label[prediction],
84
  'predicted_label_id': prediction,
 
78
  print(f'Correct label for image {i}: {correct_label}')
79
 
80
  run.log({
81
+ 'image': wandb.Image(image),
82
  'filetype': uploaded_file.type,
83
  'predicted_label': id2label[prediction],
84
  'predicted_label_id': prediction,
training.py CHANGED
@@ -7,6 +7,7 @@ from constants import (PROCESSED_DATA_DIR,
7
  EPOCHS,
8
  BERT_BASE,
9
  MAX_SEQUENCE_LENGHT,
 
10
  FilePath,
11
  PageMetadata,
12
  ImageSize,
@@ -101,6 +102,21 @@ def prepare_data(
101
  test_frac=0.15,
102
  )
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  print('Batching and shuffling the datasets')
105
  train_ds = dataset_from_dataframe(train_df)
106
  train_ds = prepare_dataset(train_ds, img_size, batch_size=BATCH_SIZE)
@@ -222,10 +238,6 @@ def train():
222
  )
223
 
224
 
225
- def evaluate():
226
- return
227
-
228
-
229
  if __name__ = '__main__':
230
  train()
231
  evaluate()
 
7
  EPOCHS,
8
  BERT_BASE,
9
  MAX_SEQUENCE_LENGHT,
10
+ PROJECT_NAME,
11
  FilePath,
12
  PageMetadata,
13
  ImageSize,
 
102
  test_frac=0.15,
103
  )
104
 
105
+ run = wandb.init(project_name=PROJECT_NAME, name='split-dataset')
106
+
107
+ split_dataset_artifact = wandb.Artifact('split-dataset-metadata', type='dataset')
108
+
109
+ train_table = wandb.Table(dataframe=train_df)
110
+ val_table = wandb.Table(dataframe=val_df)
111
+ test_table = wandb.Table(dataframe=test_df)
112
+
113
+ split_dataset_artifact.add(train_table, name='train_metadata')
114
+ split_dataset_artifact.add(val_table, name='val_metadata')
115
+ split_dataset_artifact.add(test_table, name='test_metadata')
116
+
117
+ run.log_artifact(split_dataset_artifact)
118
+ run.finish()
119
+
120
  print('Batching and shuffling the datasets')
121
  train_ds = dataset_from_dataframe(train_df)
122
  train_ds = prepare_dataset(train_ds, img_size, batch_size=BATCH_SIZE)
 
238
  )
239
 
240
 
 
 
 
 
241
  if __name__ = '__main__':
242
  train()
243
  evaluate()