Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,9 +9,12 @@ import torch
|
|
| 9 |
import os
|
| 10 |
import re
|
| 11 |
import json
|
|
|
|
|
|
|
| 12 |
from groq import Groq
|
| 13 |
from st_keyup import st_keyup
|
| 14 |
-
from
|
|
|
|
| 15 |
|
| 16 |
# Page configuration
|
| 17 |
st.set_page_config(page_title="DualTextOCRFusion", page_icon="π", layout="wide")
|
|
@@ -109,16 +112,12 @@ uploaded_file = st.sidebar.file_uploader("Choose an image...", type=["png", "jpg
|
|
| 109 |
|
| 110 |
# Input from clipboard
|
| 111 |
# Paste image button
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
errors='ignore'
|
| 119 |
-
)
|
| 120 |
-
if paste_result:
|
| 121 |
-
uploaded_file = paste_result.image_data
|
| 122 |
|
| 123 |
# Input from camera
|
| 124 |
camera_file = st.sidebar.camera_input("Capture from Camera")
|
|
|
|
| 9 |
import os
|
| 10 |
import re
|
| 11 |
import json
|
| 12 |
+
import io
|
| 13 |
+
import base64
|
| 14 |
from groq import Groq
|
| 15 |
from st_keyup import st_keyup
|
| 16 |
+
from st_img_pastebutton import paste
|
| 17 |
+
|
| 18 |
|
| 19 |
# Page configuration
|
| 20 |
st.set_page_config(page_title="DualTextOCRFusion", page_icon="π", layout="wide")
|
|
|
|
| 112 |
|
| 113 |
# Input from clipboard
|
| 114 |
# Paste image button
|
| 115 |
+
image_data = paste(label="paste from clipboard",key="image_clipboard")
|
| 116 |
+
if image_data is not None:
|
| 117 |
+
header, encoded = image_data.split(",", 1)
|
| 118 |
+
decoded_bytes = base64.b64decode(encoded)
|
| 119 |
+
img_stream = io.BytesIO(decoded_bytes)
|
| 120 |
+
uploaded_file=img_stream
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
# Input from camera
|
| 123 |
camera_file = st.sidebar.camera_input("Capture from Camera")
|