rmm commited on
Commit
3e2cb2f
·
1 Parent(s): 0e02e00

fix: instantiating InputObservation with new call signature

Browse files

(see beca8fa)

Files changed (1) hide show
  1. src/input/input_handling.py +9 -10
src/input/input_handling.py CHANGED
@@ -184,16 +184,15 @@ def metadata_inputs_one_file(file:UploadedFile, image_hash:str, dbg_ix:int=0) ->
184
 
185
  author_email = st.session_state["input_author_email"]
186
  filename = file.name
187
- image_datetime = get_image_datetime(file)
188
  latitude0, longitude0 = get_image_latlon(file)
189
  msg = f"[D] {filename}: lat, lon from image metadata: {latitude0}, {longitude0}"
190
  m_logger.debug(msg)
191
 
192
- if latitude0 is None:
193
- # get it from the default dict
194
- latitude0 = spoof_metadata.get('latitude', 0) + dbg_ix
195
  if longitude0 is None:
196
- longitude0 = spoof_metadata.get('longitude', 0) - dbg_ix
197
 
198
  image = st.session_state.images.get(image_hash, None)
199
  # add the UI elements
@@ -225,9 +224,9 @@ def metadata_inputs_one_file(file:UploadedFile, image_hash:str, dbg_ix:int=0) ->
225
 
226
  # 5. Date/time
227
  ## first from image metadata
228
- if image_datetime is not None:
229
- time_value = datetime.datetime.strptime(image_datetime, '%Y:%m:%d %H:%M:%S').time()
230
- date_value = datetime.datetime.strptime(image_datetime, '%Y:%m:%d %H:%M:%S').date()
231
  else:
232
  time_value = datetime.datetime.now().time() # Default to current time
233
  date_value = datetime.datetime.now().date()
@@ -237,7 +236,7 @@ def metadata_inputs_one_file(file:UploadedFile, image_hash:str, dbg_ix:int=0) ->
237
  time_option = viewcontainer.time_input("Time for "+filename, time_value, key=f"input_time_{image_hash}")
238
 
239
  observation = InputObservation(image=image, latitude=latitude, longitude=longitude,
240
- author_email=author_email, date=image_datetime, time=None,
241
  date_option=date_option, time_option=time_option,
242
  uploaded_file=file, image_md5=image_hash
243
  )
@@ -391,4 +390,4 @@ def add_input_UI_elements() -> None:
391
  st.markdown('<style>.st-key-container_metadata_inputs_id { border: 1px solid lightgreen; border-radius: 5px; }</style>', unsafe_allow_html=True)
392
  container_metadata_inputs = st.container(border=True, key="container_metadata_inputs_id")
393
  container_metadata_inputs.write("Metadata Inputs... wait for file upload ")
394
- st.session_state.container_metadata_inputs = container_metadata_inputs
 
184
 
185
  author_email = st.session_state["input_author_email"]
186
  filename = file.name
187
+ image_datetime_raw = get_image_datetime(file)
188
  latitude0, longitude0 = get_image_latlon(file)
189
  msg = f"[D] {filename}: lat, lon from image metadata: {latitude0}, {longitude0}"
190
  m_logger.debug(msg)
191
 
192
+ if latitude0 is None: # get some default values if not found in exifdata
193
+ latitude0:float = spoof_metadata.get('latitude', 0) + dbg_ix
 
194
  if longitude0 is None:
195
+ longitude0:float = spoof_metadata.get('longitude', 0) - dbg_ix
196
 
197
  image = st.session_state.images.get(image_hash, None)
198
  # add the UI elements
 
224
 
225
  # 5. Date/time
226
  ## first from image metadata
227
+ if image_datetime_raw is not None:
228
+ time_value = datetime.datetime.strptime(image_datetime_raw, '%Y:%m:%d %H:%M:%S').time()
229
+ date_value = datetime.datetime.strptime(image_datetime_raw, '%Y:%m:%d %H:%M:%S').date()
230
  else:
231
  time_value = datetime.datetime.now().time() # Default to current time
232
  date_value = datetime.datetime.now().date()
 
236
  time_option = viewcontainer.time_input("Time for "+filename, time_value, key=f"input_time_{image_hash}")
237
 
238
  observation = InputObservation(image=image, latitude=latitude, longitude=longitude,
239
+ author_email=author_email, image_datetime_raw=image_datetime_raw,
240
  date_option=date_option, time_option=time_option,
241
  uploaded_file=file, image_md5=image_hash
242
  )
 
390
  st.markdown('<style>.st-key-container_metadata_inputs_id { border: 1px solid lightgreen; border-radius: 5px; }</style>', unsafe_allow_html=True)
391
  container_metadata_inputs = st.container(border=True, key="container_metadata_inputs_id")
392
  container_metadata_inputs.write("Metadata Inputs... wait for file upload ")
393
+ st.session_state.container_metadata_inputs = container_metadata_inputs