Git Product home page Git Product logo

detypify's Introduction

logo

Detypify

Can't remember some Typst symbol? Draw it!

Features

  • PWA: installable and works offline
  • Tiny model: 1.3 MiB (ONNX), fast to load and run
  • Decent symbol set: support 400+ symbols

News

  • 2024-04-06: This project has been integrated into Tinymist.

Associated Repos

  • detypify-data: Detypify's own dataset (your contributions on the website finally go here)
  • detypify-external: Necessary external data to bootstrap Detypify

Use As A Library

Use the detypify-service NPM package.

Self Deployment

Download files from gh-pages branch and host them using any HTTP server.

Development

If you want to build migrate or train, you need to pull submodules. (Git LFS is required)

$ git submodule update --init --recursive

If you just want to build web, you can download train-out from NPM to project root.

Migrating

$ rye sync              # install venv and denpendencies
$ rye run migrate       # migrate
$ rye run migrate-font  # strip font (optional)

Training

$ rye sync       # install venv and denpendencies
$ rye run train  # train

Web Page

$ bun run --cwd=service copy  # copy train-out folder
$ bun install                 # install dependencies
$ bun run dev                 # start dev server
$ bun run build               # build for production

Logo & Favicons (Optional)

  1. Install NewComputerModernMath font (guide).

  2. Convert manuscript.svg.

    $ cd assets
    $ inkscape manuscript.svg --export-text-to-path --export-filename=logo.svg
    $ bunx svgo --multipass logo.svg
  3. Generate favicons by Favicon InBrowser.App using logo.svg.

  4. Move them to web/public/icons.

License

MIT

detypify's People

Contributors

quarticcat avatar

Stargazers

 avatar Monius avatar OJII3 avatar griffi-gh avatar  avatar  avatar Lukas Juhrich avatar Rubem Pacelli avatar Shigan Liu avatar Pop avatar Ruijie (Jerry) Gao avatar F. Y. avatar  avatar Eliseu Venites Filho avatar Stefano Vittorio Porta avatar  avatar Je Sian Keith Herman avatar Leo Li avatar Evan Liu avatar Ian Wrzesinski avatar Louis Vignoli avatar Zach avatar  avatar Shivam Meena avatar Simone Ragusa avatar µKöff avatar Airradda avatar flokl avatar lando avatar Senhsucht avatar  avatar  avatar Will B Chang avatar Yang Hanlin avatar  Liu Xiaoyi avatar Stefan Munnes avatar Adrián Delgado avatar  avatar hotwords avatar Vusal Aliev avatar Peng Guanwen avatar Akshay Shankar avatar fzyzcjy avatar  avatar Nimrod avatar  avatar Jihan avatar Vojta avatar  avatar Csimide avatar Ludwig Neste avatar Solirpa avatar Conor avatar GRUNK avatar DarkSky avatar Yiwei Yang avatar Fangdun Tsai avatar  avatar EYHN avatar  avatar  avatar Kyle L. Davis avatar Weverton Marques avatar Johannes Zottele avatar Quentin Bramas avatar Fr4nk1in avatar CiTrine avatar Cao Mingjun avatar Nicolai Weitkemper avatar John Skottis avatar  avatar liuly avatar Pavel Zwerschke avatar Slanterns avatar Tiankai Ma avatar BPY avatar Ionizing avatar Munteanu Vadim avatar  avatar DinghangTan avatar Francis Chua avatar Outvi V avatar IntrepidPig avatar OrangeX4 avatar Levi Zim avatar Adrian Sieber avatar Polo avatar Schrodinger ZHU Yifan avatar 破壁人五号 avatar Wenzhuo Liu avatar

Watchers

 avatar  avatar

Forkers

wannesmalfait

detypify's Issues

[Discussion] Lack of training data

Currently, all training data come from Detexify. The dataset is extremely unbalanced. Some symbols have more than 3900 samples, while some have less than 10 samples. Many uncommon symbols are nearly untrained.

Apart from that, due to the difference between LaTeX and Typst, some Typst symbols don't even have corresponding samples in Detexify's training data. For example, the join series (there's only \bowtie).

That is to say, we really need contributions from the community. Here comes the question: I don't know which platform is suitable for this need.

In addition to that, we can probably explore some data augmentation methods to enhance the training set. And unfortunately, I know nothing about that as well.

[Discussion] Stroke-based model?

The original training data come from Detexify is in the form of strokes that can be described as follows:

type Point = tuple[float, float, int]  # (x, y, timestamp)
type Stroke = list[Point]
type Strokes = list[Stroke]

The implementation of Detexify is KNN where distances are calculated by Greedy DTW. This model is too large to ship with the website. Besides, I don't know how to handle variable-length inputs. Therefore, I found another way.

Current model of Detypify (0.1.0) is naive CNN. It first normalizes strokes (center + scale), then draw them on a 32x32 canvas (pixelated, no anti-aliasing), then CNN. This approach has some drawbacks:

  • It cannot distinguish prime.rev and backslash very well. Normalization makes them look the same. There might be more such examples.
  • It cannot recognize uncommon symbols very well. This is more related to the problem of training data, which is extremely unbalanced: the numbers of samples vary from 10- to 3900+. But it seems like Detexify can recognize them.

Could a stroke-based model be better? If so, which model should I use?

Or, is there any potential improvement to the current model?

Unfriendly use as a library/package

We need an extra step to download detypify assets. What's worse is that we should keep in mind and update the assets on detypify upgrade its pre-trained model.

Myriad-Dreamin/tinymist#260

Possible solution: publish and install it via npm: yarn add detypify

import {Detypify} from 'detypify';
console.log((await Detypify.create()).candidates(strokes));

https://github.com/Myriad-Dreamin/tinymist/blob/01f72c3d75b099afff7ff59c394067e57b79027a/tools/editor-tools/src/features/symbol-view.detypify.ts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.