Skip to content

iis23025/cholecPtychiaki

Repository files navigation

Self-Supervised Surgical Phase Recognition in Laparoscopic Cholecystectomy: Foundations for Intraoperative Video-Based Prediction of Postoperative Complications

Leonidas A. Kralidis

Chair & Supervising professor: Prof. Protopapadakis E.

This repository is part of my thesis about surgical phase recognition in laparoscopic cholecystectomy.

The dissertation was approved by the Department of Applied Informatics of the University of Macedonia for the attainment of Bachelor’s degree in computer science.

Code availability and experiment reproducibility

All experiments presented in this thesis were implemented in Python using Google Colab. The complete notebook, including data preprocessing, model definitions, training procedures, and evaluation pipelines for all experimental settings (E0, E1, E1b, E2, E3), is publicly available in a GitHub repository.

CELL OUTPUTS

(version 10, complete run of all experiments)

Cell1:

Mounted at /content/drive

Cell2:

Local dataset ready at: /content/cholec80 Local videos: ['/content/cholec80/videos/video01.mp4', '/content/cholec80/videos/video02.mp4', '/content/cholec80/videos/video03.mp4', '/content/cholec80/videos/video04.mp4', '/content/cholec80/videos/video05.mp4']

Cell3:-

Cell4:

video01 -> frames: 1733 video02 -> frames: 2839 video03 -> frames: 5828 video04 -> frames: 1522 video05 -> frames: 2344

Cell5:

000001.jpg

Cell6:

Saved: /content/cholec80_index_1fps_v01_05.csv Rows: 14266 video Frame sec_idx img_path Phase label 0 video01 0 1 /content/frames_1fps/video01/000001.jpg Preparation 0 1 video01 25 2 /content/frames_1fps/video01/000002.jpg Preparation 0 2 video01 50 3 /content/frames_1fps/video01/000003.jpg Preparation 0 3 video01 75 4 /content/frames_1fps/video01/000004.jpg Preparation 0 4 video01 100 5 /content/frames_1fps/video01/000005.jpg Preparation 0

Cell7:

train/val/test: 10400 1522 2344 train videos: ['video01' 'video02' 'video03']

Cell8:

device(type='cuda')

Cell9:

Downloading: "https://download.pytorch.org/models/resnet18-f37072fd.pth" to /root/.cache/torch/hub/checkpoints/resnet18-f37072fd.pth 100%|██████████| 44.7M/44.7M [00:00<00:00, 111MB/s] Epoch 1: train_loss=0.2087 | val_acc=0.5388 | val_f1=0.4776 Epoch 2: train_loss=0.0528 | val_acc=0.3995 | val_f1=0.3644 Epoch 3: train_loss=0.0399 | val_acc=0.4159 | val_f1=0.4367

Cell10:

TEST: acc= 0.4906143344709898 macroF1= 0.43967196817060866 Saved: /content/drive/MyDrive/checkpoints/cholec80_E0_resnet18_1fps_v01_05.pt

Cell11:

Copied new videos: 15 Local mp4 count: 20

Cell12:

Extracting from: 20 videos Done: video01 frames: 1734 Done: video02 frames: 2840 Done: video03 frames: 5829 Done: video04 frames: 1523 Done: video05 frames: 2345 Done: video06 frames: 2154 Done: video07 frames: 4558 Done: video08 frames: 1520 Done: video09 frames: 2703 Done: video10 frames: 1750 Done: video11 frames: 3221 Done: video12 frames: 1091 Done: video13 frames: 982 Done: video14 frames: 1709 Done: video15 frames: 2059 Done: video16 frames: 2958 Done: video17 frames: 1305 Done: video18 frames: 1943 Done: video19 frames: 2425 Done: video20 frames: 1450

Cell13:

Videos with frames: 20 ['video01', 'video02', 'video03', 'video04', 'video05'] ... ['video16', 'video17', 'video18', 'video19', 'video20'] Saved: /content/cholec80_index_1fps_available.csv Rows: 46099 video Frame sec_idx img_path Phase label 0 video01 0 1 /content/frames_1fps/video01/000001.jpg Preparation 0 1 video01 25 2 /content/frames_1fps/video01/000002.jpg Preparation 0 2 video01 50 3 /content/frames_1fps/video01/000003.jpg Preparation 0 3 video01 75 4 /content/frames_1fps/video01/000004.jpg Preparation 0 4 video01 100 5 /content/frames_1fps/video01/000005.jpg Preparation 0

