Menu

SVM and GIST example please?

Anonymous
2015-09-07
2015-09-08
  • Dave Mobley

    Dave Mobley - 2015-09-07

    Last post was actually by me (but forgot to log in-not sure iof I can fix it after the fact)

    Hi All,

    I have a data set (some thousands of images). I want to run the GIST global descriptor on then and then apply SVM to it.

    My basic procedure is:
    1) Load dataset (Images are on filesystem in 12 distinct folders)
    2) Run SVM (and feature extractor is a GIST extractor I made)

    Does this sound like a correct approach? And if so, here is my code so far - any recommendations?

    public class GistExtractor implements FeatureExtractor<floatfv, fimage="">
    {
    private Gist<fimage> gist = null;</fimage></floatfv,>

    public GistExtractor(Gist<FImage> gist)
    {
        this.gist = gist;
    }
    
    @Override
    public FloatFV extractFeature(FImage object)
    {
        gist.analyseImage(object);
        FloatFV fv = gist.getResponse();
        return fv;
    }
    

    }

    public class GistCalculator
    {
    public static Gist<fimage> fsg = new Gist<fimage>(256, 256);
    public static FeatureExtractor<floatfv, fimage=""> gex = new GistExtractor(fsg);
    public static SVMAnnotator svm = new SVMAnnotator(gex);</floatfv,></fimage></fimage>

    public static void main(String[] args) throws IOException
    {       
        // load Dataset //
        GroupedDataset<String, VFSListDataset<Record<FImage>>, Record<FImage>> allData = 
                ScenicOrNot.getData(ImageUtilities.FIMAGE_READER);
    
        // group dataset //
        GroupedRandomSplitter<String, Record<FImage>> splits = new GroupedRandomSplitter<String, Record<FImage>>(allData, 10, 0, 2);
    
        // run svm //
        svm.train(splits.getTrainingDataset());
    }
    

    }

    I get an error "Data did not contain exactly 2 classes. It had 12."

    Does anyone have any samples that might use GIST + SVM? Currently my 12 folders are just that, folders. The names hold no relevance to what is inside (I actually use a RecordReader and extract a float score from a csv file for each image).

    Thanks
    -scprotz

     

    Last edit: Dave Mobley 2015-09-07
  • Jonathon Hare

    Jonathon Hare - 2015-09-08

    Your overall approach looks fine - I think the problem lies with your ScenicOrNot class, which I would guess is building a dataset with too many classes (for a binary problem the GroupedDataset should have two just groups).

     

Anonymous
Anonymous

Add attachments
Cancel