How can I use the AllenNLP framework to embed a label? - embed

Just like using "textfieldembedder" to embed "textfieldtensors", I want to embed labels and convert them into tensors with the same dimension as embedded input texts.

Do you know about LabelField? Just put the appropriate LabelFields into your instances, and AllenNLP will add the labels to the vocabulary for you. When Model.__init__() runs, you can query the size of the label namespace to find out how big to make your embedding matrix.

Just create a normal torch.nn.Embedding in your model, and as Dirk suggests, set its size based on the vocabulary's size for the label field during Model.__init__.

Related

Annotating images with text for deep learning + NLP

I am looking for a way to label document images and at the same time annotate the text that is inside the bounding boxes. Do you know anything to do this task?
(I have the coordinates of the image text obtained by Google-vision-API response)
thanks!
You can use annotation tools like: PPOCRLabel. This is a semi-automatic tool means it will auto-generate the text and you can edit them later.

Dynamically change line color dcc.Graph Plotly Dash between annotations

I'm writing a 'template creation' app using the dcc.Graph image annotation features in Plotly Dash.
The user adds multiple rectangles for specific features in the image (an invoice) and my callback captures the coordinates of each rectangle via the relayoutData variable. I want to use a different color for each rectangle, but can't figure out how to do it.
It seems like the only way to change the newshapes fillcolor
property is to replace the whole figure, but then I lose all previous shapes
All and any help appreciated.
Andrew
I have just found the following demo that does exactly what I am trying to do:
https://dash-gallery.plotly.host/dash-image-annotation/
Now to unpack the logic and adapt it to my context ... Happy 2021!
Andrew

How to get the orientation of the element in autodesk forge

I have a cabinet and I want to get the orientation of the cabinet. I want to automatically locate the front of the cabinet.I don't know how to get the orientation
This is a tricky problem.
Front is relative to something. If you have a cabinet, one can assume the Front is where the handles are. Now assuming the handle is a block (AutoCAD), or a family (Revit), or a part (Inventor), your code may search for such an instance.
From the above, search for this object, then calculate a vector from the center to it. That will be the base vector for a raytrace.

ITK difference betweeen SetInitialTransform and SetMovingInitialTransform

I am now using ITK library to image registration. I wonder, when setting initial parameters for ImageRegistrationMethodv4 type registration, shall I use SetMovingInitialTransform and SetFixedInitialTransform like in the tutorial, or just SetInitialTransform??
The "transform" in SetInitialTransform means transform for moving image or for fixed image? Thank you:)
(Please read this with caution--I do not have the library with me to test this answer; it's based on memory only.)
I believe SetInitialTransform() refers to the transform which is actually optimized by the registration method. In other words, it is a collection of transform parameters that specify an "initial guess" for the optimization process; these parameters will then start moving around at each iteration. (They are therefore applied to the moving image.)
I think SetMovingInitialTransform() and SetFixedInitialTransform() refer to static initial transforms which do no change at all during the registration process. They merely "set up" the moving and fixed images to desired starting locations, if you are not satisfied with their default positions in space.
If you have some simple 2D images, try testing this answer out with simple initial transformations, like a 5-unit translation transformation or something.
You could try reading the ImageRegistrationMethov4 documentation for a little more info.

Add text to Alternativa3d?

I'm creating an app with Alternativa3d (8.17.0), and would like to add labels to some cubes. But it doesn't seem like the Alternativa API provides a way to do it...
Now I know I can either:
Add a TextField to the Flash display list in the normal manner
Render the text as a bitmap beforehand and upload as a resource to the GPU
Render the text to a bitmap at run time, and upload as a resource to the GPU
BUT I need the content to be added directly to the Alternativa cube (which precludes the first option) and the text is dynamic (i.e. not known at compile time - precludes the second) and the third just feels hacky.
Is there a clean way to do this?
Depending on how you want the text displayed you could do a number of different things..
You could use a Sprite3D and add the text rendered as a bitmap. You can place the sprite3d near the cube and it will always face the camera so as you move around the cubes they will appear in 3d space but facing you at all times.
Another option is to add it to the actual cube as suggested by danii using a movieclip. However the link to that MovieClipMaterial is no longer valid and is actually for a previous version of Alternativa not version 8. I have created my own movieclipmaterial for version 8 here ( http://davidejones.com/blog/1392-moviematerial-alternativa3d-8/ ) should you want to do that.
Lastly you could render the text to bitmap and merge this with the cubes bitmap so the text is layered on top and then set this material onto the cube.
Personallt i'd use the sprite3d method its alot easier and i think will give a better effect. Take a look at this example which uses the same effect ( http://gkb40.ur.ru/web/map40a3d.swf )
Just put your TextField inside a MovieClip, and use the class MovieClipMaterial to set that MovieClip as a material for one of the sides of the cube.