Cell14:

Videos total: 20 train/val/test rows: 38976 3248 3875 train: ['video01', 'video02', 'video03', 'video04', 'video05', 'video06', 'video07', 'video08', 'video09', 'video10', 'video11', 'video12', 'video13', 'video14', 'video15', 'video16'] val: ['video17', 'video18'] test: ['video19', 'video20']

Cell15:

Epoch 1: train_loss=0.4082 | val_acc=0.8045 | val_f1=0.7272 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E0_resnet18_1fps_v01_20_best.pt Epoch 2: train_loss=0.1281 | val_acc=0.7996 | val_f1=0.7423 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E0_resnet18_1fps_v01_20_best.pt Epoch 3: train_loss=0.0831 | val_acc=0.7703 | val_f1=0.6800 Epoch 4: train_loss=0.0619 | val_acc=0.8498 | val_f1=0.7747 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E0_resnet18_1fps_v01_20_best.pt Epoch 5: train_loss=0.0574 | val_acc=0.8026 | val_f1=0.7059 Epoch 6: train_loss=0.0529 | val_acc=0.8011 | val_f1=0.7385 Epoch 7: train_loss=0.0501 | val_acc=0.8417 | val_f1=0.7683

Cell16:

VAL acc: 0.8494458128078818 VAL macroF1: 0.7745318500440579 precision recall f1-score support

        Preparation     0.6713    0.8430    0.7474       172

CalotTriangleDissection 0.9100 0.8902 0.9000 1193 ClippingCutting 0.8659 0.8304 0.8478 342 GallbladderDissection 0.8831 0.9349 0.9083 953 GallbladderPackaging 0.6626 0.7152 0.6879 151 CleaningCoagulation 0.8350 0.5850 0.6880 294 GallbladderRetraction 0.6101 0.6783 0.6424 143

           accuracy                         0.8494      3248
          macro avg     0.7768    0.7825    0.7745      3248
       weighted avg     0.8533    0.8494    0.8484      3248

TEST acc: 0.7396129032258064 TEST macroF1: 0.7058566562569375 precision recall f1-score support

        Preparation     0.6175    0.9040    0.7338       125

CalotTriangleDissection 0.8810 0.7613 0.8168 2061 ClippingCutting 0.6936 0.6792 0.6863 240 GallbladderDissection 0.5556 0.7485 0.6377 815 GallbladderPackaging 0.9180 0.5545 0.6914 202 CleaningCoagulation 0.6707 0.6512 0.6608 344 GallbladderRetraction 0.6148 0.8523 0.7143 88

           accuracy                         0.7396      3875
          macro avg     0.7073    0.7358    0.7059      3875
       weighted avg     0.7696    0.7396    0.7456      3875

Cell17:

Saved: /content/drive/MyDrive/results/E0_confusion_test_v19_20.png

Cell18:

TEST raw macroF1: 0.7058566562569375 TEST smooth macroF1: 0.7492021947998244

Cell19:

Saved: /content/drive/MyDrive/results/E0_test_predictions_v19_20.csv

Cell20:

FEATURE_DIR: /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned

Cell21:

saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video01.pt | T= 1734 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video02.pt | T= 2840 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video03.pt | T= 5829 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video04.pt | T= 1523 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video05.pt | T= 2345 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video06.pt | T= 2154 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video07.pt | T= 4558 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video08.pt | T= 1520 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video09.pt | T= 2703 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video10.pt | T= 1750 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video11.pt | T= 3221 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video12.pt | T= 1091 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video13.pt | T= 982 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video14.pt | T= 1709 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video15.pt | T= 2059 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/train_video16.pt | T= 2958 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/val_video17.pt | T= 1305 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/val_video18.pt | T= 1943 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/test_video19.pt | T= 2425 saved /content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/test_video20.pt | T= 1450 Done feature dumping.

Cell22:

(16, 2, 2)

Cell23:

Train counts per class: [1617, 16434, 3028, 11744, 1636, 2461, 2056] Train freq per class: [0.0415, 0.4216, 0.0777, 0.3013, 0.042, 0.0631, 0.0528] weights sqrt: [1.371, 0.43, 1.002, 0.509, 1.363, 1.111, 1.216]

Cell24:

BiLSTMTemporal( (lstm): LSTM(512, 256, num_layers=2, batch_first=True, dropout=0.3, bidirectional=True) (drop): Dropout(p=0.3, inplace=False) (fc): Linear(in_features=512, out_features=7, bias=True) )

