epg900 commited on
Commit
97b9782
·
verified ·
1 Parent(s): 4db401f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -57,11 +57,10 @@ def gradio_interface():
57
  image = Image.open(file.name)
58
  extracted_text = ocr(image, lang)
59
  filename = os.path.basename(file.name)
60
- filename = os.path.split(filename)
61
- print(filename)
62
- with open('output.txt','w',encoding='utf-8') as f:
63
  f.write(extracted_text)
64
- return ['output.txt']
65
 
66
  # Create and launch Gradio interface
67
  gr.Interface(
@@ -70,7 +69,7 @@ def gradio_interface():
70
  outputs=[gr.File()],
71
  title="OCR (PDF/Image)",
72
  description="Upload a PDF or Image, select the OCR language, and extract the text."
73
- ).launch()
74
 
75
 
76
  # Call the function to create the interface
 
57
  image = Image.open(file.name)
58
  extracted_text = ocr(image, lang)
59
  filename = os.path.basename(file.name)
60
+ nuul, filename = os.path.split(filename)
61
+ with open(f'{filename}.txt','w',encoding='utf-8') as f:
 
62
  f.write(extracted_text)
63
+ return [f'{filename}.txt']
64
 
65
  # Create and launch Gradio interface
66
  gr.Interface(
 
69
  outputs=[gr.File()],
70
  title="OCR (PDF/Image)",
71
  description="Upload a PDF or Image, select the OCR language, and extract the text."
72
+ ).launch(share=True, allowed_paths=[f'{filename}.txt'])
73
 
74
 
75
  # Call the function to create the interface