waleko commited on
Commit
ea58d06
1 Parent(s): 77f8033

temp remove pix2tikz

Browse files
Files changed (1) hide show
  1. webui.py +26 -26
webui.py CHANGED
@@ -17,7 +17,7 @@ import gradio as gr
17
  from transformers import TextIteratorStreamer, pipeline, ImageToTextPipeline, AutoModelForPreTraining, AutoProcessor
18
 
19
  import os
20
- from pix2tex.cli import LatexOCR
21
  from munch import Munch
22
  import spaces
23
 
@@ -26,7 +26,7 @@ from infer import TikzDocument, TikzGenerator
26
 
27
  # assets = files(__package__) / "assets" if __package__ else files("assets") / "."
28
  models = {
29
- "pix2tikz": "pix2tikz/mixed_e362_step201.pth",
30
  "llava-1.5-7b-hf": "waleko/TikZ-llava-1.5-7b",
31
  "new llava-1.5-7b-hf": "waleko/TikZ-llava-1.5-7b v2"
32
  }
@@ -57,29 +57,29 @@ def convert_to_svg(pdf):
57
  return doc[0].get_svg_image()
58
 
59
 
60
- def pix2tikz(
61
- checkpoint: str,
62
- image: Image.Image,
63
- temperature: float,
64
- _: float,
65
- __: int,
66
- ___: bool,
67
- ):
68
- cur_pwd = os.path.dirname(os.path.abspath(__file__))
69
- config_path = os.path.join(cur_pwd, 'pix2tikz/config.yaml')
70
- model_path = os.path.join(cur_pwd, checkpoint)
71
-
72
- print(cur_pwd, config_path, model_path, os.path.exists(config_path), os.path.exists(model_path))
73
-
74
- args = Munch({'config': config_path,
75
- 'checkpoint': model_path,
76
- 'no_resize': False,
77
- 'no_cuda': False,
78
- 'temperature': temperature})
79
- model = LatexOCR(args)
80
- res = model(image)
81
- text = re.sub(r'\\n(?=\W)', '\n', res)
82
- return text, None, True
83
 
84
 
85
  def inference(
@@ -93,7 +93,7 @@ def inference(
93
  try:
94
  image = image_dict['composite']
95
  if "pix2tikz" in model_name:
96
- yield pix2tikz(model_name, image, temperature, top_p, top_k, expand_to_square)
97
  return
98
 
99
  generate = TikzGenerator(
 
17
  from transformers import TextIteratorStreamer, pipeline, ImageToTextPipeline, AutoModelForPreTraining, AutoProcessor
18
 
19
  import os
20
+ # from pix2tex.cli import LatexOCR
21
  from munch import Munch
22
  import spaces
23
 
 
26
 
27
  # assets = files(__package__) / "assets" if __package__ else files("assets") / "."
28
  models = {
29
+ # "pix2tikz": "pix2tikz/mixed_e362_step201.pth",
30
  "llava-1.5-7b-hf": "waleko/TikZ-llava-1.5-7b",
31
  "new llava-1.5-7b-hf": "waleko/TikZ-llava-1.5-7b v2"
32
  }
 
57
  return doc[0].get_svg_image()
58
 
59
 
60
+ # def pix2tikz(
61
+ # checkpoint: str,
62
+ # image: Image.Image,
63
+ # temperature: float,
64
+ # _: float,
65
+ # __: int,
66
+ # ___: bool,
67
+ # ):
68
+ # cur_pwd = os.path.dirname(os.path.abspath(__file__))
69
+ # config_path = os.path.join(cur_pwd, 'pix2tikz/config.yaml')
70
+ # model_path = os.path.join(cur_pwd, checkpoint)
71
+ #
72
+ # print(cur_pwd, config_path, model_path, os.path.exists(config_path), os.path.exists(model_path))
73
+ #
74
+ # args = Munch({'config': config_path,
75
+ # 'checkpoint': model_path,
76
+ # 'no_resize': False,
77
+ # 'no_cuda': False,
78
+ # 'temperature': temperature})
79
+ # model = LatexOCR(args)
80
+ # res = model(image)
81
+ # text = re.sub(r'\\n(?=\W)', '\n', res)
82
+ # return text, None, True
83
 
84
 
85
  def inference(
 
93
  try:
94
  image = image_dict['composite']
95
  if "pix2tikz" in model_name:
96
+ # yield pix2tikz(model_name, image, temperature, top_p, top_k, expand_to_square)
97
  return
98
 
99
  generate = TikzGenerator(