Comments (5)
I also looked around and could not find support for groups in general. @alexandre01 Do we have to turn groups into simple paths for using the network?
from deepsvg.
As a workaround, you could create a script to automate Inkscape and apply it to your SVG input folder as a preprocessing step.
https://github.com/Klowner/inkscape-applytransforms
Have not tried it myself though.
from deepsvg.
Thanks @pwichmann . I will try that out.
For now, I figured out that the problem is NOT groups. I loaded an svg with groups and the current code base did load the svg correctly, except that I had to add "fill = "none" to each path in the group, otherwise when it draws its all black.
I am now trying to see if in that case the conversion to tensor is right. Is there a way of converting an tensor back to svg to make sure its working correctly?
from deepsvg.
Hello @tsaxena,
I recently added a Dataloader which can directly handle SVG icons as input. You can first pre-process the entire dataset using the https://github.com/alexandre01/deepsvg/blob/master/dataset/preprocess.py script or load https://github.com/alexandre01/deepsvg/blob/master/deepsvg/svg_dataset.py with already_preprocessed=False to perform preprocessing on the fly.
The preprocessing does the following:
svg.fill_(False)
svg.normalize().zoom(0.9)
svg.canonicalize()
svg = svg.simplify_heuristic()
Indeed, if you want to train a model for strokes only (without taking filling into account), you can set fill to False.
from deepsvg.
Let me just give some clarification regarding filling. Let's take the example of a filled "donut" shape: a filled circle with a "hole" inside. This is done in SVG by drawing in the same < path > a circular shape followed by another smaller circle drawn in the opposite direction (counter-clockwise). This is the even-odd rule.
DeepSVG however draws every path separately, and would generate in this case two paths. But how to apply the correct filling? The approach we propose is to predict a fill parameter which can take one of three values: Filling.OUTLINE (for stroke only), Filling.FILL (to fill the path) and Filling.ERASE (to "unfill" that area).
During preprocessing, paths are separated but the correct "fill" parameter is memorized. However, when visualising it, all filled shapes appear black.
The SVG.group_overlapping_paths
method tackles this issue and re-maps the generated outputs to a valid SVG with even-odd fill rule. It does so by analysing overlaps between shapes and their fill parameters to group them together in a common path. This is a hack though, as this approach won't work for more complex cases.
It's therefore better to stick with strokes for the moment. Hope this helped.
from deepsvg.
Related Issues (20)
- Tensor sizes do not match HOT 1
- Misleading Markdown HOT 1
- SVG.from_tensor() HOT 1
- TypeError: must be real number, not NoneType HOT 1
- ALSA lib errors when importing SVG
- Errors while preprocessing svg files HOT 1
- Metrics for RE and IS HOT 1
- Requirments setup error
- Update requirements.txt to 1.12.1 from 1.4.0 as 1.4.0 does not exist anymore. HOT 2
- Could you post a simple example of how to view the icon .pkl files? HOT 2
- DeepSVG for text-conditioned vector generation. HOT 1
- AttributeError: 'SVGRectangle' object has no attribute 'translate' ---Bug while using own svg file HOT 1
- About own datasets HOT 1
- Loading SVGs does not carry over their stroke attributes HOT 1
- ERROR: Could not find a version that satisfies the requirement torch==1.4.0 (from versions: 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0, 2.0.1, 2.1.0) ERROR: No matching distribution found for torch==1.4.0
- RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead.
- Hello, I probably find I bug in 'deepsvg/svglib /svg.py' (merge_group)
- SVGCommandArc is not implemented yet
- RuntimeError: The size of tensor a (45) must match the size of tensor b (8) at non-singleton dimension 0 HOT 2
- How to adjust max_num_groups and max_total_len
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepsvg.