Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,46 @@
|
|
1 |
-
---
|
2 |
-
license: llama2
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: llama2
|
3 |
+
datasets:
|
4 |
+
- nllg/datikz-v2
|
5 |
+
---
|
6 |
+
|
7 |
+
# Model Card for DeTi*k*Zify-CL<sub>7b</sub>
|
8 |
+
DeTi*k*Zify-CL<sub>7b</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 [CodeLlama
|
11 |
+
7b](https://huggingface.co/meta-llama/CodeLlama-7b-hf) and was fine-tuned on
|
12 |
+
[DaTi*k*Z<sub>v2</sub>](https://huggingface.co/datasets/nllg/datikz-v2). Check
|
13 |
+
out the [DeTi*k*Zify](https://github.com/potamides/DeTikZify) project for more
|
14 |
+
information and tips on how to best run the model.
|
15 |
+
|
16 |
+
## Usage
|
17 |
+
```python
|
18 |
+
from operator import itemgetter
|
19 |
+
|
20 |
+
from detikzify.model import load
|
21 |
+
from detikzify.infer import DetikzifyPipeline
|
22 |
+
import torch
|
23 |
+
|
24 |
+
image = "https://w.wiki/A7Cc"
|
25 |
+
pipeline = DetikzifyPipeline(*load(
|
26 |
+
base_model="nllg/detikzify-cl-7b",
|
27 |
+
device_map="auto",
|
28 |
+
torch_dtype=torch.bfloat16,
|
29 |
+
))
|
30 |
+
|
31 |
+
# generate a single TikZ program
|
32 |
+
fig = pipeline.sample(image=image)
|
33 |
+
|
34 |
+
# if it compiles, rasterize it and show it
|
35 |
+
if fig.is_rasterizable:
|
36 |
+
fig.rasterize().show()
|
37 |
+
|
38 |
+
# run MCTS for 10 minutes and generate multiple TikZ programs
|
39 |
+
figs = set()
|
40 |
+
for score, fig in pipeline.simulate(image=image, timeout=600):
|
41 |
+
figs.add((score, fig))
|
42 |
+
|
43 |
+
# save the best TikZ program
|
44 |
+
best = sorted(figs, key=itemgetter(0))[-1][1]
|
45 |
+
best.save("fig.tex")
|
46 |
+
```
|