Tonic commited on
Commit
e71614a
1 Parent(s): 7406abe

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from texify.inference import batch_inference
3
+ from texify.model.model import load_model
4
+ from texify.model.processor import load_processor
5
+ from PIL import Image
6
+
7
+ title="""🙋🏻‍♂️Welcome to🌟Tonic's👨🏻‍🔬Texify"""
8
+ 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)
9
+ Join us: TeamTonic is always making cool demos! Join our active builder's community on Discord: [Discord](https://discord.gg/nXx5wbX9) On Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On Github: [Polytonic](https://github.com/tonic-ai) & contribute to [PolyGPT](https://github.com/tonic-ai/polygpt-alpha) You can also join the [texify community here](https://discord.gg/zJSDQJWDe8). Big thanks to Vik Paruchuri for the invite and Huggingface for the Community Grant. Your special attentions are much appreciated.
10
+ """
11
+
12
+
13
+ =model = load_model()
14
+ processor = load_processor()
15
+
16
+ def process_image(img):
17
+ img = Image.fromarray(img)
18
+
19
+ results = batch_inference([img], model, processor)
20
+
21
+ return '\n'.join(results) if isinstance(results, list) else results
22
+
23
+ iface = gr.Interface(
24
+ gr.Markdown(title)
25
+ gr.Markdown(description)
26
+ fn=process_image,
27
+ inputs=gr.inputs.Image(type="pil"),
28
+ outputs="text",
29
+
30
+ if __name__ == "__main__":
31
+ iface.launch()