Cell25:

[E1 BiLSTM] Epoch 1: train_loss=1.6768 | val_acc=0.8608 | val_macroF1=0.7806 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E1_bilstm_feat512_best.pt [E1 BiLSTM] Epoch 2: train_loss=0.7440 | val_acc=0.9233 | val_macroF1=0.8651 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E1_bilstm_feat512_best.pt [E1 BiLSTM] Epoch 3: train_loss=0.2258 | val_acc=0.9353 | val_macroF1=0.8849 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E1_bilstm_feat512_best.pt [E1 BiLSTM] Epoch 4: train_loss=0.0642 | val_acc=0.9304 | val_macroF1=0.8769 [E1 BiLSTM] Epoch 5: train_loss=0.0220 | val_acc=0.9276 | val_macroF1=0.8802 [E1 BiLSTM] Epoch 6: train_loss=0.0139 | val_acc=0.9203 | val_macroF1=0.8686 [E1 BiLSTM] Epoch 7: train_loss=0.0114 | val_acc=0.9169 | val_macroF1=0.8711 [E1 BiLSTM] Epoch 8: train_loss=0.0104 | val_acc=0.9267 | val_macroF1=0.8699 [E1 BiLSTM] Epoch 9: train_loss=0.0096 | val_acc=0.9147 | val_macroF1=0.8650 [E1 BiLSTM] Epoch 10: train_loss=0.0081 | val_acc=0.9101 | val_macroF1=0.8546 [E1 BiLSTM] Epoch 11: train_loss=0.0066 | val_acc=0.9280 | val_macroF1=0.8754 [E1 BiLSTM] Epoch 12: train_loss=0.0058 | val_acc=0.9095 | val_macroF1=0.8551

Cell26:

TEST acc: 0.8196129032258065 TEST macroF1: 0.8364672413236243 precision recall f1-score support

        Preparation     0.8732    0.9920    0.9288       125

CalotTriangleDissection 0.9127 0.8467 0.8784 2061 ClippingCutting 0.8326 0.7875 0.8094 240 GallbladderDissection 0.6034 0.7951 0.6861 815 GallbladderPackaging 1.0000 0.7426 0.8523 202 CleaningCoagulation 0.8429 0.6860 0.7564 344 GallbladderRetraction 0.9333 0.9545 0.9438 88

           accuracy                         0.8196      3875
          macro avg     0.8569    0.8292    0.8365      3875
       weighted avg     0.8402    0.8196    0.8246      3875

Saved: /content/drive/MyDrive/results/E1_bilstm_test_predictions_v19_20.csv

Cell27:

[E1b TCN] Epoch 1: train_loss=1.9239 | val_acc=0.8556 | val_macroF1=0.7829 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E1b_tcn_feat512_best.pt [E1b TCN] Epoch 2: train_loss=0.0910 | val_acc=0.9027 | val_macroF1=0.8327 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E1b_tcn_feat512_best.pt [E1b TCN] Epoch 3: train_loss=0.0502 | val_acc=0.9227 | val_macroF1=0.8529 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E1b_tcn_feat512_best.pt [E1b TCN] Epoch 4: train_loss=0.0267 | val_acc=0.9212 | val_macroF1=0.8670 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E1b_tcn_feat512_best.pt [E1b TCN] Epoch 5: train_loss=0.0413 | val_acc=0.9135 | val_macroF1=0.8609 [E1b TCN] Epoch 6: train_loss=0.0207 | val_acc=0.9153 | val_macroF1=0.8639 [E1b TCN] Epoch 7: train_loss=0.0212 | val_acc=0.9049 | val_macroF1=0.8494 [E1b TCN] Epoch 8: train_loss=0.0153 | val_acc=0.9206 | val_macroF1=0.8695 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E1b_tcn_feat512_best.pt [E1b TCN] Epoch 9: train_loss=0.0122 | val_acc=0.9178 | val_macroF1=0.8636 [E1b TCN] Epoch 10: train_loss=0.0141 | val_acc=0.9113 | val_macroF1=0.8499 [E1b TCN] Epoch 11: train_loss=0.0097 | val_acc=0.8922 | val_macroF1=0.8294 [E1b TCN] Epoch 12: train_loss=0.0116 | val_acc=0.9036 | val_macroF1=0.8571 TEST acc: 0.8118709677419355 TEST macroF1: 0.7935523956398398 precision recall f1-score support

        Preparation     0.6345    1.0000    0.7764       125

