Spaces:
Runtime error
Runtime error
import gradio as gr | |
import spaces | |
from texify.inference import batch_inference | |
from texify.model.model import load_model | |
from texify.model.processor import load_processor | |
from PIL import Image | |
title="""# 🙋🏻♂️Welcome to🌟Tonic's👨🏻🔬Texify""" | |
description="""You can upload a picture with a math formula and this model will return latex formulas. Texify is a multimodal input model. You can use this Space to test out the current model [vikp/texify2](https://huggingface.co/vikp/texify2) You can also use vikp/texify2🚀 by cloning this space. Simply click here: [Duplicate Space](https://huggingface.co/spaces/Tonic1/texify?duplicate=true) | |
Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community 👻 [](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to 🌟 [DataTonic](https://github.com/Tonic-AI/DataTonic) 🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗 | |
""" | |
model = load_model() | |
processor = load_processor() | |
def process_image(img): | |
# img = Image.fromarray(img) | |
results = batch_inference([img], model, processor) | |
return '\n'.join(results) if isinstance(results, list) else results | |
with gr.Blocks() as app: | |
gr.Markdown(title) | |
gr.Markdown(description) | |
with gr.Row(): | |
with gr.Column(): | |
image_input = gr.Image(type="pil") | |
with gr.Column(): | |
output = gr.Textbox() | |
image_input.change(process_image, inputs=image_input, outputs=output) | |
if __name__ == "__main__": | |
app.launch() |