Skip to content

Deprecation and many Issues #12

@DhruvAthaide

Description

@DhruvAthaide

First Issue: The scipy.misc module has been deprecated since Scipy version 1.0.0 and the 'imread' and 'imresize' functions are no longer available in the scipy.misc module.
Fix: In the prepare_imagenet_data.py replace the 'from scipy.misc import imread, imresize' with 'import imageio' and replace the following line 'img = imread(im_path, mode='RGB')' with 'img = imageio.imread(im_path, mode='RGB')'

Second issue: The imresize function is not available in scipy module and imageio module.
Fix: In the prepare_imagenet_data.py insert 'from skimage.transform import resize' at the start of the file along with the other packages aliases, then replace the line 'img = imresize(img, img_size)' with 'img = resize(img, img_size)'

Third Issue: In TensorFlow 2.x, the Session class has been removed, and the execution model has changed to using eager execution by default.
Fix: I have fixed this issue by updating the code of TensorFlow to 2.0 in demo_inception.py and replace the line 'persisted_sess = tf.Session()' with 'persisted_sess = tf.compat.v1.Session()' and replace 'tf.import_graph_def(graph_def, name='')' with 'tf.compat.v1.import_graph_def(graph_def, name='')'

Fourth Issue: The 'tf.GraphDef()' method is not available in TensorFlow 2.0 and make the changes in demo_inception.py and replace the line 'graph_def = tf.GraphDef()' with 'graph_def = tf.compat.v1.GraphDef()'

Fifth Issue: deprecation warning about FastGFile
Fix: In demo_inception.py replace the line 'with gfile.FastGFile(model, 'rb') as f:' with 'with tf.compat.v1.gfile.GFile(model, 'rb') as f:'

Sixth Issue: As of NumPy version 1.20.0, 'np.int' is no longer available as an alias for the built-in 'int'
Fix: In demo_inception.py replace the line 'str_label_original = labels[np.int(label_original)-1].split(',')[0]' with 'str_label_original = labels[int(label_original)-1].split(',')[0]' and replace 'str_label_perturbed = labels[np.int(label_perturbed)-1].split(',')[0]' with 'str_label_perturbed = labels[int(label_perturbed)-1].split(',')[0]'

The code should run with these changes but the issue I'm getting with running the 'python demo_inception.py -i data/test_img.png' command you get is a blank image instead of a plant pot. Please correct me if I'm wrong.

@husseinfawzi could you help me run the Universal adversarial perturbations code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions