Spaces:
Running
Running
UniquePratham
commited on
Commit
•
f0cbf19
1
Parent(s):
9f3b39e
Update app.py
Browse files
app.py
CHANGED
@@ -106,16 +106,15 @@ model_choice = st.sidebar.selectbox("Select OCR Model:", ("GOT_CPU", "GOT_GPU",
|
|
106 |
uploaded_file = st.sidebar.file_uploader("Choose an image...", type=["png", "jpg", "jpeg"])
|
107 |
|
108 |
# Input from clipboard
|
109 |
-
|
|
|
110 |
try:
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
uploaded_file.write(image_data)
|
116 |
-
uploaded_file.seek(0)
|
117 |
except Exception as e:
|
118 |
-
st.sidebar.warning(f"Clipboard data is not
|
119 |
|
120 |
# Input from camera
|
121 |
camera_file = st.sidebar.camera_input("Capture from Camera")
|
|
|
106 |
uploaded_file = st.sidebar.file_uploader("Choose an image...", type=["png", "jpg", "jpeg"])
|
107 |
|
108 |
# Input from clipboard
|
109 |
+
clipboard_data = st.sidebar.text_area("Paste image data from Clipboard (base64 format):")
|
110 |
+
if clipboard_data:
|
111 |
try:
|
112 |
+
image_data = base64.b64decode(clipboard_data)
|
113 |
+
uploaded_file = tempfile.NamedTemporaryFile(delete=False, suffix=".png")
|
114 |
+
uploaded_file.write(image_data)
|
115 |
+
uploaded_file.seek(0)
|
|
|
|
|
116 |
except Exception as e:
|
117 |
+
st.sidebar.warning(f"Clipboard data is not a valid base64 encoded image or an error occurred: {str(e)}")
|
118 |
|
119 |
# Input from camera
|
120 |
camera_file = st.sidebar.camera_input("Capture from Camera")
|