Beispiel #1
0
/** argument error checking: any data? consistent multiclass or pos/neg purpose?
 *  having Negative purpose samples and multiclass is fine, but
 *  having Positive and multiclass is probably incorrect.  WARN.
 */
bool BowICETrainI::checkPurposedLists(
    const PurposedListSequence& purposedLists,
    TrainerCallbackHandlerPrx& _callback )
{
  if(purposedLists.size() == 0)
  {
    localAndClientMsg(VLogger::WARN, _callback, 
                      "Error: no data (runset) for processing\n");
    return false;
  }

  bool havemul = false;
  bool havepos = false;
  bool haveneg = false;
  maxClassId = -1;
  for (size_t listidx = 0; listidx < purposedLists.size(); listidx++)
  {
    Purpose& pur = purposedLists[listidx]->pur;
    switch(pur.ptype)
    {
    case cvac::POSITIVE:
      {
        havepos = true;
        break;
      }
    case cvac::NEGATIVE:
      {
        haveneg = true;
        break;
      }
    case cvac::MULTICLASS:
      {
        havemul = true;
        if (pur.classID>maxClassId)
        {
          maxClassId = pur.classID;
        }
        break;
      }
    }
  }
  if (havemul && havepos)
  {
    localAndClientMsg(VLogger::WARN, _callback,
                      "Your runset contains both Positive and Multiclass purposes. "
                      "This is unusual. Positives will be treated as a separate class.\n" );
  }
  localAndClientMsg(VLogger::DEBUG, _callback, "got %d purposed lists\n",
                    purposedLists.size());
  return true;
}
Beispiel #2
0
bool CascadeTrainI::checkPurposedLists(
    const PurposedListSequence& purposedLists,
    TrainerCallbackHandlerPrx& _callback )
{
  if(purposedLists.size() == 0)
  {
    localAndClientMsg(VLogger::WARN, _callback, 
                      "Error: no data (runset) for processing\n");
    return false;
  }

  bool havemul = false;
  bool havepos = false;
  bool haveneg = false;
  bool tooSmall = false;

  for (size_t listidx = 0; listidx < purposedLists.size(); listidx++)
  {
    Purpose &pur = purposedLists[listidx]->pur;
    PurposedLabelableSeq * purSeq = NULL;
    purSeq = static_cast<PurposedLabelableSeq *>(purposedLists[listidx].get());
    LabelableList artifacts = purSeq->labeledArtifacts;
    
    switch(pur.ptype)
    {
      case cvac::POSITIVE:
      {
        havepos = true;
        break;
      }
      case cvac::NEGATIVE:
      {
        haveneg = true;
        break;
      }
      case cvac::MULTICLASS:
      {
        havemul = true;
        break;
      }
      case cvac::UNPURPOSED:
      case cvac::ANY:
      {
        // ignore these samples
        break;
      }
    }
    if ((artifacts.size() < MIN_SAMPLE_SIZE))
    {
        bool hasVideo = false;
        LabelableList::iterator it;
        for (it = artifacts.begin(); it < artifacts.end(); it++)
        {
            LabelablePtr lab = *it;
            if (lab->sub.isVideo)
            {
                hasVideo = true;
                break;
            }
        }
        if (hasVideo == false)
            tooSmall = true;
    }
 
  }
  
  if (havepos == false)
  {
    localAndClientMsg(VLogger::ERROR, _callback, "Your runset does not contain a pos purpose\n");  
    return false;
  }
  if (haveneg == false)
  {
    localAndClientMsg(VLogger::ERROR, _callback, "Your runset does not contain a neg purpose\n");       
    return false;
  }
  if (tooSmall == true)
  {
    localAndClientMsg(VLogger::ERROR, _callback,
                      "Your runset must contain at least %d+%d (pos+neg) samples\n",
                      MIN_SAMPLE_SIZE, MIN_SAMPLE_SIZE);       
    return false;
  }
  return true;
}