CalotTriangleDissection 0.9110 0.8496 0.8792 2061 ClippingCutting 0.8067 0.8000 0.8033 240 GallbladderDissection 0.6314 0.7840 0.6995 815 GallbladderPackaging 1.0000 0.6436 0.7831 202 CleaningCoagulation 0.8284 0.6453 0.7255 344 GallbladderRetraction 0.8056 0.9886 0.8878 88

           accuracy                         0.8119      3875
          macro avg     0.8025    0.8159    0.7936      3875
       weighted avg     0.8317    0.8119    0.8150      3875

Saved: /content/drive/MyDrive/results/E1b_tcn_test_predictions_v19_20.csv

Cell28:

SSL_CKPT: /content/drive/MyDrive/checkpoints/cholec80_E2_ssl_simclr_pretrain.pt SSL frames: 38976 unique videos: 16

Cell29:-

Cell30:-

Cell31:

[E2 SimCLR] Epoch 01: loss=5.7462 | lr=3.00e-05 [E2 SimCLR] Epoch 02: loss=4.1140 | lr=1.50e-04 [E2 SimCLR] Epoch 03: loss=3.3938 | lr=3.00e-04 [E2 SimCLR] Epoch 04: loss=3.0967 | lr=2.99e-04 [E2 SimCLR] Epoch 05: loss=2.9563 | lr=2.96e-04 [E2 SimCLR] Epoch 06: loss=2.8599 | lr=2.92e-04 [E2 SimCLR] Epoch 07: loss=2.7961 | lr=2.85e-04 [E2 SimCLR] Epoch 08: loss=2.7436 | lr=2.77e-04 [E2 SimCLR] Epoch 09: loss=2.7101 | lr=2.67e-04 [E2 SimCLR] Epoch 10: loss=2.6789 | lr=2.56e-04 [E2 SimCLR] Epoch 11: loss=2.6437 | lr=2.44e-04 [E2 SimCLR] Epoch 12: loss=2.6290 | lr=2.30e-04 [E2 SimCLR] Epoch 13: loss=2.6106 | lr=2.15e-04 [E2 SimCLR] Epoch 14: loss=2.5872 | lr=2.00e-04 [E2 SimCLR] Epoch 15: loss=2.5683 | lr=1.83e-04 [E2 SimCLR] Epoch 16: loss=2.5562 | lr=1.67e-04 [E2 SimCLR] Epoch 17: loss=2.5445 | lr=1.50e-04 [E2 SimCLR] Epoch 18: loss=2.5291 | lr=1.33e-04 [E2 SimCLR] Epoch 19: loss=2.5194 | lr=1.17e-04 [E2 SimCLR] Epoch 20: loss=2.5141 | lr=1.00e-04 [E2 SimCLR] Epoch 21: loss=2.5050 | lr=8.49e-05 [E2 SimCLR] Epoch 22: loss=2.4957 | lr=7.02e-05 [E2 SimCLR] Epoch 23: loss=2.4883 | lr=5.65e-05 [E2 SimCLR] Epoch 24: loss=2.4830 | lr=4.39e-05 [E2 SimCLR] Epoch 25: loss=2.4787 | lr=3.27e-05 [E2 SimCLR] Epoch 26: loss=2.4738 | lr=2.30e-05 [E2 SimCLR] Epoch 27: loss=2.4701 | lr=1.49e-05 [E2 SimCLR] Epoch 28: loss=2.4690 | lr=8.42e-06 [E2 SimCLR] Epoch 29: loss=2.4667 | lr=3.76e-06 [E2 SimCLR] Epoch 30: loss=2.4658 | lr=9.43e-07 Saved SSL encoder -> /content/drive/MyDrive/checkpoints/cholec80_E2_ssl_simclr_pretrain.pt

Cell32:

SSL load missing: ['fc.weight', 'fc.bias'] ... SSL load unexpected: []

Cell33:

