All Projects → yogeshhk → MidcurveNN

yogeshhk / MidcurveNN

Licence: MIT license
Computation of Midcurve of Thin Polygons using Neural Networks

Programming Languages

Jupyter Notebook
11667 projects
TeX
3793 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to MidcurveNN

Nurbs Python
Object-oriented pure Python B-Spline and NURBS library
Stars: ✭ 295 (+1452.63%)
Mutual labels:  geometry, cad, computational-geometry
Cavaliercontours
2D polyline library for offsetting, combining, etc.
Stars: ✭ 135 (+610.53%)
Mutual labels:  geometry, cad, computational-geometry
Lazysets.jl
A Julia package for calculus with convex sets
Stars: ✭ 107 (+463.16%)
Mutual labels:  geometry, computational-geometry
Wagyu
A general library for geometry operations of union, intersections, difference, and xor
Stars: ✭ 116 (+510.53%)
Mutual labels:  geometry, computational-geometry
Elm Geometry
2D/3D geometry package for Elm
Stars: ✭ 162 (+752.63%)
Mutual labels:  geometry, cad
Phidl
Python GDS layout and CAD geometry creation
Stars: ✭ 56 (+194.74%)
Mutual labels:  geometry, cad
Maker.js
📐⚙ 2D vector line drawing and shape modeling for CNC and laser cutters.
Stars: ✭ 1,185 (+6136.84%)
Mutual labels:  geometry, cad
Gismo
G+Smo (pronounced gismo or gizmo) is a C++ library for isogeometric analysis (IGA). Geometry plus simulation modules aims at the seamless integration of Computer-aided Design (CAD) and Finite Element Analysis (FEA).
Stars: ✭ 152 (+700%)
Mutual labels:  geometry, cad
paramak
Create parametric 3D fusion reactor CAD models
Stars: ✭ 36 (+89.47%)
Mutual labels:  geometry, cad
SplashGeom
Open-source C++ library for geometry and linear algebra
Stars: ✭ 22 (+15.79%)
Mutual labels:  geometry, computational-geometry
paramak
Create parametric 3D fusion reactor CAD and neutronics models
Stars: ✭ 40 (+110.53%)
Mutual labels:  geometry, cad
Euclid
Exact Computation Geometry Framework Based on 'CGAL'
Stars: ✭ 52 (+173.68%)
Mutual labels:  geometry, computational-geometry
Aabb Tree
A d-dimensional aabb-tree implementation for MATLAB.
Stars: ✭ 5 (-73.68%)
Mutual labels:  geometry, computational-geometry
Hgeometry
HGeometry
Stars: ✭ 98 (+415.79%)
Mutual labels:  geometry, computational-geometry
Dotscad
Reduce the burden of mathematics when playing OpenSCAD
Stars: ✭ 344 (+1710.53%)
Mutual labels:  geometry, cad
polliwog
2D and 3D computational geometry library
Stars: ✭ 22 (+15.79%)
Mutual labels:  geometry, computational-geometry
pymadcad
Simple yet powerful CAD (Computer Aided Design) library, written with Python.
Stars: ✭ 63 (+231.58%)
Mutual labels:  geometry, cad
Geometry
Boost.Geometry - Generic Geometry Library | Requires C++14 since Boost 1.75
Stars: ✭ 282 (+1384.21%)
Mutual labels:  geometry, computational-geometry
Cgal
The public CGAL repository, see the README below
Stars: ✭ 2,825 (+14768.42%)
Mutual labels:  geometry, computational-geometry
topo
A Geometry library for Elixir that calculates spatial relationships between two geometries
Stars: ✭ 125 (+557.89%)
Mutual labels:  geometry, computational-geometry

MidcurveNN

Midcurve by Neural Networks

Midcurve

Description

  • Goal: Given a 2D closed shape (closed polygon) find its midcurve (polyline, closed or open)
  • Input: set of points or set of connected lines, non-intersecting, simple, convex, closed polygon
  • Output: another set of points or set of connected lines, open/branched polygons possible

Thoughts

Representation Issue

  • Shapes can not be modeled as sequences. Although polygon shape L may appear as sequence of points, it is not.
  • All shapes can not be drawn without lifting a pencil, which is possible for sequences. Say, Shapes like Y or concentric O, cannot be modeled as sequences. So, Midcurve transformation cannot be modeled as Sequence 2 Sequence network.
  • How to represent a geometric figure to feed to any Machine/Deep Learning problem, as they need numeric data in vector form?
  • How to convert geometric shapes (even after restricting the domain to 2D linear profile shapes) to vectors?
  • Closest data structure is graph, but thats predominantly topological and not geometrical. Meaning, graphs represent only connectivity and not spatial positions. Here, nodes would have coordinates and arcs would have curved-linear shape. So, even Graph Neural Networks, which convolute neighbors around a node and pool the output to generate vectors, are not suitable.
  • Need RnD to come up with a way to generate geometric-graph embedding that will convolute at nodes (having coordinates) around arcs (having geometry, say, a set of point coordinates), then pool them to form a meaningful representation. Real crux would be how to formulate pooling to aggregate all incident curves info plus node coordinates info into a single number!!

