UniquePratham commited on
Commit
f0cbf19
1 Parent(s): 9f3b39e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
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
- if st.sidebar.button("Paste from Clipboard"):
 
110
  try:
111
- clipboard_data = st.experimental_get_clipboard()
112
- if clipboard_data:
113
- image_data = base64.b64decode(clipboard_data)
114
- uploaded_file = tempfile.NamedTemporaryFile(delete=False, suffix=".png")
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 an image or an error occurred: {str(e)}")
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")