Definition at line 115 of file mainActiveLearner.cpp. References Impala::Util::DatabaseReadStrings(), Impala::Util::DatabaseWriteString(), Impala::CmdOptions::GetArg(), Impala::Core::Database::RawDataSet::GetDatabase(), Impala::Util::Database::GetFilePath(), Impala::Core::Database::RawDataSet::GetFilePathAnnotation(), Impala::Core::Database::RawDataSet::GetFilePathConceptModel(), ILOG_ERROR, ILOG_INFO, ILOG_VAR, LearnConceptFromAnnotations(), Impala::Core::ImageSet::MakeImageSet(), Impala::Core::VideoSet::MakeVideoSet(), Impala::QUID_CLASS_FRAME, Impala::QUID_CLASS_IMAGE, Impala::Core::Table::Read(), and Impala::Timer::SplitTimeStr(). Referenced by mainActiveLearner(). 00116 { 00117 ILOG_VAR(Application.RunDistributedLearningEngine); 00118 int quidClass = 0; 00119 Core::Database::RawDataSet* dataSet = 0; 00120 String setName = options.GetArg(0); 00121 Util::Database* db = new Util::Database(setName); 00122 String path = db->GetFilePath("ImageData", setName, false, true); 00123 if (! path.empty()) 00124 { 00125 quidClass = QUID_CLASS_IMAGE; 00126 dataSet = ImageSet::MakeImageSet(setName); 00127 } 00128 else 00129 { 00130 quidClass = QUID_CLASS_FRAME; 00131 dataSet = VideoSet::MakeVideoSet(setName); 00132 } 00133 db = dataSet->GetDatabase(); 00134 00135 String modelType = options.GetArg(2); 00136 Feature::FeatureDefinition featureDef(options.GetArg(3)); 00137 00138 int startnode = 1; 00139 int nodes = Link::Mpi::NrProcs() - startnode; 00140 Matrix::DistributedAccess da(options.GetArg(3), dataSet, 0, startnode, nodes); 00141 if(Link::Mpi::MyId() <= nodes + startnode && Link::Mpi::MyId() != 0) 00142 da.StartEventLoop(); 00143 else 00144 { 00145 da.Subscribe(); 00146 ILOG_INFO_NODE("engine loaded, waiting for annotations."); 00147 String conceptsName = options.GetArg(1); //"conceptsActiveLearn.txt"; 00148 00149 while(true) 00150 { 00151 // announce waiting for table 00152 // receive table 00153 00154 String identifier; 00155 00156 while (true) 00157 { 00158 String sfile = dataSet->GetFilePathAnnotation(quidClass, conceptsName, "startlearner.txt", false, true); 00159 if (!sfile.empty()) 00160 { 00161 std::vector<String> blaat; 00162 Util::DatabaseReadStrings(blaat, sfile, db); 00163 if (blaat.size() > 0) 00164 { 00165 identifier = blaat[0]; 00166 ILOG_INFO("Starting model train cycle for " << identifier); 00167 blaat.clear(); 00168 00169 Util::DatabaseWriteString(sfile, db, blaat.begin(), blaat.end()); 00170 break; 00171 } 00172 } 00173 } 00174 00175 Table::AnnotationTable* annotationtable = new Table::AnnotationTable; 00176 00177 String filename = dataSet->GetFilePathAnnotation(quidClass, conceptsName, identifier + ".tab", false, true); 00178 if(filename.empty()) 00179 { 00180 //ILOG_WARN("Annotation file not found for " << identifier); 00181 continue; 00182 } 00183 Read(annotationtable, filename, db); 00184 00185 String modelname = ""; 00186 if(true) // save the moel? 00187 { 00188 modelname = dataSet->GetFilePathConceptModel 00189 (conceptsName, "activelearn", 00190 Feature::FeatureDefinition("activelearn"), 00191 identifier+".model", 00192 true, false); 00193 } 00194 Timer timer; 00195 Table::SimilarityTableSet* simSet = 00196 LearnConceptFromAnnotations(options, da, identifier, modelname, annotationtable, db); 00197 ILOG_INFO("Learned in " << timer.SplitTimeStr()); 00198 00199 if(!simSet) 00200 { 00201 ILOG_ERROR("Learning aborted, no positives or negatives?"); 00202 continue; 00203 } 00204 00205 // save concept 00206 simSet->Save(dataSet, conceptsName, "activelearn", "activelearn", 00207 true); 00208 00209 delete annotationtable; 00210 delete simSet; 00211 00212 ILOG_INFO("Loop done: " << timer.SplitTimeStr()); 00213 } 00214 da.Unsubscribe(); 00215 } 00216 Link::Mpi::Finalize(); 00217 return 0; 00218 }
Here is the call graph for this function:
|