zzilch / RPLAN-Toolbox

A python based toolbox for RPLAN dataset

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fail to allocate bitmap - Batch processing

rickkk856 opened this issue · comments

I'm running a modified version of test.py to convert the dataset into the vector floorplan with doors and windows, I just made a loop to go throught every filename instead of using a custom from the test.py file

But it only runs 390 files and gives me a Fail to allocate bitmap error

import matplotlib.pyplot as plt
from rplan.floorplan import Floorplan
from rplan.align import align_fp_gt
from rplan.decorate import get_dw
from rplan.measure import compute_tf
from rplan.plot import get_figure,get_axes,plot_category,plot_boundary,plot_graph,plot_fp,plot_tf

from os import walk
mypath = ./data/
f = []
for (dirpath, dirnames, filenames) in walk(mypath):
    f.extend(filenames)
    break
print("FILES LOADED ............",f)

lenght = len(f)

print("There will be loaded ",lenght," Images")

for f in f:
    file_path = ('./data/'+f)
    print("Loading Image From............",file_path)

    fp = Floorplan(file_path)
    img = fp.image    
    
    fp.boundary
    fp.category
    fp.instance
    fp.inside

    data = fp.to_dict()


    boxes_aligned, order, room_boundaries = align_fp_gt(data['boundary'],data['boxes'],data['types'],data['edges'])
    data['boxes_aligned'] = boxes_aligned
    data['order'] = order
    data['room_boundaries'] = room_boundaries

    doors,windows = get_dw(data)
    data['doors'] = doors
    data['windows'] = windows

    ## Activate the line of code of what type of image you want
    ## Images will be saved in "./output" folder with same filenames

    #plot_category(fp.category) # raw image
    #plot_boundary(data['boundary']) # vector boundary
    #plot_graph(data['boundary'],data['boxes'],data['types'],data['edges']) # node graph
    #plot_fp(data['boundary'], data['boxes_aligned'][order], data['types'][order]) # vector floorplan
    plot_fp(data['boundary'], data['boxes_aligned'][order], data['types'][order],data['doors'],data['windows']) # vector floorplan with doors and windows
    plt.axis('off')
    plt.savefig('./output/'+f, bbox_inches='tight')

I need to transform A --> B

A
image

B
image

Is there another way to do this process?

it seems that the code I edited was making my computer run out of memory, so it failed to allocate bitmap

a simple plt.close() at the end of the code solved the issue