potamides commited on
Commit
20a51dc
1 Parent(s): 048b58b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +47 -3
README.md CHANGED
@@ -1,3 +1,47 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - nllg/datikz-v2
5
+ ---
6
+
7
+ # Model Card for DeTi*k*Zify-TL<sub>1.1b</sub>
8
+ DeTi*k*Zify-TL<sub>1.1b</sub> is a language model that automatically converts
9
+ sketches and existing scientific figures into editable, semantics-preserving
10
+ Ti*k*Z graphics programs. It is based on
11
+ [TinyLlama](https://huggingface.co/TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T)
12
+ and was fine-tuned on
13
+ [DaTi*k*Z<sub>v2</sub>](https://huggingface.co/datasets/nllg/datikz-v2). Check
14
+ out the [DeTi*k*Zify](https://github.com/potamides/DeTikZify) project for more
15
+ information and tips on how to best run the model.
16
+
17
+ ## Usage
18
+ ```python
19
+ from operator import itemgetter
20
+
21
+ from detikzify.model import load
22
+ from detikzify.infer import DetikzifyPipeline
23
+ import torch
24
+
25
+ image = "https://w.wiki/A7Cc"
26
+ pipeline = DetikzifyPipeline(*load(
27
+ base_model="nllg/detikzify-tl-1.1b",
28
+ device_map="auto",
29
+ torch_dtype=torch.bfloat16,
30
+ ))
31
+
32
+ # generate a single TikZ program
33
+ fig = pipeline.sample(image=image)
34
+
35
+ # if it compiles, rasterize it and show it
36
+ if fig.is_rasterizable:
37
+ fig.rasterize().show()
38
+
39
+ # run MCTS for 10 minutes and generate multiple TikZ programs in the process
40
+ figs = set()
41
+ for score, fig in pipeline.simulate(image=image, timeout=600):
42
+ figs.add((score, fig))
43
+
44
+ # save the best TikZ program
45
+ best = sorted(figs, key=itemgetter(0))[-1][1]
46
+ best.save("fig.tex")
47
+ ```