JustinLin610 commited on
Commit
d23d897
1 Parent(s): de54dd3

update ckpt and update process

Browse files
Files changed (2) hide show
  1. app.py +3 -3
  2. ezocr/easyocrlite/reader.py +2 -2
app.py CHANGED
@@ -24,8 +24,8 @@ import gradio as gr
24
  # Register refcoco task
25
  tasks.register_task('ocr', OcrTask)
26
 
27
- os.system('wget https://shuangqing-multimodal.oss-cn-zhangjiakou.aliyuncs.com/ocr_general.pt; '
28
- 'mkdir -p checkpoints; mv ocr_general.pt checkpoints/ocr.pt')
29
 
30
  # turn on cuda if GPU is available
31
  use_cuda = torch.cuda.is_available()
@@ -189,7 +189,7 @@ description = "Gradio Demo for OFA-OCR. Upload your own image or click any one o
189
  "\"Submit\" and then wait for the generated OCR result. "
190
  article = "<p style='text-align: center'><a href='https://github.com/OFA-Sys/OFA' target='_blank'>OFA Github " \
191
  "Repo</a></p> "
192
- examples = [['lihe.png'], ['chinese.jpg'], ['paibian.jpeg'], ['shupai.png'], ['zuowen.jpg']]
193
  io = gr.Interface(fn=ocr, inputs=gr.inputs.Image(type='pil'),
194
  outputs=[gr.outputs.Image(type='pil'), gr.outputs.Textbox(label="OCR result")],
195
  title=title, description=description, article=article, examples=examples,
 
24
  # Register refcoco task
25
  tasks.register_task('ocr', OcrTask)
26
 
27
+ os.system('wget https://shuangqing-multimodal.oss-cn-zhangjiakou.aliyuncs.com/ocr_general_clean.pt; '
28
+ 'mkdir -p checkpoints; mv ocr_general_clean.pt checkpoints/ocr.pt')
29
 
30
  # turn on cuda if GPU is available
31
  use_cuda = torch.cuda.is_available()
 
189
  "\"Submit\" and then wait for the generated OCR result. "
190
  article = "<p style='text-align: center'><a href='https://github.com/OFA-Sys/OFA' target='_blank'>OFA Github " \
191
  "Repo</a></p> "
192
+ examples = [['lihe.png']] #, ['chinese.jpg'], ['paibian.jpeg'], ['shupai.png'], ['zuowen.jpg']]
193
  io = gr.Interface(fn=ocr, inputs=gr.inputs.Image(type='pil'),
194
  outputs=[gr.outputs.Image(type='pil'), gr.outputs.Textbox(label="OCR result")],
195
  title=title, description=description, article=article, examples=examples,
ezocr/easyocrlite/reader.py CHANGED
@@ -104,7 +104,7 @@ class ReaderLite(object):
104
 
105
  def process(
106
  self,
107
- image_path: str,
108
  max_size: int = 960,
109
  expand_ratio: float = 1.0,
110
  sharp: float = 1.0,
@@ -121,7 +121,7 @@ class ReaderLite(object):
121
  min_size: float = 0.01,
122
  ) -> Tuple[BoxTuple, list[np.ndarray]]:
123
 
124
- image = Image.open(image_path).convert('RGB')
125
 
126
  tensor, inverse_ratio = self.preprocess(
127
  image, max_size, expand_ratio, sharp, contrast
 
104
 
105
  def process(
106
  self,
107
+ img,
108
  max_size: int = 960,
109
  expand_ratio: float = 1.0,
110
  sharp: float = 1.0,
 
121
  min_size: float = 0.01,
122
  ) -> Tuple[BoxTuple, list[np.ndarray]]:
123
 
124
+ image = img.convert('RGB')
125
 
126
  tensor, inverse_ratio = self.preprocess(
127
  image, max_size, expand_ratio, sharp, contrast