function search(data){
    var dataset_search = []; //for dataset visualisation
    var $dataset_search
    $.ajax({
        type: "POST",
        url: "/search",
        contentType: 'application/json',
        data: data,
        // handle success
        success: function (result) {
            //console.log('result.results=',result.results);
            var data = result.results;

            if (0 === data.length) {
                $("#search-error").html("Sorry, no results found. Try with some other words.");
            } else {

                var result_list = result.result_list;
            generate_filter_list(data);
            /**
             * <li class="all active"><a href="#">All (40)</a></li>
             <li class="gun"><a href="#" title="">Guns (21)</a></li>
             <li class="church"><a href="#" title="">Church (19)</a></li>
             */

            console.log("Total images found:", data.length);
            //------ for visualisation ------
            var dataset_label = []; //for dataset visualisation
            //var dataset_search = []; //for dataset visualisation
            var arr_label = []; //container for labels added
            var arr_search = []; //container for labels added
            var imagenet_guns = ["revolver","assault_rifle","rifle","muzzle"];
            //------ end of visualisation ------

            for (i = 0; i < data.length; i++) {
                // console.log('fname=',data[i][0]);
                // console.log('label=',data[i][1]);
                // console.log('prediction=',data[i][2]);

                var file = data[i][0];
                var label = data[i][1];
                var probability = data[i][2];
                var search_label = data[i][3];
                var icon_size = data[i][4];

                var data_id = "id-" + i;
                var caption = "Display Information";//"Label: " + label + "(" + (probability) + ")";

                var filename = file.split('/').pop().split('\\').pop();
                //console.log("file:", file, "filename:", filename, " search_label=",search_label)

                //prediction file to be used later
                var files  = find_info_file(file, result_list)
                var pred_file = files[0];
                var exif_file = files[1];

                var prob = (probability* 100 ).toPrecision(4);
                var item_label = "";//"<p><strong>" + filename + "</strong> " + label + " (" + prob + "%)</p>"
                var item_label_title = "File: "+ filename + " Label: "+label + " (" + prob + "%)";
                //append results
                //console.log(file, filename, file.replace(filename, encodeURI(filename)))
                var encodedFile = file.replace(filename, encodeURI(filename))

                var icons = '<div class="text-left clear-marginbot marginbot10">' +
                    //'<span class="file-info show_info"><a href="#" title="' + caption + '"><i class="icon-file icon-circled icon-bglight icon"></i></a></span> '
                     '<span><a class="download" href="' + encodedFile + '" title="Download '+ filename + '"><i class="icon-cloud-download icon-circled icon-bglight icon"></i></a></span></div>'
                var content = '<li class="item-thumbs span1 design" data-id="' + data_id + '" data-type="'+ search_label +'">'
                            +'<div class="item" id="img-label-' + data_id + '">' + item_label + icons
                            +'<div class="show_info"><img title="'+item_label_title+'" src="' + encodedFile + '" alt="" data-file-pred="' + pred_file
                            +'" data-file-exif="' + exif_file + '" /></div></div></li>';

                $('#thumbs').append(content);

                //------ for visualisation ------
                var idx_search = $.inArray(search_label, arr_search);
                var idx_category = $.inArray(label, imagenet_guns);

                if(idx_search > -1){ //found it, then just add
                    dataset_search[idx_search]["value"] = (dataset_search[idx_search]["value"])  + 1
                } else {
                    arr_search.push(search_label)  //ensures same index
                    var category = "not_gun";
                    if(idx_category >-1){ category = "gun" }
                    dataset_search.push({"label": search_label,"value": 1, "category":category})
                }
                //------ end of visualisation ------
            }
            $dataset_search = dataset_search
            //call the animation function again here
            call_thumbs_animation();
            //visualise only after its done, move to complete function
            //visualize_results(dataset_search);
            scrollToDiv($("#search-results-title"));

            } //else-images-found


        },
        // handle error
        error: function (error) {
            console.log(error);
            // append to dom
            //$("#error").append()
        },
        //oncomplete
        complete: function (){
            $loading.hide();
            visualize_results($dataset_search);
        }
    });

}
/**
 * search the prediction files and return the image list
 * @param data
 */
