Home || Visual Search || Applications || Architecture || Important Messages || OGL || Src

void Impala::Core::Table::BayesFusion::ExecuteBayesFusion ( double  alpha,
bool  bUseAnnoMatrix = true 
) [inline]

Definition at line 210 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::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, Impala::Core::Table::Bayes::mImgSet, Impala::Core::Table::Bayes::mIsImageSet, 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().

00211     {
00212         if (!bUseAnnoMatrix)
00213         {
00214             // load Prob_c_g[][] from ground truth of test set
00215             LoadMatrix(false);
00216         }
00217 
00218         // load genre similarity tables
00219         for (int j=0 ; j<mGenreNum ; j++)
00220             genreSimTable[j] = mGenreSimSet->GetSimTable(j);
00221 
00222         //for (int k=0 ; k<mConceptSimSet->NrTables() ; k++)
00223         //_ASSERT(mConceptNum == mConceptSimSet->NrTables());
00224         for (int k=0 ; k<mConceptNum ; k++)
00225         {
00226             //SimilarityTableSet::SimTableType* conceptSimTable = mConceptSimSet->GetSimTable(k);
00227             conceptSimTable[k] = mConceptSimSet->GetSimTable(k);
00228 
00229             std::cout << "table " << k << ", name = " << mConceptSimSet->GetName(k)
00230                       << std::endl;
00231             if (conceptSimTable[k]->Size() != mQuidTable->Size())
00232             {
00233                 //ILOG_ERROR("DumpRanking: simtable size doesn't match");
00234                 printf("DumpRanking: simtable size doesn't match\n");
00235                 continue;
00236             }
00237 
00238             int nForwardCount = 0;
00239             int nBackwardCount = 0;
00240             double diffForward = 0;
00241             double diffBackward = 0;
00242 
00243             int nPosOutRangeCount=0;
00244             int nNegOutRangeCount=0;
00245 
00246             String concept = mConceptSimSet->GetName(k);
00247             //for (int i=mStart ; i<mEnd ; i++)
00248             for (int i=0 ; i<mTableSize ; i++)
00249             {
00250                 Quid quid = mQuidTable->Get1(i);
00251                 //std::cout << concept << ", ";
00252                 /*if (!mIsImageSet)
00253                 {
00254                     int keyId = mKeyframes->GetFrameId(quid);
00255                     if (keyId != -1)
00256                         std::cout << FileNameBase(mKeyframes->GetName(keyId)) << ", ";
00257                     else
00258                         std::cout << mVidSet->QuidToString(quid, true) << ", ";
00259                 }*/
00260                 std::cout << conceptSimTable[k]->Get1(i) << std::endl;
00261 
00262                 // update the concept scores
00263                 Real64 conceptOldScore = conceptSimTable[k]->Get1(i);
00264 
00265                 Real64 sum = 0;
00266                 for (int j=0; j<mGenreNum; j++)
00267                 {
00268                     Real64 genreScore = genreSimTable[j]->Get1(i);
00269 
00270                     sum += mProb_c_g[k][j] * genreScore;
00271 
00272                     //std::cout << mProb_c_g[k][j] << "*" <<genreScore<< "+" << std:endl;
00273                 }
00274                 //std::cout << std::endl;
00275 
00276                 //Real64 conceptNewScore = sum/mGenreNum;
00277                 //Real64 conceptNewScore = sum;
00278                 //double alpha = 0.95;
00279                 Real64 conceptNewScore = conceptOldScore * alpha + (1-alpha)* sum;
00280                 conceptSimTable[k]->Set1(i,conceptNewScore); // set the new concept score
00281 
00282                 // check positive samples
00283                 Real64 diff;
00284                 if (tabConcept[k]->IsPositive(i))
00285                 {
00286                     diff = conceptNewScore - conceptOldScore;
00287                     if (diff > 0)
00288                     {
00289                         diffForward += diff;
00290                         nForwardCount ++;
00291                     } 
00292                     else 
00293                     {
00294                         diffBackward += diff;
00295                         nBackwardCount ++;
00296                     }
00297 
00298                     if (conceptNewScore > 1 && mVerbose)
00299                     {
00300                         //std::cout << "[+ out of range] New Score: " << conceptNewScore << std::endl;
00301                         nPosOutRangeCount ++;
00302                     }
00303                 }
00304                 else
00305                 {
00306                     if (conceptNewScore > 1 && mVerbose)
00307                     {
00308                         //std::cout << "[- out of range] New Score: " << conceptNewScore << std::endl;
00309                         nNegOutRangeCount ++;
00310                     }
00311                 }
00312             }
00313             //std::cout << std::endl;
00314 
00315             if (mVerbose)
00316             {
00317                 std::cout << "+ [pos moving] ";
00318                 std::cout << "Forward " << nForwardCount << ": " <<  diffForward << ", ";
00319                 std::cout << "Backward " << nBackwardCount << ": " <<  diffBackward << std::endl;
00320 
00321                 std::cout << "+ [out of range]: " << nPosOutRangeCount << " in total" << std::endl;
00322                 std::cout << "- [out of range]: " << nNegOutRangeCount << " in total" << std::endl;
00323             }              
00324         }
00325 
00326         mConceptSimSet->ComputeRanks(true);
00327           
00328         if (mWriteTable)
00329         {
00330             //mImgSet->GetFilePathSimilarityIndex(conceptSet, model,feature, "names.txt",false, false);
00331             //mVidSet->GetFilePathSimilarityIndex(conceptSet, model,feature, "names.txt",false, false);
00332             //Impala::CString outpath = ".\\SimilarityIndex\\concepts.txt\\chi2\\both2-3sift-p112213\\";
00333             String OutPath = mConceptPath;
00334             OutPath.resize(OutPath.size() - 9); // remove "names.txt"
00335 
00336             if (mIsImageSet)
00337                 mConceptSimSet->Save(OutPath, mImgSet->GetDatabase(),true);
00338             else
00339                 mConceptSimSet->Save(OutPath, mVidSet->GetDatabase(),true);
00340             std::cout << "Saving files: " << OutPath << std::endl;
00341         }
00342 
00343     }

Here is the call graph for this function:


Generated on Thu Jan 13 09:20:48 2011 for ImpalaSrc by  doxygen 1.5.1