RufusRubin777 commited on
Commit
cadd139
·
verified ·
1 Parent(s): 61baa3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -24
app.py CHANGED
@@ -33,22 +33,12 @@ def run_GOT(image, language):
33
  image_path = os.path.join(UPLOAD_FOLDER, f"{unique_id}.png")
34
  shutil.copy(image, image_path)
35
  try:
36
- if language == "English":
37
- res = model.chat(tokenizer, image_path, ocr_type='ocr')
38
- return res
39
- elif language == "Hindi":
40
- res = reader.readtext(image)
41
- extracted_text = ''
42
- for x in res:
43
- extracted_text += x[1] + '\n'
44
- return extracted_text
45
- else:
46
- english_extraction = model.chat(tokenizer, image_path, ocr_type='ocr')
47
- hindi_extraction = reader.readtext(image)
48
- hindi_extract = ''
49
- for x in hindi_extraction:
50
- hindi_extract += x[1] + '\n'
51
- return english_extraction + '\n' + hindi_extract
52
  except Exception as e:
53
  return f"Error: {str(e)}", None
54
  finally:
@@ -102,18 +92,11 @@ title_html = """
102
 
103
  with gr.Blocks() as scan_master_web_app:
104
  gr.HTML(title_html)
105
- gr.Markdown("""
106
- You need to upload your image below and choose appropriate language, then click "Submit" to run the model. More characters will result in longer wait times.
107
- """)
108
 
109
  with gr.Row():
110
  with gr.Column():
111
  image_input = gr.Image(type="filepath", label="Upload your image")
112
- gr.Markdown("""
113
- If your image contains only English text, then choose English option in the language.
114
- If it contains only Hindi text, then choose Hindi option in the language.
115
- If it contains both languages, then choose the third option.
116
- """)
117
  lang_dropdown = gr.Dropdown(
118
  choices=["English", "Hindi", "English + Hindi"],
119
  label="Choose language",
 
33
  image_path = os.path.join(UPLOAD_FOLDER, f"{unique_id}.png")
34
  shutil.copy(image, image_path)
35
  try:
36
+ english_extraction = model.chat(tokenizer, image_path, ocr_type='ocr')
37
+ hindi_extraction = reader.readtext(image)
38
+ hindi_extract = ''
39
+ for x in hindi_extraction:
40
+ hindi_extract += x[1] + '\n'
41
+ return english_extraction + '\n' + hindi_extract
 
 
 
 
 
 
 
 
 
 
42
  except Exception as e:
43
  return f"Error: {str(e)}", None
44
  finally:
 
92
 
93
  with gr.Blocks() as scan_master_web_app:
94
  gr.HTML(title_html)
 
 
 
95
 
96
  with gr.Row():
97
  with gr.Column():
98
  image_input = gr.Image(type="filepath", label="Upload your image")
99
+
 
 
 
 
100
  lang_dropdown = gr.Dropdown(
101
  choices=["English", "Hindi", "English + Hindi"],
102
  label="Choose language",