Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproduzir "KFC: Kinship Verification with Fair Contrastive Loss and Multi-Task Learning" #52

Closed
8 tasks done
vitalwarley opened this issue Jan 17, 2024 · 18 comments
Closed
8 tasks done
Assignees

Comments

@vitalwarley
Copy link
Owner

vitalwarley commented Jan 17, 2024

#50

Baixar datasets

  • CornellKin
  • UBKinFace
  • KinFaceW-I, KinFaceW-II
  • Family101
  • FIW

Executar scripts

  • train
  • find
  • test
@vitalwarley vitalwarley self-assigned this Jan 17, 2024
@vitalwarley
Copy link
Owner Author

╔╡[warley]:[arch-rog-strix]➾[~/dev/research/works/KFC] | [on branch main] 
╚═╡(kfc) [10:49] λ tree --filesfirst -L 1
.
├── dataset.py
├── find.py
├── LICENSE
├── losses.py
├── models_multi_task.py
├── README.md
├── requirements.txt
├── test.py
├── torch_resnet101.py
├── train.py
├── Cornell_Kin
├── data_files
├── Family101_150x120
├── KinFaceW-I
├── KinFaceW-II
├── log_files
├── Test
├── Train
├── UB_KinFace
└── Validation

As amostras do dataset FIW são Train, Validation, Test. Copiei de #26.

@vitalwarley
Copy link
Owner Author

Encontrei um obstáculo complicado: garynlfd/KFC#3

@vitalwarley
Copy link
Owner Author

vitalwarley commented Jan 20, 2024

@vitalwarley
Copy link
Owner Author

vitalwarley commented Jan 23, 2024

Ontem realizei o treinamento do modelo, todavia esqueci de reverter umas mudanças no dataset de treino -- eu havia removido algumas amostras problemáticas no antigo dataset.

Vou continuar com os próximos scripts localmente enquanto que configuro um novo treinamento na RIG2.

╚═╡[9:19] λ python train.py --batch_size 20 \
                --sample data_files \
                --save_path log_files \
                --epochs 100 --beta 0.08 \
                --log_path log_files/log.txt \
                --gpu 0
...

*************
epoch 100
  8%|████████▍                                                                                                  | 599/7560 [04:42<54:06,  2.14it/s][W CudaIPCTypes.cpp:15] Producer process has been terminated before all shared CUDA tensors released. See Note [Sharing CUDA tensors]
  8%|████████▍                                                                                                  | 599/7560 [04:44<55:01,  2.11it/s]
1200000
total_loss:1.678999
kinship_loss:0.049584
race_loss:1.629415
race margin:  [tensor(0.0915, grad_fn=<DivBackward0>), tensor(0.1607, grad_fn=<DivBackward0>), tensor(0.0140, grad_fn=<DivBackward0>), tensor(-0.0705, grad_fn=<DivBackward0>)]
[W CudaIPCTypes.cpp:15] Producer process has been terminated before all shared CUDA tensors released. See Note [Sharing CUDA tensors]
auc is 0.867303 
std is 0.023086 
auc did not improve from 0.900970

Precisei diminuir o batch aqui de 25 para 20.

@vitalwarley
Copy link
Owner Author

╚═╡(kfc) [9:19] λ python find.py --sample data_files/ --save_path log_files --batch_size 30 --log_path log_files/log.txt --gpu 0
/home/warley/.virtualenvs/kfc/lib/python3.11/site-packages/torch/__init__.py:614: UserWarning: torch.set_default_tensor_type() is deprecated as of PyTorch 2.1, please use torch.set_default_dtype() and torch.set_default_device() as alternatives. (Triggered internally at ../torch/csrc/tensor/python_tensor.cpp:451.)
  _C._set_default_tensor_type(t)
100
200
300
400
500
600
700
800
900
1000
1100
1200
1300
1400
1500
1600
1700
1800
1900
2000
[W CudaIPCTypes.cpp:15] Producer process has been terminated before all shared CUDA tensors released. See Note [Sharing CUDA tensors]
auc :  0.8857414765391811
threshold : 0.10917659848928452

@vitalwarley
Copy link
Owner Author

diff --git a/test.py b/test.py
index d1b067f..81dcab5 100644
--- a/test.py
+++ b/test.py
@@ -68,7 +68,7 @@ def gen(list_tuples, batch_size):
 
 def read_image(path):
     img = image.load_img(path, target_size=(112, 112))
-    img = np.array(img).astype(np.float)
+    img = np.array(img).astype(np.float64)
     return np.transpose(img, (2, 0, 1))
