Definition at line 197 of file BayesFusion.h. References Impala::Core::Table::SimilarityTableSet::ComputeRanks(), conceptSimTable, genreSimTable, Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::Core::Database::RawDataSet::GetDatabase(), Impala::Core::VideoSet::Keyframes::GetFrameId(), Impala::Core::Table::SimilarityTableSet::GetName(), Impala::Core::Table::SimilarityTableSet::GetSimTable(), Impala::Core::Table::Bayes::LoadMatrix(), Impala::Core::Table::Bayes::mConceptNum, mConceptPath, mConceptSimSet, Impala::Core::Table::Bayes::mGenreNum, mGenreSimSet, mKeyframes, Impala::Core::Table::Bayes::mProb_c_g, mQuidTable, Impala::Core::Table::Bayes::mTableSize, Impala::Core::Table::Bayes::mVerbose, Impala::Core::Table::Bayes::mVidSet, mWriteTable, Impala::Core::Table::SimilarityTableSet::Save(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Set1(), Impala::Core::Table::Table::Size(), and Impala::Core::Table::Bayes::tabConcept. Referenced by DoFusion(). 00198 { 00199 if (!bUseAnnoMatrix) 00200 { 00201 // load Prob_c_g[][] from ground truth of test set 00202 LoadMatrix(false); 00203 } 00204 00205 // load genre similarity tables 00206 for (int j=0 ; j<mGenreNum ; j++) 00207 genreSimTable[j] = mGenreSimSet->GetSimTable(j); 00208 00209 //for (int k=0 ; k<mConceptSimSet->NrTables() ; k++) 00210 //_ASSERT(mConceptNum == mConceptSimSet->NrTables()); 00211 for (int k=0 ; k<mConceptNum ; k++) 00212 { 00213 //SimilarityTableSet::SimTableType* conceptSimTable = mConceptSimSet->GetSimTable(k); 00214 conceptSimTable[k] = mConceptSimSet->GetSimTable(k); 00215 00216 std::cout << "table " << k << ", name = " << mConceptSimSet->GetName(k) 00217 << std::endl; 00218 if (conceptSimTable[k]->Size() != mQuidTable->Size()) 00219 { 00220 //ILOG_ERROR("DumpRanking: simtable size doesn't match"); 00221 printf("DumpRanking: simtable size doesn't match\n"); 00222 continue; 00223 } 00224 00225 int nForwardCount = 0; 00226 int nBackwardCount = 0; 00227 double diffForward = 0; 00228 double diffBackward = 0; 00229 00230 int nPosOutRangeCount=0; 00231 int nNegOutRangeCount=0; 00232 00233 String concept = mConceptSimSet->GetName(k); 00234 //for (int i=mStart ; i<mEnd ; i++) 00235 for (int i=0 ; i<mTableSize ; i++) 00236 { 00237 Quid quid = mQuidTable->Get1(i); 00238 //std::cout << concept << ", "; 00239 int keyId = mKeyframes->GetFrameId(quid); 00240 /*if (keyId != -1) 00241 std::cout << FileNameBase(mKeyframes->GetName(keyId)) << ", "; 00242 else 00243 std::cout << mVidSet->QuidToString(quid, true) << ", "; 00244 std::cout << conceptSimTable[k]->Get1(i) << std::endl;*/ 00245 00246 // update the concept scores 00247 Real64 conceptOldScore = conceptSimTable[k]->Get1(i); 00248 00249 Real64 sum = 0; 00250 for (int j=0; j<mGenreNum; j++) 00251 { 00252 Real64 genreScore = genreSimTable[j]->Get1(i); 00253 00254 sum += mProb_c_g[k][j] * genreScore; 00255 00256 //std::cout << mProb_c_g[k][j] << "*" <<genreScore<< "+" << std:endl; 00257 } 00258 //std::cout << std::endl; 00259 00260 //Real64 conceptNewScore = sum/mGenreNum; 00261 //Real64 conceptNewScore = sum; 00262 //double alpha = 0.95; 00263 Real64 conceptNewScore = conceptOldScore * alpha + (1-alpha)* sum; 00264 conceptSimTable[k]->Set1(i,conceptNewScore); // set the new concept score 00265 00266 // check positive samples 00267 Real64 diff; 00268 if (tabConcept[k]->IsPositive(i)) 00269 { 00270 diff = conceptNewScore - conceptOldScore; 00271 if (diff > 0) 00272 { 00273 diffForward += diff; 00274 nForwardCount ++; 00275 } 00276 else 00277 { 00278 diffBackward += diff; 00279 nBackwardCount ++; 00280 } 00281 00282 if (conceptNewScore > 1 && mVerbose) 00283 { 00284 //std::cout << "[+ out of range] New Score: " << conceptNewScore << std::endl; 00285 nPosOutRangeCount ++; 00286 } 00287 } 00288 else 00289 { 00290 if (conceptNewScore > 1 && mVerbose) 00291 { 00292 //std::cout << "[- out of range] New Score: " << conceptNewScore << std::endl; 00293 nNegOutRangeCount ++; 00294 } 00295 } 00296 } 00297 //std::cout << std::endl; 00298 00299 if (mVerbose) 00300 { 00301 std::cout << "+ [pos moving] "; 00302 std::cout << "Forward " << nForwardCount << ": " << diffForward << ", "; 00303 std::cout << "Backward " << nBackwardCount << ": " << diffBackward << std::endl; 00304 00305 std::cout << "+ [out of range]: " << nPosOutRangeCount << " in total" << std::endl; 00306 std::cout << "- [out of range]: " << nNegOutRangeCount << " in total" << std::endl; 00307 } 00308 } 00309 00310 mConceptSimSet->ComputeRanks(true); 00311 00312 if (mWriteTable) 00313 { 00314 //mVidSet->GetFilePathSimilarityIndex(conceptSet, model,feature, "names.txt",false, false); 00315 //Impala::CString outpath = ".\\SimilarityIndex\\concepts.txt\\chi2\\both2-3sift-p112213\\"; 00316 String OutPath = mConceptPath; 00317 OutPath.resize(OutPath.size() - 9); // remove "names.txt" 00318 00319 mConceptSimSet->Save(OutPath, mVidSet->GetDatabase(),true); 00320 std::cout << "Saving files: " << OutPath << std::endl; 00321 } 00322 00323 }
Here is the call graph for this function:
|