実現したいこと
The Quick, Draw! Datasetのndjsonをpngにしたいと思いこのサイトを参考に、The Quick, Draw! Datasetのndjsonをjsonファイルにするところまではできました。
エラー内容
次に、同じサイトに載っている、pythonを用いたjsonからのpngへの変換で0~53まではpng画像が出力されるのですが、途中で、以下のようなエラーが出て止まってしまいます。
error
1ValueError Traceback (most recent call last) 2<ipython-input-18-eb4bda208900> in <module> 3 8 x = setting[j]['drawing'][i][0] 4 9 y = setting[j]['drawing'][i][1] 5---> 10 f=interpolate.interp1d(x,y,kind="slinear") 6 11 pl.plot(x,y,'k') 7 12 ax = pl.gca() 8 9D:\Users\imcla\Anaconda3\envs\tensorflow chainer\lib\site-packages\scipy\interpolate\interpolate.py in __init__(***failed resolving arguments***) 10 541 if len(self.x) < minval: 11 542 raise ValueError("x and y arrays must have at " 12--> 543 "least %d entries" % minval) 13 544 14 545 @property 15 16ValueError: x and y arrays must have at least 2 entries
実際のソースコードは以下の通りです。
python
1import json 2from scipy import interpolate 3import pylab as pl 4f = open("rawjson/full_raw_ant.json") 5setting = json.load(f) 6for j in range(0,100): 7 for i in range(0,len(setting[j]['drawing'])): 8 x = setting[j]['drawing'][i][0] 9 y = setting[j]['drawing'][i][1] 10 f=interpolate.interp1d(x,y,kind="slinear") 11 pl.plot(x,y,'k') 12 ax = pl.gca() 13 ax.xaxis.set_ticks_position('top') 14 ax.invert_yaxis() 15 pl.axis('off') 16 pl.savefig("train/ant/%d.png"%j) 17 pl.close()
実行環境
使用している環境は
winsows10 Home 1903
Anaconda Navvigator1.9.7
どうすればこのエラーをなくすことができるでしょうか。すみませんがよろしくお願いします。
あなたの回答
tips
プレビュー