The web UI of DeTikZify requires TeX Live
2023, ghostscript,
and poppler. You can launch it by running
python -m detikzify.webui
. It comes with a command line interface. With the
--share
flag, for example, you can create a shareable link. Checkout --help
for a full list of supported options. As scientific figures usually use black
fonts on a white background, it is best to use the web UI in light mode. This
can be enforced by using the --light
flag. If FlashAttention-2
is installed, it is picked up automatically and should boost inference speeds.
Visual Prompting Creating sketches for DeTikZify (or providing any input images) shares many similarities with the process of prompting large language models. If DeTikZify struggles to comprehend your intent, consider "rephrasing" your input. This could mean simplifying your sketches or focusing more on the key issue at hand. In this particular instance, for example, we attempted to "prompt" DeTikZify to align characters diagonally around an equal sign, but it was unsuccessful even after many simulations. However, upon adjusting the input (by reducing the stroke width and using more easily recognizable characters) we achieved the intended output after only one simulation.
Image Editor You can draw sketches in the integrated image editor, but its feature set is quite limited. If you are not satisfied with the synthesized TikZ programs, try drawing more elaborate sketches in an editor of your choice (perhaps with graphics primitives) and upload them into the UI. Alternatively, experimenting with line thickness and/or colors in the integrated editor might also help.
Input Postprocessing Please note that all input images are cropped to the smallest square around their content and then resized to the resolution DeTikZify expects. If you leave large margins this means that DeTikZify might perceive your input differently from how you intended (e.g., by drawing thicker axes). As a rule of thumb, always try to fill as much of the canvas as possible.
Input Complexity If you provide very complex sketches (or figures) and are not satisfied with the results, you can also try segmenting (or simplifying) your input and letting DeTikZify synthesize the individual pieces independently. This has the advantage that the results will probably be better, and the disadvantage that you will have to modify and assemble the pieces yourself.
Source Code Artifacts Due to the way we preprocess our
arXiv.org data, the preambles of the extracted TikZ
programs sometimes include packages that are not used inside the tikzpicture
environments, and the DeTikZify models pick up on this behavior. While this
does not hinder compilation in any way, we still recommend everyone to check
the generated preambles and clean them up, if necessary.
Accuracy-Efficiency Trade-Off We noticed that lower values for temperatures and top-p (nucleus) values force DeTikZify to generate TikZ programs that follow the input images more closely, at the expense of generating more compile-time errors. We pick sensible defaults that aim to balance these two aspects, but you might want to try to tune these parameters yourself.
External Graphics In DaTikZv2, we replace any externally
included graphics in the tikzpicture
environments with the example
image
placeholder from the mwe package. So if you want
to generate code with placeholders for your own external graphics, just draw
that example image.