Definition at line 60 of file mainConceptLearnClient.cpp. References Impala::Application::ActiveLearnEngineQuids::AddNegative(), Impala::Application::ActiveLearnEngineQuids::AddPositive(), Impala::Application::ActiveLearnEngineQuids::AddRandomNegatives(), Impala::Application::ActiveLearnEngineQuids::GetErrCount(), Impala::Core::VideoSet::Keyframes::GetFrameId(), Impala::Core::VideoSet::Segmentation::GetName(), Impala::Core::VideoSet::Keyframes::GetShotId(), Impala::Application::ActiveLearnEngineQuids::HasResults(), ILOG_DEBUG, ILOG_ERROR, ILOG_INFO, mALE, mKeyframes, mSegmentation, ParseQuid(), Impala::Application::ActiveLearnEngineQuids::PrepareNewID(), Impala::Application::ActiveLearnEngineQuids::PrepRequest(), Impala::QuidSet(), Impala::Application::ActiveLearnEngineQuids::Ready(), Impala::Application::ActiveLearnEngineQuids::RequestSubmitted(), Impala::Application::ActiveLearnEngineQuids::RetrieveResults(), Impala::Timer::SplitTime(), and Impala::Application::ActiveLearnEngineQuids::SubmitRequest(). Referenced by ConceptLearnClient(). 00061 { 00062 Timer tim; 00063 int ctim = tim.SplitTime(); 00064 int manReset; 00065 00066 manReset = 1; 00067 00068 bool done = false; 00069 00070 while (!done) 00071 { 00072 // load stage or print stage? 00073 if (!mALE->RequestSubmitted()) 00074 { 00075 ILOG_INFO("Sending data to ALE..."); 00076 // load stage: 00077 00078 mALE->PrepRequest(); 00079 00080 // read positive keyframes from file: 00081 00082 std::ifstream f("quids_positive.txt"); 00083 while (! f.eof() ) 00084 { 00085 std::string line; 00086 f >> line; 00087 if (line == "") break; 00088 Quid q = ParseQuid(line); 00089 if (q<0) { 00090 continue; 00091 } 00092 00093 ILOG_DEBUG("Positive:" << QuidObj(q)); 00094 mALE->AddPositive(q); 00095 } 00096 f.close(); 00097 00098 00099 // read negatives: 00100 00101 std::ifstream fneg("quids_negative.txt"); 00102 bool nolines = TRUE; 00103 while (! fneg.eof() ) 00104 { 00105 std::string line; 00106 fneg >> line; 00107 if (line == "") break; 00108 Quid q = ParseQuid(line); 00109 if (q<0) { 00110 continue; 00111 } 00112 nolines = FALSE; 00113 ILOG_DEBUG("Negative:" << QuidObj(q)); 00114 mALE->AddNegative(q); 00115 } 00116 fneg.close(); 00117 00118 if (nolines) 00119 { 00120 ILOG_DEBUG("Adding random negatives..."); 00121 mALE->AddRandomNegatives(50); 00122 } 00123 00124 if (!mALE->Ready()) 00125 { 00126 ILOG_ERROR("ALE not ready. Aborting."); 00127 return; 00128 } 00129 00130 // submit request: 00131 mALE->SubmitRequest(); 00132 // .. and wait! 00133 00134 while (ctim+4 > tim.SplitTime()); 00135 ctim = tim.SplitTime(); 00136 00137 } else { 00138 if (mALE->HasResults()) 00139 { 00140 // retrieve sage: 00141 ILOG_INFO("Receiving data..."); 00142 std::list<Core::Trec::QuidResult> quids = mALE->RetrieveResults(); 00143 00144 if (quids.size() > 0 && mALE->GetErrCount() < 200) 00145 { 00146 std::ostringstream b; 00147 b << "result.txt"; 00148 std::string ofname = b.str(); 00149 std::ofstream out(ofname.c_str(), std::ios::out); 00150 std::list<Core::Trec::QuidResult>::iterator i = quids.begin(); 00151 00152 while (i != quids.end()) 00153 { 00154 if (QuidSet(i->quid) == 14) 00155 { 00156 int keyid = mKeyframes->GetFrameId(i->quid); 00157 if (keyid > -1) 00158 { 00159 int shotid = mKeyframes->GetShotId(keyid); 00160 std::string shotname = mSegmentation->GetName(shotid); 00161 out << shotname << " " << i->rank << " " << i->score << std::endl; 00162 } 00163 } 00164 //out << "0" << topic << " Q0 " << shotname << " " << i->rank << " " << i->score << std::endl; 00165 i++; 00166 } 00167 out.close(); 00168 return; 00169 manReset = 1; 00170 } else { 00171 ILOG_INFO("Results not yet valid, retrying..."); 00172 // wait a while... 00173 while (ctim+3 > tim.SplitTime()); 00174 ctim = tim.SplitTime(); 00175 } 00176 00177 manReset++; 00178 if (manReset >3) 00179 { 00180 ILOG_ERROR("We have waited too long, resetting..."); 00181 mALE->PrepareNewID(); 00182 manReset = 1; 00183 } /*else 00184 { 00185 ILOG_ERROR("FAILURE: could not find results for this set."); 00186 done = true; 00187 } */ 00188 } else { 00189 // no results yet, wait some more. 00190 while (ctim+3 > tim.SplitTime()); 00191 ctim = tim.SplitTime(); 00192 } 00193 } 00194 00195 } 00196 00197 }
Here is the call graph for this function: ![]()
|