╚═╡(kfc) [9:41] λ python test.py --sample data_files/ --save_path log_files --batch_size 30 --log_path log_files/log.txt --gpu 0 --threshold 0.10917659848928452
... 17 minutos depois
Test output
^[hnumber of false negative pairs:  9017
false negative rate:  0.09855291057337093
number of false positive pairs:  7800
false positive rate:  0.08525149190110827
fd : 0.7830224752517313
md : 0.8429052730549244
fs : 0.8413508570456382
ms : 0.790169133192389
avg : 0.8161955975255208
easy KIN cosine similarities:
Image Pair: ['Family101_150x120/Victoria/Queen_Silvia/Queen_Silvia_0019.jpg', 'Family101_150x120/Victoria/Madeleine/Madeleine_0007.jpg'], Similarity: 1.0
Image Pair: ['Family101_150x120/Sheen/Martin_Sheen/Martin_Sheen_0019.jpg', 'Family101_150x120/Sheen/Ramon_Estevez/Ramon_Estevez_0012.jpg'], Similarity: 1.0
Image Pair: ['Family101_150x120/Sheen/Martin_Sheen/Martin_Sheen_0013.jpg', 'Family101_150x120/Sheen/Ramon_Estevez/Ramon_Estevez_0013.jpg'], Similarity: 1.0
Image Pair: ['Family101_150x120/Wilson/Ellen_Axson_Wilson/Ellen_Axson_Wilson_0001.jpg', 'Family101_150x120/Wilson/Margaret_Woodrow_Wilson/Margaret_Woodrow_Wilson_0006.jpg'], Similarity: 0.9858179688453674
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0022.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9842594265937805
Image Pair: ['Family101_150x120/Bo/Bo_Xilai/Bo_Xilai_0008.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0009.jpg'], Similarity: 0.9841707944869995
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0007.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9839189052581787
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0017.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9831457138061523
Image Pair: ['Family101_150x120/Bo/Bo_Xilai/Bo_Xilai_0014.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0009.jpg'], Similarity: 0.9821934103965759
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0007.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0002.jpg'], Similarity: 0.9819899797439575
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0001.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9819543361663818
Image Pair: ['Family101_150x120/Bo/Gu_Kailai/Gu_Kailai_0005.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0009.jpg'], Similarity: 0.9816953539848328
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0007.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.9816329479217529
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0019.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9814653396606445
Image Pair: ['Family101_150x120/Tsuguko/Prince_Takamado/Prince_Takamado_0002.jpg', 'Family101_150x120/Tsuguko/Princess_Tsuguko/Princess_Tsuguko_0006.jpg'], Similarity: 0.9814221858978271
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0020.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.9814149141311646
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0017.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.9813425540924072
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0007.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0001.jpg'], Similarity: 0.9812716245651245
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0010.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.9812338352203369
Image Pair: ['Family101_150x120/Bo/Bo_Xilai/Bo_Xilai_0008.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0004.jpg'], Similarity: 0.9810476899147034
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0015.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0002.jpg'], Similarity: 0.9810352325439453
Image Pair: ['Family101_150x120/Bo/Bo_Yibo/Bo_Yibo_0001.jpg', 'Family101_150x120/Bo/Bo_Xilai/Bo_Xilai_0009.jpg'], Similarity: 0.9809560775756836
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0022.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.9809377193450928
Image Pair: ['Family101_150x120/Bo/Bo_Xilai/Bo_Xilai_0013.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0018.jpg'], Similarity: 0.9808964133262634
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0017.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0001.jpg'], Similarity: 0.9808921813964844
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0020.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9808260202407837
Image Pair: ['Family101_150x120/Chen/Wu_Shu-chen/Wu_Shu-chen_0002.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9806446433067322
Image Pair: ['Family101_150x120/Bo/Bo_Xilai/Bo_Xilai_0014.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0019.jpg'], Similarity: 0.9805902242660522
Image Pair: ['Family101_150x120/Bo/Bo_Xilai/Bo_Xilai_0017.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0009.jpg'], Similarity: 0.9803814888000488
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0001.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.9801994562149048
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0010.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9801484942436218
Image Pair: ['Family101_150x120/Bo/Bo_Xilai/Bo_Xilai_0010.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0009.jpg'], Similarity: 0.9799408912658691
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0001.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0001.jpg'], Similarity: 0.9798178672790527
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0023.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9797762632369995
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0023.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.9796983599662781
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0010.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0002.jpg'], Similarity: 0.979537844657898
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0019.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0001.jpg'], Similarity: 0.9793769121170044
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0015.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9793750047683716
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0015.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.9792839288711548
Image Pair: ['Family101_150x120/Bo/Bo_Xilai/Bo_Xilai_0014.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0004.jpg'], Similarity: 0.9790430665016174
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0016.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9789975881576538
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0020.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0002.jpg'], Similarity: 0.9789326786994934
Image Pair: ['Family101_150x120/Chen/Wu_Shu-chen/Wu_Shu-chen_0016.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9789262413978577
Image Pair: ['Family101_150x120/Chen/Wu_Shu-chen/Wu_Shu-chen_0002.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.978923499584198
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0022.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0002.jpg'], Similarity: 0.9788038730621338
Image Pair: ['Family101_150x120/Chen/Wu_Shu-chen/Wu_Shu-chen_0013.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.9787880182266235
Image Pair: ['Test/test-faces/face3697.jpg', 'Test/test-faces/face5044.jpg'], Similarity: 0.9787712693214417
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0022.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0001.jpg'], Similarity: 0.9787106513977051
Image Pair: ['Family101_150x120/Chen/Wu_Shu-chen/Wu_Shu-chen_0016.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.9786477088928223
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0017.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0002.jpg'], Similarity: 0.9786210656166077
Image Pair: ['Family101_150x120/Chen/Wu_Shu-chen/Wu_Shu-chen_0007.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9785522222518921
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0003.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9785465598106384
Image Pair: ['Family101_150x120/Chen/Wu_Shu-chen/Wu_Shu-chen_0013.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0004.jpg'], Similarity: 0.9784868955612183
Image Pair: ['Family101_150x120/Chen/Wu_Shu-chen/Wu_Shu-chen_0014.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.9784377813339233
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0003.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0003.jpg'], Similarity: 0.9784111976623535
Image Pair: ['Family101_150x120/Chen/Chen_Shui-bian/Chen_Shui-bian_0019.jpg', 'Family101_150x120/Chen/Chen_Chih-chung/Chen_Chih-chung_0002.jpg'], Similarity: 0.9784098863601685
Image Pair: ['Family101_150x120/Bo/Bo_Xilai/Bo_Xilai_0008.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0008.jpg'], Similarity: 0.9783249497413635
Image Pair: ['Family101_150x120/Bo/Gu_Kailai/Gu_Kailai_0005.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0013.jpg'], Similarity: 0.9782449007034302
Image Pair: ['Family101_150x120/Bo/Bo_Xilai/Bo_Xilai_0017.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0004.jpg'], Similarity: 0.9782353043556213
Image Pair: ['Family101_150x120/Bo/Gu_Kailai/Gu_Kailai_0005.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0008.jpg'], Similarity: 0.9782055020332336
--------------------
easy non-KIN cosine similarities:
Image Pair: ['Family101_150x120/Tyler/Bebe_Buell/Bebe_Buell_0001.jpg', 'KinFaceW-II/images/mother-son/ms_166_2.jpg'], Similarity: 0.10917337983846664
Image Pair: ['Family101_150x120/Nixon/Richard_M_Nixon/Richard_M_Nixon_0001.jpg', 'Family101_150x120/Reagan/Patti_Davis/Patti_Davis_0001.jpg'], Similarity: 0.10916692018508911
Image Pair: ['Family101_150x120/Paltrow/Blythe_Danner/Blythe_Danner_0005.jpg', 'Family101_150x120/Reagan/Ron_Reagan/Ron_Reagan_0006.jpg'], Similarity: 0.10916632413864136
Image Pair: ['Family101_150x120/Sen/Bharat_Dev_Varma/Bharat_Dev_Varma_0006.jpg', 'Family101_150x120/Khan/Soha_Ali_Khan/Soha_Ali_Khan_0011.jpg'], Similarity: 0.10916215181350708
Image Pair: ['Family101_150x120/Presley/Priscilla_Presley/Priscilla_Presley_0027.jpg', 'Family101_150x120/Saudi/Sheikh_Hamdan_bin_Mohammed_bin_Rashid_Al_Maktoum/Sheikh_Hamdan_bin_Mohammed_bin_Rashid_Al_Maktoum_0002.jpg'], Similarity: 0.10916037857532501
Image Pair: ['Family101_150x120/Ritter/Tex_Ritter/Tex_Ritter_0012.jpg', 'Family101_150x120/Victoria/Princess_Victoria/Princess_Victoria_0031.jpg'], Similarity: 0.10915027558803558
Image Pair: ['Family101_150x120/Spelling/Candy_Spelling/Candy_Spelling_0006.jpg', 'Family101_150x120/Tyler/Mia_Tyler/Mia_Tyler_0006.jpg'], Similarity: 0.10914122313261032
Image Pair: ['Test/test-faces/face4246.jpg', 'Family101_150x120/Sahni/Parikshit_Sahni/Parikshit_Sahni_0001.jpg'], Similarity: 0.10913979262113571
Image Pair: ['Family101_150x120/Stiller/Jerry_Stiller/Jerry_Stiller_0011.jpg', 'Family101_150x120/Sen/Riya_Sen/Riya_Sen_0009.jpg'], Similarity: 0.10913868248462677
Image Pair: ['Family101_150x120/Sinatra/Frank_Sinatra/Frank_Sinatra_0005.jpg', 'Family101_150x120/Dutt/Sanjay_Dutt/Sanjay_Dutt_0002.jpg'], Similarity: 0.1091373860836029
Image Pair: ['Family101_150x120/Sen/Bharat_Dev_Varma/Bharat_Dev_Varma_0003.jpg', 'Test/test-faces/face3201.jpg'], Similarity: 0.10913603007793427
Image Pair: ['Family101_150x120/Sen/Bharat_Dev_Varma/Bharat_Dev_Varma_0001.jpg', 'Test/test-faces/face3201.jpg'], Similarity: 0.10913603007793427
Image Pair: ['Family101_150x120/Sheen/Martin_Sheen/Martin_Sheen_0016.jpg', 'Test/test-faces/face1641.jpg'], Similarity: 0.1091311126947403
Image Pair: ['Family101_150x120/Reagan/Jane_Wyman/Jane_Wyman_0011.jpg', 'Family101_150x120/Dutt/Sanjay_Dutt/Sanjay_Dutt_0012.jpg'], Similarity: 0.10911113023757935
Image Pair: ['Test/test-faces/face3957.jpg', 'Family101_150x120/Rossellini/Isabella_Rossellini/Isabella_Rossellini_0021.jpg'], Similarity: 0.10910818725824356
Image Pair: ['Family101_150x120/Presley/Elvis_Presley/Elvis_Presley_0014.jpg', 'Family101_150x120/Khan/Saif_Ali_Khan/Saif_Ali_Khan_0005.jpg'], Similarity: 0.10910478234291077
Image Pair: ['Family101_150x120/Osbourne/Ozzy_Osbourne/Ozzy_Osbourne_0003.jpg', 'Family101_150x120/Tyler/Liv_Tyler/Liv_Tyler_0001.jpg'], Similarity: 0.10910096019506454
Image Pair: ['Family101_150x120/Sen/Bharat_Dev_Varma/Bharat_Dev_Varma_0007.jpg', 'Test/test-faces/face645.jpg'], Similarity: 0.10909711569547653
Image Pair: ['Family101_150x120/Sen/Moon_Moon_Sen/Moon_Moon_Sen_0002.jpg', 'Family101_150x120/Reagan/Patti_Davis/Patti_Davis_0001.jpg'], Similarity: 0.10908861458301544
Image Pair: ['Family101_150x120/Rossellini/Isabella_Rossellini/Isabella_Rossellini_0016.jpg', 'Family101_150x120/Khan/Saif_Ali_Khan/Saif_Ali_Khan_0002.jpg'], Similarity: 0.1090746819972992
Image Pair: ['Test/test-faces/face3195.jpg', 'Family101_150x120/Jiang/Jiang_You-bou/Jiang_You-bou_0013.jpg'], Similarity: 0.10907282680273056
Image Pair: ['Test/test-faces/face943.jpg', 'Family101_150x120/Truman/Harry_S_Truman/Harry_S_Truman_0008.jpg'], Similarity: 0.10907092690467834
Image Pair: ['Family101_150x120/Saudi/Sheikh_Mohammed_bin_Rashid_Al_Maktroum/Sheikh_Mohammed_bin_Rashid_Al_Maktroum_0003.jpg', 'Family101_150x120/Dutt/Sanjay_Dutt/Sanjay_Dutt_0003.jpg'], Similarity: 0.10906761884689331
Image Pair: ['Family101_150x120/Dutt/Nargis_Dutt/Nargis_Dutt_0004.jpg', 'KinFaceW-I/images/father-son/fs_118_2.jpg'], Similarity: 0.10905846953392029
Image Pair: ['Family101_150x120/Presley/Lisa_Marie_Presley/Lisa_Marie_Presley_0001.jpg', 'Family101_150x120/Khan/Soha_Ali_Khan/Soha_Ali_Khan_0009.jpg'], Similarity: 0.10902658104896545
Image Pair: ['Family101_150x120/Dutt/Nargis_Dutt/Nargis_Dutt_0002.jpg', 'Test/test-faces/face2586.jpg'], Similarity: 0.1090153157711029
Image Pair: ['Test/test-faces/face1508.jpg', 'Family101_150x120/Tyler/Liv_Tyler/Liv_Tyler_0007.jpg'], Similarity: 0.10900804400444031
Image Pair: ['Family101_150x120/Sen/Moon_Moon_Sen/Moon_Moon_Sen_0014.jpg', 'Family101_150x120/Dutt/Namrata_Dutt/Namrata_Dutt_0012.jpg'], Similarity: 0.10900337994098663
Image Pair: ['Family101_150x120/Sheen/Martin_Sheen/Martin_Sheen_0015.jpg', 'Family101_150x120/Williams/Jett_Williams/Jett_Williams_0002.jpg'], Similarity: 0.10899621248245239
Image Pair: ['Family101_150x120/Spelling/Candy_Spelling/Candy_Spelling_0012.jpg', 'Family101_150x120/Dutt/Sanjay_Dutt/Sanjay_Dutt_0002.jpg'], Similarity: 0.1089802086353302
--------------------
hard KIN cosine similarities:
Image Pair: ['Family101_150x120/Osbourne/Ozzy_Osbourne/Ozzy_Osbourne_0012.jpg', 'Family101_150x120/Osbourne/Jack_Osbourne/Jack_Osbourne_0011.jpg'], Similarity: 0.22507473826408386
Image Pair: ['Family101_150x120/Osbourne/Ozzy_Osbourne/Ozzy_Osbourne_0012.jpg', 'Family101_150x120/Osbourne/Jack_Osbourne/Jack_Osbourne_0012.jpg'], Similarity: 0.19801682233810425
Image Pair: ['Family101_150x120/Osbourne/Ozzy_Osbourne/Ozzy_Osbourne_0012.jpg', 'Family101_150x120/Osbourne/Jack_Osbourne/Jack_Osbourne_0018.jpg'], Similarity: 0.18423673510551453
Image Pair: ['Family101_150x120/Smith/Sheree_Smith/Sheree_Smith_0006.jpg', 'Family101_150x120/Smith/Trey_Smith/Trey_Smith_0012.jpg'], Similarity: 0.18136078119277954
Image Pair: ['Family101_150x120/Sen/Moon_Moon_Sen/Moon_Moon_Sen_0007.jpg', 'Family101_150x120/Sen/Raima_Sen/Raima_Sen_0015.jpg'], Similarity: 0.17209522426128387
Image Pair: ['Test/test-faces/face570.jpg', 'Test/test-faces/face1591.jpg'], Similarity: 0.16818219423294067
Image Pair: ['Family101_150x120/Sen/Moon_Moon_Sen/Moon_Moon_Sen_0007.jpg', 'Family101_150x120/Sen/Raima_Sen/Raima_Sen_0013.jpg'], Similarity: 0.1603042185306549
Image Pair: ['Family101_150x120/Spelling/Candy_Spelling/Candy_Spelling_0016.jpg', 'Family101_150x120/Spelling/Randy_Spelling/Randy_Spelling_0016.jpg'], Similarity: 0.1595291793346405
Image Pair: ['Family101_150x120/Jiang/Chiang_Ching-kuo/Chiang_Ching-kuo_0002.jpg', 'Family101_150x120/Jiang/Jiang_Hsiao-wen/Jiang_Hsiao-wen_0002.jpg'], Similarity: 0.15605446696281433
Image Pair: ['Family101_150x120/Osbourne/Ozzy_Osbourne/Ozzy_Osbourne_0012.jpg', 'Family101_150x120/Osbourne/Jack_Osbourne/Jack_Osbourne_0007.jpg'], Similarity: 0.15602163970470428
Image Pair: ['Family101_150x120/Jiang/Chiang_Ching-kuo/Chiang_Ching-kuo_0008.jpg', 'Family101_150x120/Jiang/Jiang_Hsiao-wen/Jiang_Hsiao-wen_0002.jpg'], Similarity: 0.15576261281967163
Image Pair: ['Family101_150x120/Sen/Moon_Moon_Sen/Moon_Moon_Sen_0006.jpg', 'Family101_150x120/Sen/Raima_Sen/Raima_Sen_0015.jpg'], Similarity: 0.15427076816558838
Image Pair: ['Family101_150x120/Osbourne/Ozzy_Osbourne/Ozzy_Osbourne_0012.jpg', 'Family101_150x120/Osbourne/Jack_Osbourne/Jack_Osbourne_0014.jpg'], Similarity: 0.14973363280296326
Image Pair: ['Family101_150x120/Spelling/Candy_Spelling/Candy_Spelling_0016.jpg', 'Family101_150x120/Spelling/Randy_Spelling/Randy_Spelling_0017.jpg'], Similarity: 0.14912647008895874
Image Pair: ['Family101_150x120/Jiang/Chiang_Ching-kuo/Chiang_Ching-kuo_0012.jpg', 'Family101_150x120/Jiang/Jiang_Hsiao-chang/Jiang_Hsiao-chang_0002.jpg'], Similarity: 0.14898532629013062
Image Pair: ['Family101_150x120/Osbourne/Ozzy_Osbourne/Ozzy_Osbourne_0012.jpg', 'Family101_150x120/Osbourne/Jack_Osbourne/Jack_Osbourne_0002.jpg'], Similarity: 0.1472015678882599
Image Pair: ['Family101_150x120/Tyler/Steven_Tyler/Steven_Tyler_0018.jpg', 'Family101_150x120/Tyler/Liv_Tyler/Liv_Tyler_0022.jpg'], Similarity: 0.14504525065422058
Image Pair: ['Family101_150x120/Jiang/Chiang_Ching-kuo/Chiang_Ching-kuo_0012.jpg', 'Family101_150x120/Jiang/Jiang_Hsiao-wen/Jiang_Hsiao-wen_0002.jpg'], Similarity: 0.1431746780872345
Image Pair: ['Family101_150x120/Sen/Moon_Moon_Sen/Moon_Moon_Sen_0006.jpg', 'Family101_150x120/Sen/Raima_Sen/Raima_Sen_0028.jpg'], Similarity: 0.14277368783950806
Image Pair: ['Test/test-faces/face1632.jpg', 'Test/test-faces/face615.jpg'], Similarity: 0.14237180352210999
Image Pair: ['Family101_150x120/Jiang/Chiang_Ching-kuo/Chiang_Ching-kuo_0005.jpg', 'Family101_150x120/Jiang/Jiang_Hsiao-wen/Jiang_Hsiao-wen_0002.jpg'], Similarity: 0.1412714123725891
Image Pair: ['Family101_150x120/Sen/Moon_Moon_Sen/Moon_Moon_Sen_0007.jpg', 'Family101_150x120/Sen/Raima_Sen/Raima_Sen_0028.jpg'], Similarity: 0.13817720115184784
Image Pair: ['Family101_150x120/Jiang/Chiang_Ching-kuo/Chiang_Ching-kuo_0005.jpg', 'Family101_150x120/Jiang/Jiang_Hsiao-chang/Jiang_Hsiao-chang_0001.jpg'], Similarity: 0.13574223220348358
Image Pair: ['Family101_150x120/Jiang/Chiang_Ching-kuo/Chiang_Ching-kuo_0006.jpg', 'Family101_150x120/Jiang/Jiang_Hsiao-chang/Jiang_Hsiao-chang_0001.jpg'], Similarity: 0.1349644958972931
Image Pair: ['Family101_150x120/Jiang/Chiang_Ching-kuo/Chiang_Ching-kuo_0004.jpg', 'Family101_150x120/Jiang/Jiang_Hsiao-wen/Jiang_Hsiao-wen_0002.jpg'], Similarity: 0.13485784828662872
Image Pair: ['Family101_150x120/Sen/Moon_Moon_Sen/Moon_Moon_Sen_0007.jpg', 'Family101_150x120/Sen/Raima_Sen/Raima_Sen_0031.jpg'], Similarity: 0.13237987458705902
Image Pair: ['Family101_150x120/Smith/Sheree_Smith/Sheree_Smith_0004.jpg', 'Family101_150x120/Smith/Trey_Smith/Trey_Smith_0012.jpg'], Similarity: 0.13193681836128235
Image Pair: ['Family101_150x120/Sen/Bharat_Dev_Varma/Bharat_Dev_Varma_0005.jpg', 'Family101_150x120/Sen/Riya_Sen/Riya_Sen_0001.jpg'], Similarity: 0.1316407322883606
Image Pair: ['Test/test-faces/face77.jpg', 'Test/test-faces/face4820.jpg'], Similarity: 0.13016104698181152
Image Pair: ['Family101_150x120/Jiang/Chiang_Kai-shek/Chiang_Kai-shek_0012.jpg', 'Family101_150x120/Jiang/Chiang_Ching-kuo/Chiang_Ching-kuo_0001.jpg'], Similarity: 0.1291065216064453
--------------------
hard non-KIN cosine similarities:
Image Pair: ['Family101_150x120/Power/Tyrone_Power_Jr/Tyrone_Power_Jr_0015.jpg', 'Family101_150x120/Presley/Danielle_Riley_Keough/Danielle_Riley_Keough_0015.jpg'], Similarity: -0.10917934775352478
Image Pair: ['Family101_150x120/Ritter/Nancy_Morgan/Nancy_Morgan_0004.jpg', 'Test/test-faces/face5020.jpg'], Similarity: -0.10918864607810974
Image Pair: ['Family101_150x120/Stiller/Anne_Meara/Anne_Meara_0007.jpg', 'Family101_150x120/Jiang/Jiang_Hsiao-chang/Jiang_Hsiao-chang_0002.jpg'], Similarity: -0.10920095443725586
Image Pair: ['Family101_150x120/Power/Tyrone_Power_Jr/Tyrone_Power_Jr_0009.jpg', 'Family101_150x120/Rockefeller/David_Rockefeller_Jr/David_Rockefeller_Jr_0009.jpg'], Similarity: -0.10920779407024384
Image Pair: ['Family101_150x120/Williams/Hank__Williams/Hank__Williams_0018.jpg', 'Family101_150x120/Dutt/Namrata_Dutt/Namrata_Dutt_0019.jpg'], Similarity: -0.10921040177345276
Image Pair: ['Family101_150x120/Presley/Elvis_Presley/Elvis_Presley_0003.jpg', 'Family101_150x120/Sen/Riya_Sen/Riya_Sen_0024.jpg'], Similarity: -0.10921400040388107
Image Pair: ['Family101_150x120/Sen/Moon_Moon_Sen/Moon_Moon_Sen_0022.jpg', 'Test/test-faces/face2405.jpg'], Similarity: -0.10921767354011536
Image Pair: ['Family101_150x120/Victoria/Queen_Silvia/Queen_Silvia_0008.jpg', 'Test/test-faces/face5044.jpg'], Similarity: -0.10923165082931519
Image Pair: ['Family101_150x120/Tyler/Steven_Tyler/Steven_Tyler_0026.jpg', 'Family101_150x120/Dutt/Namrata_Dutt/Namrata_Dutt_0011.jpg'], Similarity: -0.10924015939235687
Image Pair: ['Family101_150x120/Sheen/Martin_Sheen/Martin_Sheen_0013.jpg', 'Family101_150x120/Tyler/Mia_Tyler/Mia_Tyler_0009.jpg'], Similarity: -0.10925218462944031
Image Pair: ['Test/test-faces/face3221.jpg', 'Family101_150x120/Ritter/John_Ritter/John_Ritter_0003.jpg'], Similarity: -0.10926280915737152
Image Pair: ['Family101_150x120/Dutt/Sunil_Dutt/Sunil_Dutt_0007.jpg', 'Family101_150x120/Babbar/Arya_Babbar/Arya_Babbar_0013.jpg'], Similarity: -0.10927216708660126
Image Pair: ['Family101_150x120/Tyler/Steven_Tyler/Steven_Tyler_0017.jpg', 'Family101_150x120/Bo/Bo_Guagua/Bo_Guagua_0015.jpg'], Similarity: -0.10928894579410553
Image Pair: ['Family101_150x120/Walton/Susie_Walton/Susie_Walton_0001.jpg', 'Family101_150x120/Smith/Trey_Smith/Trey_Smith_0007.jpg'], Similarity: -0.10929001867771149
Image Pair: ['Test/test-faces/face3911.jpg', 'KinFaceW-II/images/mother-son/ms_015_2.jpg'], Similarity: -0.10931336879730225
Image Pair: ['Family101_150x120/Sen/Moon_Moon_Sen/Moon_Moon_Sen_0018.jpg', 'Family101_150x120/Babbar/Pratik_Babbar/Pratik_Babbar_0002.jpg'], Similarity: -0.10931450128555298
Image Pair: ['Family101_150x120/Osbourne/Sharon_Osbourne/Sharon_Osbourne_0005.jpg', 'Family101_150x120/Sinatra/Frank_Sinatra_Jr/Frank_Sinatra_Jr_0008.jpg'], Similarity: -0.10933243483304977
Image Pair: ['Family101_150x120/Osbourne/Ozzy_Osbourne/Ozzy_Osbourne_0015.jpg', 'Test/test-faces/face1429.jpg'], Similarity: -0.10933668911457062
Image Pair: ['Family101_150x120/Osbourne/Ozzy_Osbourne/Ozzy_Osbourne_0015.jpg', 'Test/test-faces/face1429.jpg'], Similarity: -0.10933668911457062
Image Pair: ['Family101_150x120/Presley/Lisa_Marie_Presley/Lisa_Marie_Presley_0032.jpg', 'Family101_150x120/Smith/Jaden_Smith/Jaden_Smith_0012.jpg'], Similarity: -0.10935328900814056
Image Pair: ['Family101_150x120/Osbourne/Ozzy_Osbourne/Ozzy_Osbourne_0005.jpg', 'Family101_150x120/Sheen/Charlie_Sheen/Charlie_Sheen_0003.jpg'], Similarity: -0.10938329994678497
Image Pair: ['Family101_150x120/Rockefeller/David_Rockefeller/David_Rockefeller_0013.jpg', 'Family101_150x120/Dutt/Priya_Dutt/Priya_Dutt_0005.jpg'], Similarity: -0.10939311981201172
Image Pair: ['Test/test-faces/face4927.jpg', 'Test/test-faces/face4434.jpg'], Similarity: -0.10940797626972198
Image Pair: ['Test/test-faces/face1749.jpg', 'Family101_150x120/Tsuguko/Prince_Takamado/Prince_Takamado_0001.jpg'], Similarity: -0.10940991342067719
Image Pair: ['Family101_150x120/Jiang/Soong_may-ling/Soong_may-ling_0006.jpg', 'Family101_150x120/Babbar/Juhi_Babbar/Juhi_Babbar_0010.jpg'], Similarity: -0.10941725224256516
Image Pair: ['Family101_150x120/Victoria/Queen_Silvia/Queen_Silvia_0015.jpg', 'Family101_150x120/Sen/Riya_Sen/Riya_Sen_0008.jpg'], Similarity: -0.10946708172559738
Image Pair: ['Test/test-faces/face3976.jpg', 'Family101_150x120/Smith/Willow_Smith/Willow_Smith_0001.jpg'], Similarity: -0.10947421193122864
Image Pair: ['Family101_150x120/Sinatra/Frank_Sinatra/Frank_Sinatra_0008.jpg', 'Family101_150x120/Khan/Soha_Ali_Khan/Soha_Ali_Khan_0006.jpg'], Similarity: -0.10948339104652405
Image Pair: ['Family101_150x120/Spelling/Aaron_Spelling/Aaron_Spelling_0002.jpg', 'Family101_150x120/Khan/Saif_Ali_Khan/Saif_Ali_Khan_0006.jpg'], Similarity: -0.10949453711509705
Image Pair: ['Family101_150x120/Sen/Bharat_Dev_Varma/Bharat_Dev_Varma_0005.jpg', 'Family101_150x120/Victoria/Princess_Victoria/Princess_Victoria_0028.jpg'], Similarity: -0.10949501395225525

Treinamento na RIG2 está em curso. Precisei remover dtype de np2tensor em dataset.py, pois o autor atualizou o código. Isso implica que meu treinamento foi feito com kinship como inteiro, enquanto que na RIG2, esse label está como float. Nada problemático.

É importante citar, também, que eu estou usando Python 3.11.6 localmente e 3.10.12 na RIG2. Removi as versões pinadas dos pacotes.

Localmente

Package Requirements Version Installed Version
einops 0.6.1 0.7.0
keras 2.7.0 2.15.0
matplotlib 3.4.3 3.8.2
numpy 1.21.1 1.26.3
pandas 1.2.4 2.1.4
scikit_learn 0.24.2
scipy 1.7.1 1.11.4
seaborn 0.11.1 0.13.1
torch 1.10.1 2.1.2
torchvision 0.11.2 0.16.2
tqdm 4.59.0 4.66.1

RIG2

Package Requirements Version Installed Version
einops 0.6.1 0.7.0
keras 2.7.0 2.15.0
matplotlib 3.4.3 3.8.2
numpy 1.21.1 1.26.3
pandas 1.2.4 2.2.0
scikit_learn 0.24.2 but not installed
scipy 1.7.1 1.12.0
seaborn 0.11.1 0.13.1
torch 1.10.1 2.1.2
torchvision 0.11.2 0.16.2
tqdm 4.59.0 4.66.1

Em ambos os casos foi instalado o tensorflow 2.15.0.post1, um pacote necessário, mas não presente no requirements.txt.

@vitalwarley
Copy link
Owner Author

vitalwarley commented Jan 23, 2024

Penso que os resultados abaixo (saída de test.py) são do próprio KinRace

fd : 0.7830224752517313
md : 0.8429052730549244
fs : 0.8413508570456382
ms : 0.790169133192389
avg : 0.8161955975255208

todavia não sei qual das tabelas no paper seria a correta a comparar.

image
image
image

Avaliarei na RIG2 assim que o treinamento lá em curso acabar.

@vitalwarley
Copy link
Owner Author

RIG2 off.

@vitalwarley
Copy link
Owner Author

*************
epoch 100
total_loss:1.681790
kinship_loss:0.057413
race_loss:1.624377
race margin:  [tensor(0.0765, grad_fn=<DivBackward0>), tensor(0.1486, grad_fn=<DivBackward0>), tensor(0.0209, grad_fn=<DivBackward0>), tensor(-0.1239, grad_fn=<DivBackward0>)]
auc is 0.866994
std is 0.033332
auc did not improve from 0.903749
➜  KFC git:(main) ✗ cat log_files/log_find.txt
auc :  0.8809779349594808
threshold : 0.08373381197452545
➜  KFC git:(main) ✗ cat log_files/log_test.txt
number of false negative pairs:  8055
false negative rate:  0.08803855990556758
number of false positive pairs:  10478
false positive rate:  0.11452117078715544
fd : 0.7729957088838849
md : 0.8245710256209355
fs : 0.8146399557653864
ms : 0.7698731501057082
avg : 0.797440269307277

@vitalwarley
Copy link
Owner Author

Referente à tabela 6, temos as médias abaixo, o que indica que #51 é o SOTA no FIW, considerando apenas os quatro principais parentescos.

Vuvko[30]: Mean = 77.00
Ustc-nelslip[44]: Mean = 77.00
TeamCNU[46]: Mean = 78.50
FaCoRNet(ArcFace)[31]: Mean ≈ 79.77
FaCoRNet(AdaFace)[31]: Mean ≈ 81.58
KFC(multi-task): Mean ≈ 81.38
KFC(adversarial): Mean ≈ 80.12

@vitalwarley
Copy link
Owner Author

Referente ao treinamento na RIG2

image

Margin, acredito, refere-se ao viés de cada amostra. No gráfico, refere-se à média para cada raça: AA (African), A (Asian), C (Caucasian), I (Indian).

@vitalwarley
Copy link
Owner Author

vitalwarley commented Mar 13, 2024

No gráfico acima, temos 0.90375 AUC @ epoch 5. Abaixo, temos um treinamento sem aprendizado adversarial, que segundo os autores foi o melhor em termos de acurácia em reconhecimento de parentesco

mt_race

  • Podemos notar que Race Loss diminuiu drasticamente, mas ao menos a AUC foi inferior que o treinamento anterior. Deveria ser maior, não?
  • Por outro lado, a variação da acurácia sobre as diferentes raças foi maior, como esperado.
  • A margem/viés também foi absolutamente maior, exceto talvez a margem de A? Dado que A tem mais amostras, e que a margem é computada considerando ambas as posições do par, faz sentido esse equilíbrio -- o sinal da margem/viés muda a depender da posição: positivo à esquerda, negativo à direita.
  • A diferença nesse treinamento é que usei batch_size = 60, enquanto que acima usei batch_size = 25.

@vitalwarley
Copy link
Owner Author

vitalwarley commented Mar 13, 2024

Multi-task RACE + KIN

Treinamento com uma nova camada HeadKin, usada para classificação de parentesco: fs, fd, ms, md, non-kin.

mt_race_kin_fixed

Podemos ver um crescimento na acurácia do classificador de parentesco (KR) e do verificador de parentesco (KV), enquanto que a AUC permanece mais ou menos estável.

Abaixo distribuição das amostras em termos de parentesco, tipo de parentesco e raça.

KinRace Train Set
plot_train

KinRace Val Set 1

Os dados são balanceados em termos de tipo de parentesco e existência de parentesco. Em termos desses junto à raça, creio que não, todavia o que importa é a existência de parentesco mesmo.

  Is_Kin Kinship_Type  Frequency
0      0           fd       1972
1      0           fs       1972
2      0           md       1972
3      0           ms       1972
4      1           fd       1846
5      1           fs       2243
6      1           md       1873
7      1           ms       1766
class HeadKin(nn.Module):  # couldn't be HeadFamily because there is no family label
    def __init__(self,in_features=512,out_features=4,ratio=8):
        super().__init__()
        self.projection_head=nn.Sequential(
            torch.nn.Linear(in_features*2, in_features//ratio),
            torch.nn.BatchNorm1d(in_features//ratio),
            torch.nn.ReLU(),
            torch.nn.Linear(in_features//ratio, out_features),
        )
        
        self.initialize_weights(self.projection_head)
        
    def initialize_weights(self,proj_head):
        for m in proj_head.modules():
            if isinstance(m, nn.Linear):
                nn.init.uniform_(m.weight -0.05, 0.05)
                if m.bias is not None:
                    nn.init.constant_(m.bias, 0)
            elif isinstance(m, nn.BatchNorm1d):
                nn.init.constant_(m.weight, 1)
                nn.init.constant_(m.bias, 0)
    def forward(self,em):
        return self.projection_head(em)

Enquanto que na inferência temos

... # init
        self.task_kin=HeadKin(512,4,5) # fd, md, fs, ms, non-kin
... # foward
        e1e2 = torch.cat([e1,e2],dim=1)
        kin=self.task_kin(e1e2)  

E na validação

        kin_pred.extend(torch.argmax(kin,dim=1).cpu().detach().numpy().tolist())
        kin_true.extend(kinship.cpu().detach().numpy().tolist())
...
    kin_acc = np.mean(np.array(kin_pred) == np.array(kin_true))

Logo penso que não erro na implementação.

@vitalwarley
Copy link
Owner Author

vitalwarley commented Mar 13, 2024

Multi-task RACE + KIN + WEIGHTED LOSS

Outro experimento realizado, onde modifiquei a perda total com pesos para cada classificador.

            loss = (1 - loss_race_factor - loss_kin_factor) * kinship_loss + loss_race_factor * race_loss + loss_kin_factor * kin_loss

Os pesos/fatores são 0.2 para cada.

Todavia, o treinamento procede com o mesmo comportamento.

mt_race_kin_wfactor

@vitalwarley
Copy link
Owner Author

vitalwarley commented Mar 14, 2024

Multi-task RACE (+ADV) + KIN + WEIGHTED LOSS

Mais um experimento: similar ao anterior, mas com gradiente reverso para o classificador de raça. É notável a remoção de vieses de raça, vide a margem ao longo das épocas, mas apenas para AA, pois as demais se mantém como antes -- inclusive a variação da acurácia entre as raças (_Epoch vs STD). Talvez a classificação de parentesco force o modelo a manter algum tipo de viés?

Outro detalhe interessante é que a perda Race Loss não desceu como as demais. Talvez similar ao treinamento do melhor modelo e, de certa forma, uma evidência do que falei antes sobre o classificador de parentesco.

mt_race_adv_kin_wfactor

Não adicionei um gradiente reverso ao classificador de parentesco porque não vejo sentido em remover atributos de parentesco. São úteis à verificação, eu penso.

Segue algumas ideias que quero tentar

  • Modificar computação do mapa de atenção para ser similar à FaCoRNet
    • Usar mapa de atenção na perda -- penso que seja o único componente faltante na rede KFC relativa à FaCoRNet
  • Avaliar diferentes mecanismos de interação de canais (vide Attention mechanisms in computer vision: A survey e Dual Attention Network for Scene Segmentation) no lugar do CBAM
  • Classificador de família no lugar do classificador de parentesco
    • Não sei a viabilidade, dado que preciso alterar o .csv do dataset KinRace. É mais fácil tentar isso junto à FaCoRNet. Lembremo-nos que classificação de família foi uma etapa do SOTA2020 (Achieving Better Kinship Recognition Through Better Baseline, Review Shadrikov's reproduction status #24)

Penso que essa avaliação incremental pode me guiar melhor no que propor. Faltam-me conhecimento mais baixo nível sobre o funcionamento dos componentes (e.g. CBAM), bem como sobre que componente realmente avançou o SOTA dentro desses últimos trabalhos.

Para que esses experimentos sejam reproduzíveis, é preciso refatorar o código. Atualmente mudo o código para cada experimento, o que implica perder as mudanças que fiz. Nesse final de semana tratarei disso. O ganho não será só na reprodutibilidade, mas em poder realizar diversos experimentos simultâneos.

@vitalwarley
Copy link
Owner Author

vitalwarley commented Mar 14, 2024

Multi-task RACE (+ADV) + KIN

mt_race_adv_kin

@vitalwarley
Copy link
Owner Author

vitalwarley commented Mar 14, 2024

Refiz dois experimentos para obter também a acurácia e comparar com os experimentos que já fiz.

Multi-task RACE (+ADV)

mt_race_adv

Multi-task RACE

mt_race

@vitalwarley
Copy link
Owner Author

#71 (comment)

➜  KFC git:(main) ✗ python train.py --batch_size 60 \
                --sample ./data_files \
                --save_path ./log_files_mt_race_kin_fixed_headkin \
                --epochs 20 \
                --log_path log_files_mt_race_kin_fixed_headkin/train.txt \
                --gpu 1

com instanciação correta para HeadKin

+        self.task_kin=HeadKin(512,5,8) # fd, md, fs, ms, non-kin

À comparar com #52 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant