I ran my script for annotating images before 3 days and when it was finish yesterday, this message shows up "Killed". Why is that?
And when I run dmesg, the output is: [269538.495694] Out of memory: Killed process 10231 (python3) total-vm:5864124kB, anon-rss:4250068kB, file-rss:4kB, shmem-rss:0kB, UID:1000 pgtables:8880kB oom_score_adj:0
I'm using ubuntu 22.04.
The script opens json file on the beggining and inside some function for annotating text on images, the write_json() is called. And the data (images with text) was read from .h5 file
def write_json(data, filename='da.json'):
with open(filename,'w') as file:
ujson.dump(data,file,indent=4)
with open("da.json") as json_file:
data=ujson.load(json_file)
temp=data["annotations"]
def viz_textbb(text_im, imageName, charBB_list, wordBB, textToList, alpha=1.0):
start = 0
coordinate = []
name = []
upperList = []
downList = []
FinalFinal = []
imageData = { }
dictList = []
for eachWord in textToList:
length = len(eachWord)
for i in range(0,4):
for j in range(start,length+start):
coordinate.append([charBB_list[0][0][i][j], charBB_list[0][1][i][j]])
name.append(coordinate)
coordinate = []
for j in range(0, length):
for i in range(len(name)) :
if(i == 0 or i == 1):
upperList.append(name[i][j])
if(i == 2):
downList.append(name[i+1][j])
if(i == 3):
downList.append(name[i-1][j])
down = reversed(downList)
joinList = [*upperList,*down,upperList[0]]
FinalFinal.append(joinList)
imageData['transcription']=eachWord
imageData['language']="Latin"
imageData['illegibility']=False
imageData['points']=joinList
dictionary_copy = imageData.copy()
dictList.append(dictionary_copy)
del(dictionary_copy)
name=[]
upperList = []
downList = []
start = len(eachWord) + start
finalDict = {f'gt_{imageName}':dictList}
temp.update(finalDict)
write_json(data)
def main(db_fname):
db = h5py.File(db_fname, 'r')
dsets = sorted(db['data'].keys())
#print ("total number of images : ", colorize(Color.RED, len(dsets), highlight=True))
for k in dsets:
rgb = db['data'][k][...]
charBB = db['data'][k].attrs['charBB']
wordBB = db['data'][k].attrs['wordBB']
txt = db['data'][k].attrs['txt']
textToList = (db['data'][k].attrs['txt']).tolist()
viz_textbb(rgb, k,[charBB], wordBB, textToList)
print ("image name : ", colorize(Color.RED, k, bold=True))
# print (" ** no. of chars : ", colorize(Color.YELLOW, charBB.shape[-1]))
# print (" ** no. of words : ", colorize(Color.YELLOW, wordBB.shape[-1]))
print (" ** text : ", colorize(Color.GREEN, txt))
db.close()
json.close()
if __name__=='__main__':
main('results/SynthText.h5')