RufusRubin777 commited on
Commit
3cefb7d
Β·
verified Β·
1 Parent(s): 5fb60b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -17
app.py CHANGED
@@ -13,10 +13,8 @@ import easyocr
13
 
14
  # OCR Model
15
  tokenizer = AutoTokenizer.from_pretrained('RufusRubin777/GOT-OCR2_0_CPU', trust_remote_code=True, device_map='cpu')
16
- # model = AutoModel.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True, low_cpu_mem_usage=True, device_map='cuda', use_safetensors=True)
17
  model = AutoModel.from_pretrained('RufusRubin777/GOT-OCR2_0_CPU', trust_remote_code=True, low_cpu_mem_usage=True, device_map='cpu', use_safetensors=True)
18
- # model = model.eval().cuda()
19
- model = model.eval()
20
  reader = easyocr.Reader(['hi'])
21
 
22
  UPLOAD_FOLDER = "./uploads"
@@ -31,7 +29,7 @@ def image_to_base64(image):
31
  image.save(buffered, format="PNG")
32
  return base64.b64encode(buffered.getvalue()).decode()
33
 
34
- # OCR Processing of the image uploaded by the user
35
  # @spaces.GPU
36
  def run_GOT(image,language):
37
  unique_id = str(uuid.uuid4())
@@ -95,20 +93,7 @@ title_html = """
95
  <p>Scan Master uses General OCR Theory (GOT), a 580M end-to-end OCR 2.0 model for English optical character recognition and EASYOCR for Hindi optical character recognition. It supports plain text ocr.</p>
96
  """
97
 
98
- acknowledgement_html = """
99
- <h3>Acknowledgement</h3>
100
- <a href="https://huggingface.co/ucaslcl/GOT-OCR2_0">[😊 Hugging Face]</a>
101
- <a href="https://arxiv.org/abs/2409.01704">[πŸ“œ Paper]</a>
102
- <a href="https://github.com/Ucas-HaoranWei/GOT-OCR2.0/">[🌟 GitHub]</a>
103
- """
104
-
105
- aboutme_html = """
106
- <h3>About Me</h3>
107
- <p>Name : Satvik Chandrakar</p>
108
- <a href="https://github.com/Satvik-ai">[🌟 GitHub]</a> """
109
-
110
 
111
- # Scan Master web application developed using Gradio
112
  with gr.Blocks() as scan_master_web_app:
113
  gr.HTML(title_html)
114
  gr.Markdown("""
 
13
 
14
  # OCR Model
15
  tokenizer = AutoTokenizer.from_pretrained('RufusRubin777/GOT-OCR2_0_CPU', trust_remote_code=True, device_map='cpu')
 
16
  model = AutoModel.from_pretrained('RufusRubin777/GOT-OCR2_0_CPU', trust_remote_code=True, low_cpu_mem_usage=True, device_map='cpu', use_safetensors=True)
17
+ model = model.eval().cpu()
 
18
  reader = easyocr.Reader(['hi'])
19
 
20
  UPLOAD_FOLDER = "./uploads"
 
29
  image.save(buffered, format="PNG")
30
  return base64.b64encode(buffered.getvalue()).decode()
31
 
32
+
33
  # @spaces.GPU
34
  def run_GOT(image,language):
35
  unique_id = str(uuid.uuid4())
 
93
  <p>Scan Master uses General OCR Theory (GOT), a 580M end-to-end OCR 2.0 model for English optical character recognition and EASYOCR for Hindi optical character recognition. It supports plain text ocr.</p>
94
  """
95
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
 
97
  with gr.Blocks() as scan_master_web_app:
98
  gr.HTML(title_html)
99
  gr.Markdown("""