Variable Lengths Issue

  • It is a dimension-reduction problem. In 2D, input is the sketch profile (parametrically 2D), whereas the output is the midcurve (parametrically 1D). Input points are ordered (mostly forming closed loop, manifold). Output points may not be ordered, and can have branches (non-manifold)
  • It is a variable input and variable output problem as number of points and lines are different in input and output.
  • It is a network 2 network problem (not Sequence to Sequence) with variable size inputs and outputs
  • For Encoder Decoder like network, libraries like Tensorflow need fixed length inputs. If input has variable lengths then padding is done with some unused value. But the padding will be a big issue here as the padding value cannot be like 0,0 as it itself would be a valid point.
  • The problem of using seq2seq is that both input polygons and output branched midcurves are not linearly connected, they may have loops, or branches. Need to think more. (more details in LIMITATIONS below)
  • Instead of going to point list as i/o let’s look at well worked format of images. Images are of constant size, say 64x64 pixels. Let’s colour profile in the bitmap (b&w only) similarly midcurve in output bitmap. With this as i/o LSTM encoder decoder seq2seq can be applied. Variety in training data can be populated by shifting/rotating/scaling both i/o. Only 2D sketch profile for now. Only linear segments. Only single simple polygon with no holes.
  • How to vectorise? Each point as 2 floats/ints. So total input vector is polygon of m points is 2m floats/ints. Closed polygon with repeat the first point as last. Output is vector of 2n points. In case of closed figure, repeat the last point. Prepare training data using data files used in MIDAS. To make 100s, 1000s of input profiles, one can scale both input and output with different factors, and then randomly shuffle the entries. Find max num points of a profile, make that as fixed length for both input and output. Fill with 0,0??? As origin 0,0 could be valid part of profile…any other filler? NULL? Run simple feed forward NN, later RNN, LSTM, Seq2seq
  • See https://www.tensorflow.org/tutorials/seq2seq, https://www.youtube.com/watch?v=G5RY_SUJih4, A Neural Representation of Sketch Drawings, https://magenta.tensorflow.org/sketch_rnn https://github.com/tensorflow/magenta/blob/master/magenta/models/sketch_rnn/README.md
  • Add plotting capability, show polygons their midcurves etc, easy to debug and test unseen figures.

Dilution to Images

  • Images of geometric shapes address both, representation as well as variable-size issue. Big dilution is that, true geometric shapes are like Vector images, whereas images used here would be of Raster type. Approximation has crept in.

  • Even after modeling, the predicted output needs to be post-processed to bring to geometric form. Challenging again.

  • Thus, this project is divided into two phases:

    • Phase I: Image to Image transformation learning
      • Img2Img: i/o fixed size 100x100 bitmaps
      • Populate many by scaling/rotating/translating both io shapes within the fixed size
      • Use Encoder Decoder like Semantic Segmentation or Pix2Pix of IMages to learn dimension reduction
    • Phase II: Geometry to Geometry transformation learning
      • Build both, input and output polyline graphs with (x,y) coordinates as node features and edges with node id pairs mentioned. For poly-lines, edges being lines, no need to store geometric intermediate points as features, else for curves, store say, sampled fixed 'n' points.
      • Build Image-Segmentation like Encoder-Decoder network, given Graph Convolution Layers from DGL in place of usual Image-based 2D convolution layer, in the usual pytorch encoder-decoder model.
      • Generate variety of input-output polyline pairs, by using geometric transformations (and not image transformations as done in Phase I).
      • See if Variational Graph Auto-Encoders https://github.com/dmlc/dgl/tree/master/examples/pytorch/vgae can help.
  • Currently Phase I is under implementation. Phase II can start only after suitable geometric-graph embedding representation becomes available.

Publications/Talks

Citations

Regarding the state of the art, the closest work related to this paper is   from   Kulkarni[28].   
Kulkarni   proposed MidcurveNN, an encoder-decoder neural network to extract mid-curves from 
polygonal 2D shapes. The principle is to train the network with both a pixel image of the 
polygonal shape and of the final desired mid-curves. Although in an early  stage  of  research,  
the  network  is  able  to  produce reasonably  well  the mid-curves  of  simple  L-shaped polygons.  
The  limitations  of  this  work  remain  in  the noisiness of the produced results. 
It has not been tested on a large diversity of shapes and is performed on the full shape 
globally potentially requiring a high-resolution pixel grid for large models.

[28]Y.H. Kulkarni, MIDCURVENN: Encoder-decoder neural network for computing midcurve of a thin polygon, 
in: Open Data Sci. Conf.,2019

Disclaimer:

Author ([email protected]) gives no guarantee of the results of the program. It is just a fun script. Lot of improvements are still to be made. So, don’t depend on it at all.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].