Spaces:
Running
on
T4
Running
on
T4
File size: 1,104 Bytes
6a29418 f87997e 6a29418 ed21af3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import gradio as gr
import numpy as np
import requests
import base64
import os
API_ENDPOINT = os.getenv('API_ENDPOINT')
API_KEY = os.getenv('API_KEY')
# setup
gallery = gr.Gallery(label="Rendered Image", show_label=False, elem_id="gallery").style(grid=[1], height="auto")
# infer
def infer(latex):
formula = latex
data = {'formula': formula, 'api_key': API_KEY}
with requests.post(url=API_ENDPOINT, data=data, timeout=600, stream=True) as r:
i = 0
for line in r.iter_lines():
response = line.decode('ascii').strip()
r = base64.decodebytes(response.encode('ascii'))
q = np.frombuffer(r, dtype=np.float32).reshape((64, 320, 3))
i += 1
yield i, [q,]
title = "Markup-to-Image Diffusion Models with Scheduled Sampling"
description="Yuntian Deng, Noriyuki Kojima, Alexander M. Rush"
# launch
gr.Interface(fn=infer, inputs=["text"], outputs=[gr.Slider(0, 1000, value=0, label='step (out of 1000)'), gallery],title=title,description=description).queue(concurrency_count=20, max_size=200).launch(enable_queue=True)
|