void Accessor::Load( lpxmlnode pNode) { m_source = GetAttributeStringValue("source", pNode); m_count = GetAttributeIntegerValue("count", pNode); m_stride = GetAttributeIntegerValue("stride", pNode); uint i=0; lpxmlnode pCurrNode = pNode->first_node(); do { std::string Name = pCurrNode->name(); if(Name == "param") { Param prm; prm.Load(pCurrNode); m_param.push_back(prm); } pCurrNode = pCurrNode->next_sibling(); } while(pCurrNode != NULL); }
int main(int argc, char* argv[]) { OPTIONS opt; if(!LoadConfiguration(argc, argv, opt)) return 1; clock_t time_b, time_e; time_b = clock(); try { // load input lists CFileList files("Files"); CFileList **fileLists; loadFileLists(files, opt); // load GMM GMModel GMM; if (GMM.Load(opt.GMM_file.c_str(), opt.load_txt) != 0) { error_report = string("GMM model [") + opt.GMM_file + "] not found"; throw runtime_error(error_report.c_str()); } unsigned int M = GMM.GetNumberOfMixtures(); unsigned int D = GMM.GetDimension(); // prepare estimator GMMStatsEstimator<realT> *estimator; if(opt.SSEacc) { estimator = new GMMStatsEstimator_SSE <realT>; } #ifdef _CUDA else if(opt.CUDAacc) { estimator = new GMMStatsEstimator_CUDA <realT> (opt.cudaGPUid); } #endif else { estimator = new GMMStatsEstimator <realT>; } if(opt.verbosity > 1) cout << " [" << estimator->getEstimationType().c_str() << " Estimation ON]" << endl; estimator->insertModel(GMM); estimator->_numThreads = opt.numThreads; estimator->_verbosity = opt.verbosity; char *filename; string outFileName; if(opt.verbosity > 1) cout << "Log-likes are going to be computed [#files = " << files.ListLength() << "]" << endl; float *outLLs = NULL; unsigned int outLLs_size = 0; Param param; files.Rewind(); while(files.GetItemName(&filename)) { if(param.Load(filename, opt.load_type, opt.dwnsmp) != 0) { cerr << "WARNING: Param file [" << filename << "] not found -> skipped!" << endl; continue; } unsigned int NSamples = (unsigned int) param.GetNumberOfVectors(); unsigned int prmdim = (unsigned int) param.GetVectorDim(); if(NSamples < 1 && opt.verbosity > 1) { cerr << "WARNING: Param file [" << filename << "] empty" << endl; continue; } if (NSamples > outLLs_size) { delete[] outLLs; outLLs = new float [NSamples]; outLLs_size = NSamples; } estimator->compVecsLogLikeMT(*param.GetVectors(), NSamples, prmdim, outLLs); if(estimator->_fNumStabilityTroubles) { cerr << "WARNING: numerical stability troubles detected [file> " << filename << "]" << endl; estimator->_fNumStabilityTroubles = false; } if (opt.forEachVec) { string foo(filename); GetNewPath(outFileName, foo, opt.outputDir, opt.outExt); saveMat<float> (outFileName.c_str(), opt.save_txt, outLLs, 1, NSamples); } else { float meanLL = 0.0f; for (unsigned int n = 0; n < NSamples; n++) meanLL += outLLs[n]; meanLL /= NSamples; cout << "\r" << filename << "\t" << meanLL << "\n"; } } delete estimator; delete[] outLLs; } catch (bad_alloc& ba) { cerr << "Out of memory!" << endl; cerr << ba.what() << endl; } catch (exception& e) { cerr << e.what() << endl; } catch (...) { cerr << "Unknown exception caught!" << endl << "Please, contact the developer." << endl; } time_e = clock(); if(opt.verbosity > 1) cout << endl << "[Processing time = " << (time_e - time_b)/(double) CLOCKS_PER_SEC << " seconds]" << endl; return 0; }