PhaseDataset + train_tf/test_tf ready. Example df columns: ['video', 'Frame', 'sec_idx', 'img_path', 'Phase', 'label'] Train rows: 38976 Val rows: 3248 Test rows: 3875 [E2_rand] Epoch 1: train_loss=0.7267 | val_acc=0.6918 | val_macroF1=0.4775 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E2_rand_best.pt [E2_rand] Epoch 2: train_loss=0.3671 | val_acc=0.7774 | val_macroF1=0.6725 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E2_rand_best.pt [E2_rand] Epoch 3: train_loss=0.2519 | val_acc=0.7672 | val_macroF1=0.6164 [E2_rand] Epoch 4: train_loss=0.1773 | val_acc=0.7075 | val_macroF1=0.5248 [E2_rand] Epoch 5: train_loss=0.1438 | val_acc=0.7442 | val_macroF1=0.6040 [E2_rand] Epoch 6: train_loss=0.1075 | val_acc=0.7251 | val_macroF1=0.6040 [E2_rand] Epoch 7: train_loss=0.0947 | val_acc=0.7081 | val_macroF1=0.5613

[E2_rand] TEST acc=0.6545 | TEST macroF1=0.4047 precision recall f1-score support

        Preparation     0.0656    0.0320    0.0430       125

CalotTriangleDissection 0.7525 0.9044 0.8215 2061 ClippingCutting 0.3370 0.3875 0.3605 240 GallbladderDissection 0.6733 0.3718 0.4791 815 GallbladderPackaging 0.6667 0.0990 0.1724 202 CleaningCoagulation 0.6917 0.5087 0.5863 344 GallbladderRetraction 0.2348 0.8750 0.3702 88

           accuracy                         0.6545      3875
          macro avg     0.4888    0.4541    0.4047      3875
       weighted avg     0.6663    0.6545    0.6308      3875

Saved: /content/drive/MyDrive/results/E2_rand_test_predictions_v19_20.csv [E2_imagenet] Epoch 1: train_loss=0.2686 | val_acc=0.8371 | val_macroF1=0.7397 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E2_imagenet_best.pt [E2_imagenet] Epoch 2: train_loss=0.1115 | val_acc=0.7423 | val_macroF1=0.7146 [E2_imagenet] Epoch 3: train_loss=0.0785 | val_acc=0.8467 | val_macroF1=0.7714 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E2_imagenet_best.pt [E2_imagenet] Epoch 4: train_loss=0.0611 | val_acc=0.7675 | val_macroF1=0.6907 [E2_imagenet] Epoch 5: train_loss=0.0488 | val_acc=0.7500 | val_macroF1=0.6765 [E2_imagenet] Epoch 6: train_loss=0.0513 | val_acc=0.8661 | val_macroF1=0.7953 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E2_imagenet_best.pt [E2_imagenet] Epoch 7: train_loss=0.0349 | val_acc=0.8279 | val_macroF1=0.7552

[E2_imagenet] TEST acc=0.7791 | TEST macroF1=0.6880 precision recall f1-score support

        Preparation     0.6505    0.5360    0.5877       125

CalotTriangleDissection 0.8755 0.8598 0.8676 2061 ClippingCutting 0.6000 0.5750 0.5872 240 GallbladderDissection 0.6429 0.7865 0.7075 815 GallbladderPackaging 0.9574 0.6683 0.7872 202 CleaningCoagulation 0.9126 0.5465 0.6836 344 GallbladderRetraction 0.4483 0.8864 0.5954 88

           accuracy                         0.7791      3875
          macro avg     0.7268    0.6941    0.6880      3875
       weighted avg     0.8001    0.7791    0.7808      3875

Saved: /content/drive/MyDrive/results/E2_imagenet_test_predictions_v19_20.csv [E2_ssl_simclr] Epoch 1: train_loss=0.5974 | val_acc=0.6844 | val_macroF1=0.5378 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E2_ssl_simclr_best.pt [E2_ssl_simclr] Epoch 2: train_loss=0.3192 | val_acc=0.7722 | val_macroF1=0.6232 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E2_ssl_simclr_best.pt [E2_ssl_simclr] Epoch 3: train_loss=0.2345 | val_acc=0.7946 | val_macroF1=0.6852 saved best -> /content/drive/MyDrive/checkpoints/cholec80_E2_ssl_simclr_best.pt [E2_ssl_simclr] Epoch 4: train_loss=0.1787 | val_acc=0.7789 | val_macroF1=0.6326 [E2_ssl_simclr] Epoch 5: train_loss=0.1465 | val_acc=0.7094 | val_macroF1=0.6087 [E2_ssl_simclr] Epoch 6: train_loss=0.1214 | val_acc=0.7432 | val_macroF1=0.5945 [E2_ssl_simclr] Epoch 7: train_loss=0.0995 | val_acc=0.7275 | val_macroF1=0.6059

