Commit
·
c70224f
0
Parent(s):
Duplicate from yuntian-deng/latex2im
Browse filesCo-authored-by: Yuntian Deng <[email protected]>
- .gitattributes +31 -0
- README.md +14 -0
- app.py +43 -0
.gitattributes
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
23 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Latex2im
|
3 |
+
emoji: 🔥
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: blue
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.4
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: mit
|
11 |
+
duplicated_from: yuntian-deng/latex2im
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# https://huggingface.co/yuntian-deng/latex2im_ss_finetunegptneo
|
2 |
+
import gradio as gr
|
3 |
+
import numpy as np
|
4 |
+
import requests
|
5 |
+
import base64
|
6 |
+
import os
|
7 |
+
|
8 |
+
API_ENDPOINT = os.getenv('API_ENDPOINT')
|
9 |
+
API_KEY = os.getenv('API_KEY')
|
10 |
+
|
11 |
+
title = "<h1><center>Markup-to-Image Diffusion Models with Scheduled Sampling</center></h1>"
|
12 |
+
authors = "<center>Yuntian Deng, Noriyuki Kojima, Alexander M. Rush</center>"
|
13 |
+
info = '<center><a href="https://arxiv.org/pdf/2210.05147.pdf">Paper</a> <a href="https://github.com/da03/markup2im">Code</a></center>'
|
14 |
+
|
15 |
+
with gr.Blocks() as demo:
|
16 |
+
gr.Markdown(title)
|
17 |
+
gr.Markdown(authors)
|
18 |
+
gr.Markdown(info)
|
19 |
+
with gr.Row():
|
20 |
+
with gr.Column(scale=2):
|
21 |
+
textbox = gr.Textbox(label=r'Type LaTeX formula below and click "Generate"', lines=1, max_lines=1, placeholder='Type LaTeX formula here and click "Generate"', value=r'\sum_{t=1}^T\E_{y_t \sim {\tilde P(y_t| y_0)}} \left\| \frac{y_t - \sqrt{\bar{\alpha}_t}y_0}{\sqrt{1-\bar{\alpha}_t}} - \epsilon_\theta(y_t, t)\right\|^2.')
|
22 |
+
submit_btn = gr.Button("Generate", elem_id="btn")
|
23 |
+
with gr.Column(scale=3):
|
24 |
+
slider = gr.Slider(0, 1000, value=0, label='step (out of 1000)')
|
25 |
+
image = gr.Image(label="Rendered Image", show_label=False, elem_id="image")
|
26 |
+
inputs = [textbox]
|
27 |
+
outputs = [slider, image, submit_btn]
|
28 |
+
def infer(formula):
|
29 |
+
data = {'formula': formula, 'api_key': API_KEY}
|
30 |
+
try:
|
31 |
+
with requests.post(url=API_ENDPOINT, data=data, timeout=600, stream=True) as r:
|
32 |
+
i = 0
|
33 |
+
for line in r.iter_lines():
|
34 |
+
response = line.decode('ascii').strip()
|
35 |
+
r = base64.decodebytes(response.encode('ascii'))
|
36 |
+
q = np.frombuffer(r, dtype=np.float32).reshape((64, 320, 3))
|
37 |
+
i += 1
|
38 |
+
yield i, q, submit_btn.update(visible=False)
|
39 |
+
yield i, q, submit_btn.update(visible=True)
|
40 |
+
except Exception as e:
|
41 |
+
yield 1000, 255*np.ones((64, 320, 3)), submit_btn.update(visible=True)
|
42 |
+
submit_btn.click(fn=infer, inputs=inputs, outputs=outputs)
|
43 |
+
demo.queue(concurrency_count=20, max_size=200).launch(enable_queue=True)
|