From d59a682c047a0db0f8c39aee491abf142579a9a2 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Mon, 23 Nov 2020 15:22:58 +0100 Subject: [PATCH] publication changes --- requirements.txt | 1 + tools.py | 46 ++++++++++++++++++++++++++++++++-------------- www/index.html | 5 +++-- www/saved.html | 4 ++-- 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/requirements.txt b/requirements.txt index a41560c..f5184af 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ coloredlogs pycocotools numpy mahotas +svgwrite \ No newline at end of file diff --git a/tools.py b/tools.py index 9e37f6a..df6dd00 100644 --- a/tools.py +++ b/tools.py @@ -57,6 +57,16 @@ argParser.add_argument( metavar="SVG_FILENAME", help=""" Create an SVG with sticker pages (afterwards convert to EPS: \"for f in *; do echo $f; inkscape -f $f --export-eps $f.eps; done\") + To PDF: + for f in stickers-v1/*.svg; do echo $f; inkscape $f -o pdf/$f.pdf; done + pdfunite stickers-v1/*.pdf stickers-v1.pdf + """ + ) +argParser.add_argument( + '--no-texture', + action='store_true', + help=""" + Don't fill with texture, but only print cut lines """ ) args = argParser.parse_args() @@ -200,7 +210,8 @@ if args.stickers: size = (105, 148) # in mm sizeFactor = 5 # influences the size of the patterns viewBoxSize = (size[0] * sizeFactor, size[1] * sizeFactor) - margin = 5 + margin = 10 + textMargin = 5 gridSize = ( int((viewBoxSize[0]-((grid[0]+1)*margin))/grid[0]), int((viewBoxSize[1]-((grid[1]+1)*margin))/grid[1]) @@ -211,6 +222,7 @@ if args.stickers: nr = 0 total_nr = len(coco.cats) + max_cat_id = max([cid for cid, _ in coco.cats.items()]) for category_id, cat in coco.cats.items(): nr+=1 filename = os.path.join( @@ -228,6 +240,7 @@ if args.stickers: ) inkscape = Inkscape(dwg) + # Layers/groups to cut stickers at 123stickers.nl contourG = inkscape.layer(label='Snijlijnen') drawingG = inkscape.layer(label='Shapes') @@ -237,27 +250,29 @@ if args.stickers: font_size = 10 + # COCO cat id's go until 90, whereas there's only 80 categories. + # for consistency, we stick with id instead of the nr. text = dwg.text( - f"{nr:02d}/{total_nr}", - insert=(margin, margin+font_size), font_size=font_size, fill='black' + f"{category_id:02d}/{max_cat_id}", + insert=(textMargin, textMargin+font_size), font_size=font_size, fill='black', font_family='Arial', ) drawingG.add(text) text = dwg.text( - f"{category_id}. {cat['supercategory']} - {cat['name']}", - insert=(viewBoxSize[0]-margin, margin+font_size), font_size=font_size, fill='black', + f"{cat['supercategory']} - {cat['name']}", + insert=(viewBoxSize[0]-textMargin, textMargin+font_size), font_size=font_size, fill='black', font_family='Arial', style='text-anchor:end;') drawingG.add(text) text = dwg.text( f"Common Objects In Context", - insert=(margin, viewBoxSize[1]-margin), font_size=font_size, fill='black', + insert=(textMargin, viewBoxSize[1]-textMargin), font_size=font_size, fill='black', font_family='Arial', ) drawingG.add(text) text = dwg.text( - f"Plotting Data", - insert=(viewBoxSize[0]-margin, viewBoxSize[1]-margin), font_size=font_size, fill='black', + f"http://plottingd.at/a", + insert=(viewBoxSize[0]-textMargin, viewBoxSize[1]-textMargin), font_size=font_size, fill='black', font_family='Arial', style='text-anchor:end;') drawingG.add(text) @@ -283,14 +298,17 @@ if args.stickers: drawingG.add(position2G) - xml = dwg.get_xml() - with open('textures.xml', 'r') as fp: - textureTree = ElementTree.fromstring(fp.read()) - defsTree = xml.find('defs') - for pattern in textureTree: - defsTree.append(pattern) + + if not args.no_texture: + with open('textures.xml', 'r') as fp: + textureTree = ElementTree.fromstring(fp.read()) + defsTree = xml.find('defs') + for pattern in textureTree: + defsTree.append(pattern) + xmlString = ElementTree.tostring(xml) + with open(filename, 'wb') as fp: # print(xmlString) fp.write(xmlString) diff --git a/www/index.html b/www/index.html index 8428ffd..80e671c 100644 --- a/www/index.html +++ b/www/index.html @@ -1,5 +1,6 @@ + The COCO dataset : Plotting Data @@ -8,7 +9,7 @@ -