0

I run this code from tensorflow tutorials on my jupyter with python3 and I got the following error;

#Importing
import numpy as np
from scipy import signal
from scipy import misc   
import matplotlib.pyplot as plt
from PIL import Image    

### Load image of your choice on the notebook
print("Please type the name of your test image after uploading to \
your notebook (just drag and grop for upload. Please remember to \
type the extension of the file. Default: bird.jpg")

raw = input()   
im = Image.open(raw)  # type here your image's name

# uses the ITU-R 601-2 Luma transform (there are several ways to convert an 
# image to grey scale)

image_gr = im.convert("L")    
print("\n Original type: %r \n\n" % image_gr)

# convert image to a matrix with values from 0 to 255 (uint8) 
arr = np.asarray(image_gr) 
print("After conversion to numerical representation: \n\n %r" % arr) 
### Activating matplotlib for Ipython
%matplotlib inline

### Plot image
imgplot = plt.imshow(arr)
imgplot.set_cmap('gray')  
print("\n Input image converted to gray scale: \n")
plt.show(imgplot)


Please type the name of your test image after uploading to your notebook 
(just drag and grop for upload. Please remember to type the extension of the file. Default: bird.jpg 

TypeError                                 Traceback (most recent call last)
<ipython-input-26-061778a3dd36> in <module>()
     14 print("Please type the name of your test image after uploading to 
your notebook (just drag and grop for upload. Please remember to type the 
extension of the file. Default: bird.jpg")
     15 
---> 16 raw = input()   
     17 
     18 

TypeError: 'Variable' object is not callable

I tried to search for this typeError, but nothing specified exactly as 'Variable' object. Appreciate all your help.

Nat
  • 301
  • 2
  • 6
  • The error indicates that you already have a variable called `input`. Are you running this in iPython or some other IDE, where there is a variable called `input`? Try paring down your script to smaller parts to see what breaks and what works. – charlesreid1 Oct 09 '17 at 07:41
  • I run this code with jupyter notebook. The raw_input() was used at first, but there was an error of undefined name. Then I changed it to input() as suggested for python3. – Nat Oct 09 '17 at 09:50

1 Answers1

-1

I just found this fix by @tacaswell

https://stackoverflow.com/a/31687067/7468989

simply add this line;

from six.moves import input
Nat
  • 301
  • 2
  • 6
  • It isn't clear how this solves the problem as described in the original post - if the problem was happening in Python 3 when calling the `input()` function, importing `input()` from six would not materially change anything. Is there any inconsistency between the code you posted and the code that caused the error? – charlesreid1 Oct 10 '17 at 02:10
  • the only thing that I change in my code is from "raw_input()", which I got an error of undefined name, to "input()" with an error specified above. – Nat Oct 11 '17 at 05:18