2017-10-09 3 views
0

私はこのコードをpython3で私のjupyterのtensorflowチュートリアルから実行します。コンボリューションが画像に適用されました - TypeError: '変数'オブジェクトが呼び出し可能ではありません

#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: '変数' オブジェクトの呼び出し可能

ではない私は、この例外TypeErrorを検索しようとしたが、何も '変数' オブジェクトとして正確に指定されていません。すべてのあなたの助けを感謝します。

+0

このエラーは、すでに「入力」という変数があることを示しています。あなたはiPythonや他のIDEでこれを実行していますか? 'input'という変数がありますか?スクリプトを細かい部分に分解して、どのような改行と何が効いているのかを確認してください。 – charlesreid1

+0

私はこのコードをjupyterノートブックで実行します。最初にraw_input()が使用されましたが、未定義の名前のエラーがありました。それから、python3で提案されているようにinput()に変更しました。 – Nat

答えて

-1

私はちょうど@tacaswell

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

することにより、この修正プログラムは、単純にこの行を追加しました。

from six.moves import input 
+0

これは、Python 3で 'input()'関数を呼び出すときに問題が起きた場合、6からの 'input()'をインポートしても何も実質的に変更されないという、元のポストで説明したように問題を解決する方法ははっきりしません。投稿したコードとエラーの原因となったコードに矛盾がありますか? – charlesreid1

+0

私のコードで変更したのは、未定義の名前のエラーがある "raw_input()"から上記のエラーが発生した "input()"です。 – Nat

関連する問題