heecheol.park commited on
Commit
737d609
Β·
1 Parent(s): a3b945a

revert: remove copy to clipboard feature and return to original code

Browse files
Files changed (1) hide show
  1. app.py +1 -32
app.py CHANGED
@@ -9,42 +9,11 @@ def ocr_image_to_text(image: Image.Image):
9
  text = pytesseract.image_to_string(image_cv, lang='eng+kor')
10
  return text
11
 
12
-
13
- COPY_TO_CLIPBOARD_SCRIPT = """
14
- <script>
15
- function copyToClipboard() {
16
- const textArea = document.createElement('textarea');
17
- textArea.value = document.getElementById('output-text').innerText;
18
- document.body.appendChild(textArea);
19
- textArea.select();
20
- document.execCommand('copy');
21
- document.body.removeChild(textArea);
22
- }
23
- </script>
24
- """
25
-
26
- template = gr.templates.Template(
27
- input_template=gr.templates.custom_templates.INPUT_TEMPLATE,
28
- output_template=f"""
29
- <style>
30
- #output-text {{
31
- white-space: pre-wrap;
32
- }}
33
- </style>
34
- <div id="output-text">{{{output}}}</div>
35
- <button onclick="copyToClipboard()">Copy to Clipboard</button>
36
- {COPY_TO_CLIPBOARD_SCRIPT}
37
- """,
38
- input_width=6,
39
- output_width=6,
40
- )
41
-
42
-
43
  # Gradio μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ •μ˜ν•©λ‹ˆλ‹€.
44
  image_input = gr.inputs.Image(label="Upload an image")
45
  text_output = gr.outputs.Textbox(label="Extracted Text")
46
 
47
- iface = gr.Interface(fn=ocr_image_to_text, inputs=image_input, outputs=text_output, title="OCR Image to Text", template=template)
48
 
49
  # μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‹€ν–‰ν•˜κ³  Hugging Face Spaces에 λ°°ν¬ν•©λ‹ˆλ‹€.
50
  iface.launch()
 
9
  text = pytesseract.image_to_string(image_cv, lang='eng+kor')
10
  return text
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  # Gradio μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ •μ˜ν•©λ‹ˆλ‹€.
13
  image_input = gr.inputs.Image(label="Upload an image")
14
  text_output = gr.outputs.Textbox(label="Extracted Text")
15
 
16
+ iface = gr.Interface(fn=ocr_image_to_text, inputs=image_input, outputs=text_output, title="OCR Image to Text")
17
 
18
  # μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‹€ν–‰ν•˜κ³  Hugging Face Spaces에 λ°°ν¬ν•©λ‹ˆλ‹€.
19
  iface.launch()