Maelic / SGG-Benchmark

A New Benchmark for Scene Graph Generation, targeting real-world applications
MIT License
16 stars 3 forks source link

Change the fontpath from draw_single_label to be relative or to check if the .ttf exists in the system #9

Closed NilBiescas closed 3 weeks ago

NilBiescas commented 3 weeks ago

def draw_single_label(pic, box, label, color=(255,0,255,128)): draw = ImageDraw.Draw(pic) font_size = 30 font = ImageFont.truetype("/home/maelic/Documents/PhD/MyModel/PhD_Commonsense_Enrichment/analysis_diagrams/gidole/GidoleFont/Gidole-Regular.ttf", size=font_size) x1,y1,x2,y2 = int(box[0]), int(box[1]), int(box[2]), int(box[3]) p1 = (x1, y1) p2 = (x2, y2) bb_center = (int(p1[0] + p2[0])/2, int(p1[1] + p2[1])/2)

bbox = draw.textbbox(bb_center, label, font=font)
draw.rectangle(bbox, fill=color)
draw.text(bb_center, label, fill="black", font=font)
return bb_center