from set_up_caffe_net import Get_Model_File

m.main()
acts = m.acts
class_labels = m.class_labels

class_dict = h.make_class_to_line_number_look_up_table(
    class_labels=class_labels, verbose=False)
# this builds the look-up table between points and the class they are in

## This bit is slow, it loads the label data for all acts
label_dict, found_labels, no_files_in_label = h.build_label_dict(acts)
model_file = Get_Model_File('no_reg_AlexNet')
if usingDocker:
    # new set-up with safer deployment for use on all machines
    caffe_root, image_directory, labels_file, model_def, model_weights, dir_list, labels = s.set_up_caffe(
    )
    net, transformer = s.Caffe_NN_setup(
        imangenet_mean_image='python/caffe/imagenet/ilsvrc_2012_mean.npy',
        batch_size=50,
        model_def=model_def,
        model_weights=model_weights,
        verbose=True,
        root_dir=caffe_root)
else:
    # old set-up with hardcoded links and old-style unsafe deployment
    caffe_root, image_directory, labels_file, model_def, model_weights, dir_list, labels = \
        s.set_up_caffe(image_directory='/storage/data/imagenet_2012',
                       model_file=model_file,
                       label_file_address='data/ilsvrc12/synset_words.txt',
                       dir_file='/storage/data/imagenet_2012_class_list.txt',
                       root_dir='/home/eg16993/src/caffe', verbose=True)
Beispiel #2
0
                      out_file_name="synset_texture224.txt")




## Get a list of images which have associated objects and we'll take those as classes




# here we set up where things should be found by caffe
r.caffe_root, r.image_directory, r.labels_file, r.model_def, r.model_weights, r.dir_list, r.labels = \
            set_up_caffe(image_directory=r.image_directory,
                         model_file=r.model_file,
                         #label_file_address='/storage/data/fooling_images_2015/synset_words.txt',
                         label_file_address=r.labels_file,
                         dir_file=r.dir_list,
                         root_dir=os.environ['CAFFE_ROOT'], verbose=True,
                         deploy_file=r.deploy_file)



#here we build our neural net
# NTS i am not entrely sure that the mean image is correct, I may have to make a new one
r.net, r.transformer = Caffe_NN_setup(
    imangenet_mean_image=os.path.join(os.environ['PYCAFFE_ROOT'], 'caffe/imagenet/ilsvrc_2012_mean.npy'),
    batch_size=50, model_def=r.model_def, model_weights=r.model_weights,
    verbose=True, root_dir=r.caffe_root, img_size=r.img_size)


    # this sets up the material
    image_list_textures, labels_list_textures = make_synset_files(
        index_into_index_file=11,
        index_file=
        '/home/eg16993/neuralNetworks/experiments/NetDissect/NetDissect-release1/dataset/broden1_227/index.csv',
        category_file=
        '/home/eg16993/neuralNetworks/experiments/NetDissect/NetDissect-release1/dataset/broden1_227/c_texture.csv',
        out_file_name="synset_texture227.txt")

## Get a list of images which have associated objects and we'll take those as classes

# here we set up where things should be found by caffe
r.caffe_root, r.image_directory, r.labels_file, r.model_def, r.model_weights, r.dir_list, r.labels = \
            set_up_caffe(image_directory=r.image_directory,
                         model_file=r.model_file,
                         #label_file_address='/storage/data/fooling_images_2015/synset_words.txt',
                         label_file_address=r.labels_file,
                         dir_file=r.dir_list,
                         root_dir='/home/eg16993/src/caffe', verbose=True)

#here we build our neural net
# NTS i am not entrely sure that the mean image is correct, I may have to make a new one
r.net, r.transformer = Caffe_NN_setup(
    imangenet_mean_image=
    '/home/eg16993/src/caffe/python/caffe/imagenet/ilsvrc_2012_mean.npy',
    batch_size=50,
    model_def=r.model_def,
    model_weights=r.model_weights,
    verbose=True,
    root_dir=r.caffe_root)

r.short_labels = [label.split(' ')[0] for label in r.labels]