[E2_ssl_simclr] TEST acc=0.6663 | TEST macroF1=0.4572 precision recall f1-score support

        Preparation     0.4884    0.3360    0.3981       125

CalotTriangleDissection 0.7548 0.8020 0.7777 2061 ClippingCutting 0.1618 0.0458 0.0714 240 GallbladderDissection 0.5582 0.6883 0.6165 815 GallbladderPackaging 0.8462 0.1089 0.1930 202 CleaningCoagulation 0.7108 0.6860 0.6982 344 GallbladderRetraction 0.3393 0.6477 0.4453 88

           accuracy                         0.6663      3875
          macro avg     0.5513    0.4736    0.4572      3875
       weighted avg     0.6595    0.6663    0.6427      3875

Saved: /content/drive/MyDrive/results/E2_ssl_simclr_test_predictions_v19_20.csv

=== SUMMARY === exp init val_best_macroF1 test_acc test_macroF1 0 E2_rand random 0.672536 0.654452 0.404701 1 E2_imagenet imagenet 0.795339 0.779097 0.688036 2 E2_ssl_simclr ssl 0.685163 0.666323 0.457177

Cell34:

Copied new videos: 60 Local mp4 count: 80 Using E0 checkpoint: /content/drive/MyDrive/checkpoints/cholec80_E0_resnet18_1fps_v01_20_best.pt 100%|██████████| 60/60 [3:05:36<00:00, 185.61s/it] Done. Created: 60 | Skipped (already existed): 0 Example feature files: ['/content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/deploy_video21.pt', '/content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/deploy_video22.pt', '/content/drive/MyDrive/features/cholec80_1fps_resnet18_E0finetuned/deploy_video23.pt'] Keys: dict_keys(['x', 'sec', 'y']) | x: (1258, 512) | sec: (1258,) | y unique: tensor([-100]) E3: Using feature prefix: deploy E3: Missing feature files: 0 E3: Loaded checkpoint: /content/drive/MyDrive/checkpoints/cholec80_E1_bilstm_feat512_best.pt 100%|██████████| 15/15 [00:02<00:00, 5.52it/s] E3: Detected UNLABELED features (-100). Exporting predictions only (no metrics). Saved: /content/drive/MyDrive/results/E3_unlabelled_test_predictions_v21_80.csv video sec_idx y_true y_pred phase_pred 0 video21 0 -100 5 CleaningCoagulation 1 video21 1 -100 5 CleaningCoagulation 2 video21 2 -100 5 CleaningCoagulation 3 video21 3 -100 5 CleaningCoagulation 4 video21 4 -100 5 CleaningCoagulation

Cell35:
Videos in predictions: 60 ['video21', 'video22', 'video23'] ...

=== E3 (videos 21-80) === Overall Accuracy : 0.7751320266726389 Overall Macro-F1 : 0.6762280944306092

Classification report: precision recall f1-score support

        Preparation     0.7713    0.2815    0.4125      6660

CalotTriangleDissection 0.9366 0.7542 0.8356 55138 ClippingCutting 0.8414 0.6218 0.7151 10470 GallbladderDissection 0.7418 0.9285 0.8247 44921 GallbladderPackaging 0.7819 0.7865 0.7842 5629 CleaningCoagulation 0.6912 0.6530 0.6715 11235 GallbladderRetraction 0.3393 0.8816 0.4900 4366

           accuracy                         0.7751    138419
          macro avg     0.7291    0.7010    0.6762    138419
       weighted avg     0.8132    0.7751    0.7763    138419

Saved eval CSV: /content/drive/MyDrive/results/E3_eval_predictions_v21_80_with_ytrue.csv

Worst 5 videos by macroF1: video n_secs fps acc macro_f1 video60 2532 25.0 0.222749 0.312337 video75 1923 25.0 0.838794 0.455275 video36 2387 25.0 0.604106 0.459289 video51 2944 25.0 0.519022 0.467275 video56 1834 25.0 0.663032 0.467794

Best 5 videos by macroF1: video n_secs fps acc macro_f1 video28 1199 25.0 0.934946 0.847375 video34 1323 25.0 0.938776 0.853433 video30 2925 25.0 0.898803 0.882936 video73 1356 25.0 0.898230 0.909211 video22 1532 25.0 0.933420 0.929844

About

This repository is part of my thesis about surgical phase recognition in laparoscopic cholecystectomy. The dissertation was approved by the Department of Applied Informatics of the University of Macedonia for the attainment of Bachelor’s degree in computer science.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors