Please let me know if anyone has dealt with this issue.
I have a lot of 2D panels divided into segments, the segments are randomly generated.
The definition of a grasshopper is below in the post.
But you need to solve the problem
There are many such panels (without color) of various configurations (let’s say 8) they need to be colored and placed on layers of the corresponding name.
I thought, if I already have a base (accumulated in the process) of such colored panels, can I use machine learning (using some kind of plugin) to teach the grasshopper to color segments on these panels and give names to groups of objects, etc.
if something messy wrote please clarify please discuss))
Assume that you are able to get a 0/1 Matrix (user defines x/y res) that is in fact a “fingertip” of each panel (like doing 2D Voxel collections on per panel basis). If Color has some meaning … add Color info as well (using a proper Class where some Property is the Matrix and some other is the Color).
Then … using some classic Clustering algo … “grouping” these mini Matrices according some user defined match score value (kinda a primitive pattern recognition) … is rather elementary and real-time fast (for some reasonable amount of Matrices: say 200-300).
All that are very easy with code but I have no idea (nor any interest to know) how to do it with components.
Anyway notify if you want an entry level C# on that matter.
It is incredibly tedious to understand and “fix” complex code like this. One thing that was quickly obvious, however, is that the zipped 42+ MB Rhino file machine learning.3dm is not used by your GH code? If that is correct, why did you post it? To anyone else looking at this thread, I believe you don’t need the machine learning.7z file at all.
Another thing that’s obvious in studying the GH file is that you have used ‘Flatten’ when it would serve your goal better to avoid that. I don’t know if I’ll get any further, though taking a break often helps.
I’ve re-read your description several times but don’t understand it. I’ve spent a lot of time going through your code and don’t see anything related to “machine learning” or neural networks.
In the end, I did very little except unflatten the outputs of two BBX components and sort out the data tree branches. At the last minute, I added the two yellow groups to make all the Voronoi cells face the same direction by using circles as guide curves. Oh, I used my ColorB and ColorJ clusters to get the colors.
I see no purpose in the red group at the far right.
Again, the machine learning.7z zipped file and 42 MB Rhino file inside it are not needed.
P.S. Notes:
You can disable preview in the yellow groups.
You can change the radius of the pipes I used to show the edges or eliminate them. Without some width though, these edges disappear.
I found bugs caused by changing the random number seed value or the Random ‘N’ (Count) value. In the image below, I changed ‘N’ from 3 to 5 which makes it wacky.
Looking through the code, it’s easy to see why. The random zig-zag patterns overlap which messes up the lofting and Voronoi trimming. You need to solve that problem.
P.P.S. I looked at this code again, thinking about how to fix your problem, but I have too much on my plate at the moment and ended up just cleaning (and discarding) more code. Earlier in the model that I hadn’t touched before. Less code to do the same thing is better! Please use this version.
Peter, thanks for your reply.
I speak С Sharp at a basic level, you are one of those who inspired me to study it)))
I tried to solve this problem with the usual sorting and selection of objects.
but the geometry of the input is always random and the definition of a grasshopper does not always work perfectly.
thanks for responding
Apparently I messed up
I have attached a rhino file, there is an example of a colorized panel and 8 random panel options that I have as the original without color.
I have at the input a lot of such panels that have no color.
I need to color them according to the pattern on the left.
For a couple of years of work, I have accumulated a whole database of such panels that I painted, relatively speaking, with my hands.
I posted the grasshopper code so that it would be possible to create such panels randomly and experiment.
if I understand machine learning correctly, if I already have H number of such panels in color, I can use machine learning to teach a grasshopper to paint random such panels according to the database of bathhouses conditionally?
That doesn’t matter at all: all what you need is to assosiate Matrices (a “pixelated” status, that is) to your patterns (in order to Cluster them).
Since you speak C# … well … try to pixelate a Line (acc some user defined x/yRes).
After mastering the Line thing … the general case of this has as follows:
Given a boundary do random Curves inside (instead of just Lines). Forget your Vor shapes for the moment: it’s just the next (very easy) step.
Define a BrepFace from the boundary and split it with the Curves. This yields a Brep with a variable amount of BrepFaces (the “areas” for your Vor cells). Or cearch forCcx events on a per Curve basis (maybe is faster).
Define a grid using the Boundary BBox (hope that you know how to do that).
Define a Matrix M from that grid (set M.Zero()).
Foreach BrepFace in 2 test the grid pts for strict inclusion. If yes set the x/y Matrix cell to 1. Or do a classic Ccx Crv/Crv search.
So you have a pixelated result on hand: the Matrix, that is (for the moment forget Colors as well).
Do that for any other pattern (assuming that all Boundaries have the same size).
So the only thing missing is a Clustering Method using a custom Type defined via some Class (that’s elementary … but if you hit the wall … I’ll post one C#).
PS: trying to solve similar things with components is the art of pointless (but ignorance is a bliss).
PS: when an idiot (the computer) attempts to “see” a pattern … this means always classic Matrix ops.
For instance: how we can find a “similar” (to some ref crv) crv that way? (and if is not “exactly” the same … what can we do?) Answers: The Lord, District 666, North Pole.
I don’t see any attached Rhino file? Replacing the colors generated by ColorB and ColorJ with your color palette is relatively trivial. It can literally be as simple as replacing those clusters since it is isolated from the data tree structures.
I do not see yet that the task is trivial.
so it turns out the following
there is n number of panels that are randomly divided into an arbitrary number of surfaces by lines.
all objects initially without color
there are only reno objects
Grasshopper script to randomly create panels for example.
maybe here on the forum or on the Internet there were similar tasks using machine learning or other methods?
Again: dealing with ML without expert skills in coding is kinda attempting to ride fast a Panigale (while your previous bike was a CB500) => hospital or morgue on sight.
What is not trivial is maintaining useful data trees or keeping your random zig-zag lines from overlapping. Machine learning for these fundamental GH coding tasks makes no sense at all to me.
Step 1: Gather and Prepare Dataset
1.1 Collect the images of existing panels with labeled data for the segments’ colors and names of the groups of objects.
1.2 Organize and store the collected images in a specific directory for easy access.
1.3 Annotate the images by adding the labeled data for the segments’ colors and names of the groups of objects.
Step 2: Create and Train Machine Learning Model
2.1 Choose a suitable plugin for creating a machine learning model. There are several options available such as wrapped TensorFlow, PyTorch, Keras, etc.
2.2 Load the annotated image dataset into the chosen plugin.
2.3 Split the dataset into training and validation sets.
2.4 Configure the model architecture, including the number of layers, activation functions, optimizer, loss function, etc.
2.5 Train the model using the training set.
2.6 Evaluate the model using the validation set and fine-tune the parameters if necessary.
Step 3: Use the Trained Model
3.1 Load the trained model into the application.
3.2 Use the model to predict the segments’ colors and names of the groups of objects in new panels based on their configurations.
3.3 Verify the accuracy of the predictions and make improvements to the model if necessary.
I believe I could make a simple solution to help you with your classification project, I do not believe you need an AI to sort this problem out, however I believe that you should never listen to others undermining your ideas, you should always push for your ideas.
I do believe that this idea is overly complex for such a simple task, however you can totally use standard classification algorithms to solve this, it’s just overkill.
If you need help designing an AI solution to help you with your classification problem do not hesitate to reach out to me f.serragedine@shipdesign.it
thank you very much for the answer
I probably didn’t write exactly, the code in the grasshopper is just to simulate panels
the panels come to me as a rhino file they are all the same color on the same layer…
like this, there is no grasshopper file with data trees in fact for them …
plus, in addition to these panels, I have three-dimensional details that also need to be painted and they are just in the form of rhino files. but for now, let’s move on to 2d panels.
Well … the thing is that you should always optimize the weapon (in relation to the desired massacre). For instance Clustering about 200 Patterns the Matrix way yields 100 ms (max). If this is not the right weapon for the job I don’t know what is.
Note: you seriously overkill the term Pattern here: the only thing required is the separating Curves/Bands/Cats/Dogs (unless you want to get lost in the translation by examining all that Vor Polylines 1:1 - the art of pointless if you ask me).