WenqingZhang commited on
Commit
8f87303
β€’
1 Parent(s): 69856e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -80,6 +80,20 @@ def process_input(input_type, user_input, uploaded_file):
80
  return user_input
81
  else:
82
  return "ζ— ζ•ˆηš„θΎ“ε…₯η±»εž‹ζˆ–ζœͺδΈŠδΌ ζ–‡δ»Άγ€‚"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  def toggle_visibility(input_type):
85
  user_input_visible = input_type == "Text Input"
 
80
  return user_input
81
  else:
82
  return "ζ— ζ•ˆηš„θΎ“ε…₯η±»εž‹ζˆ–ζœͺδΈŠδΌ ζ–‡δ»Άγ€‚"
83
+ def process_input(input_type, user_input, uploaded_file):
84
+ print('ooooocr')
85
+ if input_type == "File Upload" and uploaded_file is not None:
86
+ # θ―»ε–δΈŠδΌ ηš„ζ–‡δ»Ά
87
+ with open(uploaded_file.name, "rb") as f:
88
+ image = f.read()
89
+ results = reader.readtext(image)
90
+ # ζε–θ―†εˆ«ηš„ζ–‡ζœ¬
91
+ extracted_text = ' '.join([text[1] for text in results])
92
+ print("ζε–ηš„ζ–‡ζœ¬:")
93
+ print(extracted_text)
94
+ return extracted_text
95
+ elif input_type == "Text Input":
96
+ return user_input
97
 
98
  def toggle_visibility(input_type):
99
  user_input_visible = input_type == "Text Input"