@@ -85,7 +85,7 @@ def call_model(args, model, image_resizer, tokenizer):
85
85
else :
86
86
img = np .array (pad (img ).convert ('RGB' ))
87
87
t = test_transform (image = img )['image' ][:1 ].unsqueeze (0 )
88
-
88
+ print ( "processing... \n " )
89
89
im = t .to (args .device )
90
90
91
91
with torch .no_grad ():
@@ -134,7 +134,8 @@ def call_model(args, model, image_resizer, tokenizer):
134
134
args , * objs = initialize (args )
135
135
while True :
136
136
instructions = input ('Predict LaTeX code for image ("?"/"h" for help). ' )
137
- ins = instructions .strip ().lower ()
137
+ possible_file = instructions .strip ()
138
+ ins = possible_file .lower ()
138
139
if ins == 'x' :
139
140
break
140
141
elif ins in ['?' , 'h' , 'help' ]:
@@ -144,16 +145,16 @@ def call_model(args, model, image_resizer, tokenizer):
144
145
On Windows and macOS you can copy the image into memory and just press ENTER to get a prediction.
145
146
Alternatively you can paste the image file path here and submit.
146
147
147
- You might get a different prediction every time you submit the same image. If the result you got was close you \
148
- can just predict the same image by pressing ENTER again. If that still does not work you can change the temperature \
149
- or you have take another picture with another resolution.
148
+ You might get a different prediction every time you submit the same image. If the result you got was close you
149
+ can just predict the same image by pressing ENTER again. If that still does not work you can change the temperature
150
+ or you have to take another picture with another resolution (e.g. zoom out and take a screenshot with lower resolution).
150
151
151
152
Press "x" to close the program.
152
153
You can interrupt the model if it takes too long by pressing Ctrl+C.
153
154
154
155
Visualization:
155
- You can either render the code into a png using XeLaTeX (see README) to get an image file back. \
156
- This is slow and requires a working installation of XeLaTeX. To activate type 'show' or set the flag --show
156
+ You can either render the code into a png using XeLaTeX (see README) to get an image file back.
157
+ This is slow and requires a working installation of XeLaTeX. To activate type 'show' or set the flag --show
157
158
Alternatively you can render the expression in the browser using katex.org. Type 'katex' or set --katex
158
159
159
160
Settings:
@@ -165,8 +166,8 @@ def call_model(args, model, image_resizer, tokenizer):
165
166
setattr (args , ins , not getattr (args , ins , False ))
166
167
print ('set %s to %s' % (ins , getattr (args , ins )))
167
168
continue
168
- elif os .path .isfile (ins ):
169
- args .file = ins
169
+ elif os .path .isfile (possible_file ):
170
+ args .file = possible_file
170
171
else :
171
172
t = re .match (r't=([\.\d]+)' , ins )
172
173
if t is not None :
0 commit comments