Giter Club home page Giter Club 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wannesmalfait

detypify's Issues

How to draw a ℘?

How to draw a $\wp$ (\wp, ℘) ? At present, it seems that all inputs of the trajectory will be recognized as φ and other results. Is this because the dataset does not contain ℘?

[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

[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.

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.