2017-10-09 1 views
0

Ich führe diesen Code von Tensorflow-Tutorials auf meinem Jupyter mit Python3 und ich bekam den folgenden Fehler;Faltung auf Bilder angewendet - TypeError: 'Variable' Objekt ist nicht aufrufbar

#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' Objekt ist nicht aufrufbar

ich für diese Typeerror zu suchen versucht, aber nichts angegeben genau wie 'Variable' Objekt. Schätze all deine Hilfe.

+0

Der Fehler zeigt an, dass Sie bereits eine Variable mit dem Namen 'input' haben. Laufen Sie das in iPython oder einer anderen IDE, wo es eine Variable namens 'input' gibt? Versuchen Sie, Ihr Skript in kleinere Teile zu zerlegen, um zu sehen, was bricht und was funktioniert. – charlesreid1

+0

Ich führe diesen Code mit Jupyter Notebook. Die raw_input() wurde zuerst verwendet, aber es gab einen Fehler mit undefiniertem Namen. Dann änderte ich es in input() wie für python3 vorgeschlagen. – Nat

Antwort

-1

Ich habe gerade dieses Update von @tacaswell

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

einfach diese Zeile hinzufügen;

from six.moves import input 
+0

Es ist nicht klar, wie dies das Problem löst, wie im ursprünglichen Post beschrieben - wenn das Problem in Python 3 beim Aufruf der 'input()' Funktion passiert, würde das Importieren von 'input()' aus sechs nichts wesentlich ändern. Gibt es eine Inkonsistenz zwischen dem Code, den Sie gepostet haben, und dem Code, der den Fehler verursacht hat? – charlesreid1

+0

die einzige Sache, die ich in meinem Code ändere, ist von "rohe_input()", die ich einen Fehler von undefiniertem Namen erhielt, zu "input()" mit einem Fehler, der oben angegeben wird. – Nat

Verwandte Themen