search the prediction files and return the image list
@param data
search the prediction files and return the image list @param data
function search(data){
    var dataset_search = []; 
    var $dataset_search
    $.ajax({
        type: "POST",
        url: "/search",
        contentType: 'application/json',
        data: data,
        success: function (result) {
            var data = result.results;
            if (0 === data.length) {
                $("#search-error").html("Sorry, no results found. Try with some other words.");
            } else {
                var result_list = result.result_list;
            generate_filter_list(data);
            console.log("Total images found:", data.length);
            var dataset_label = []; 
            //var dataset_search = []; 
            var arr_label = []; 
            var arr_search = []; 
            var imagenet_guns = ["revolver","assault_rifle","rifle","muzzle"];
            for (i = 0; i < data.length; i++) {
                var file = data[i][0];
                var label = data[i][1];
                var probability = data[i][2];
                var search_label = data[i][3];
                var icon_size = data[i][4];
                var data_id = "id-" + i;
                var caption = "Display Information";
                var filename = file.split('/').pop().split('\\').pop();
                var files  = find_info_file(file, result_list)
                var pred_file = files[0];
                var exif_file = files[1];
                var prob = (probability* 100 ).toPrecision(4);
                var item_label = "";
                var item_label_title = "File: "+ filename + " Label: "+label + " (" + prob + "%)";
                var encodedFile = file.replace(filename, encodeURI(filename))
                var icons = '<div class="text-left clear-marginbot marginbot10">' +
                     '<span><a class="download" href="' + encodedFile + '" title="Download '+ filename + '"><i class="icon-cloud-download icon-circled icon-bglight icon"></i></a></span></div>'
                var content = '<li class="item-thumbs span1 design" data-id="' + data_id + '" data-type="'+ search_label +'">'
                            +'<div class="item" id="img-label-' + data_id + '">' + item_label + icons
                            +'<div class="show_info"><img title="'+item_label_title+'" src="' + encodedFile + '" alt="" data-file-pred="' + pred_file
                            +'" data-file-exif="' + exif_file + '" /></div></div></li>';
                $('#thumbs').append(content);
                var idx_search = $.inArray(search_label, arr_search);
                var idx_category = $.inArray(label, imagenet_guns);
                if(idx_search > -1){ 
                    dataset_search[idx_search]["value"] = (dataset_search[idx_search]["value"])  + 1
                } else {
                    arr_search.push(search_label)  
                    var category = "not_gun";
                    if(idx_category >-1){ category = "gun" }
                    dataset_search.push({"label": search_label,"value": 1, "category":category})
                }
            }
            $dataset_search = dataset_search
            call_thumbs_animation();
            scrollToDiv($("#search-results-title"));
            } 
        },
        error: function (error) {
            console.log(error);
        },
        complete: function (){
            $loading.hide();
            visualize_results($dataset_search);
        }
    });
}
function search ( data ) { var dataset_search = [ ] ; var $dataset_search $ . ajax ( { type : "POST" , url : "/search" , contentType : 'application/json' , data : data , success : function ( result ) { var data = result . results ; if ( 0 === data . length ) { $ ( "#search-error" ) . html ( "Sorry, no results found. Try with some other words." ) ; } else { var result_list = result . result_list ; generate_filter_list ( data ) ; console . log ( "Total images found:" , data . length ) ; var dataset_label = [ ] ; var arr_label = [ ] ; var arr_search = [ ] ; var imagenet_guns = [ "revolver" , "assault_rifle" , "rifle" , "muzzle" ] ; for ( i = 0 ; i < data . length ; i ++ ) { var file = data [ i ] [ 0 ] ; var label = data [ i ] [ 1 ] ; var probability = data [ i ] [ 2 ] ; var search_label = data [ i ] [ 3 ] ; var icon_size = data [ i ] [ 4 ] ; var data_id = "id-" + i ; var caption = "Display Information" ; var filename = file . split ( '/' ) . pop ( ) . split ( '\\' ) . pop ( ) ; var files = find_info_file ( file , result_list ) var pred_file = files [ 0 ] ; var exif_file = files [ 1 ] ; var prob = ( probability * 100 ) . toPrecision ( 4 ) ; var item_label = "" ; var item_label_title = "File: " + filename + " Label: " + label + " (" + prob + "%)" ; var encodedFile = file . replace ( filename , encodeURI ( filename ) ) var icons = '<div class="text-left clear-marginbot marginbot10">' + '<span><a class="download" href="' + encodedFile + '" title="Download ' + filename + '"><i class="icon-cloud-download icon-circled icon-bglight icon"></i></a></span></div>' var content = '<li class="item-thumbs span1 design" data-id="' + data_id + '" data-type="' + search_label + '">' + '<div class="item" id="img-label-' + data_id + '">' + item_label + icons + '<div class="show_info"><img title="' + item_label_title + '" src="' + encodedFile + '" alt="" data-file-pred="' + pred_file + '" data-file-exif="' + exif_file + '" /></div></div></li>' ; $ ( '#thumbs' ) . append ( content ) ; var idx_search = $ . inArray ( search_label , arr_search ) ; var idx_category = $ . inArray ( label , imagenet_guns ) ; if ( idx_search > - 1 ) { dataset_search [ idx_search ] [ "value" ] = ( dataset_search [ idx_search ] [ "value" ] ) + 1 } else { arr_search . push ( search_label ) var category = "not_gun" ; if ( idx_category > - 1 ) { category = "gun" } dataset_search . push ( { "label" : search_label , "value" : 1 , "category" : category } ) } } $dataset_search = dataset_search call_thumbs_animation ( ) ; scrollToDiv ( $ ( "#search-results-title" ) ) ; } } , error : function ( error ) { console . log ( error ) ; } , complete : function ( ) { $loading . hide ( ) ; visualize_results ( $dataset_search ) ; } } ) ; }
search the prediction files and return the image list
 @param data
search the prediction files and return the image list @param data
//for dataset visualisation // handle success //console.log('result.results=',result.results); /**
             * <li class="all active"><a href="#">All (40)</a></li>
             <li class="gun"><a href="#" title="">Guns (21)</a></li>
             <li class="church"><a href="#" title="">Church (19)</a></li>
             */ //------ for visualisation ------ //for dataset visualisation //var dataset_search = []; //for dataset visualisation //container for labels added //container for labels added //------ end of visualisation ------ // console.log('fname=',data[i][0]); // console.log('label=',data[i][1]); // console.log('prediction=',data[i][2]); //"Label: " + label + "(" + (probability) + ")"; //console.log("file:", file, "filename:", filename, " search_label=",search_label) //prediction file to be used later //"<p><strong>" + filename + "</strong> " + label + " (" + prob + "%)</p>" //append results //console.log(file, filename, file.replace(filename, encodeURI(filename))) //'<span class="file-info show_info"><a href="#" title="' + caption + '"><i class="icon-file icon-circled icon-bglight icon"></i></a></span> ' //------ for visualisation ------ //found it, then just add //ensures same index //------ end of visualisation ------ //call the animation function again here //visualise only after its done, move to complete function //visualize_results(dataset_search); //else-images-found // handle error // append to dom //$("#error").append() //oncomplete