freealise commited on
Commit
cabfe86
1 Parent(s): ec3d4a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -19
app.py CHANGED
@@ -14,6 +14,7 @@ import tempfile
14
  from functools import partial
15
  import spaces
16
  from zipfile import ZipFile
 
17
 
18
  from depth_anything.dpt import DepthAnything
19
  from depth_anything.util.transform import Resize, NormalizeImage, PrepareForNet
@@ -451,8 +452,14 @@ with gr.Blocks(css=css) as demo:
451
  selected = gr.Number(elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
452
  output_frame.select(fn=select_frame, inputs=None, outputs=[output_depth, selected], show_progress='hidden')
453
  output_depth.select(fn=select_frame, inputs=None, outputs=[output_frame, selected], show_progress='hidden')
454
- example_coords = '50.07379596793083,14.437146122950555 50.073799567020004,14.437146774240507 50.07377647505558,14.437161000659017 50.07379496839027,14.437148958238538 50.073823157821664,14.437124189538856'
455
- coords = gr.Textbox(elem_id="coords", value=example_coords, label="Precise coordinates", show_label=False)
 
 
 
 
 
 
456
  offset = gr.HTML(value="""<svg id='offset' height='256' width='256' viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;background-color:transparent;' onpointerdown='
457
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
458
  var evt = document.createEvent(\"Event\");
@@ -605,30 +612,18 @@ with gr.Blocks(css=css) as demo:
605
  locations = []
606
 
607
  if not coordinates:
608
- locations_str = example_coords.split()
609
  else:
610
- locations_str = coordinates.split()
611
- print(locations_str)
612
-
613
- avg_coords = [0.0, 0.0]
614
- for location in locations_str:
615
- location = location.split(',')
616
- avg_coords[0] = avg_coords[0] + float(location[0])
617
- avg_coords[1] = avg_coords[1] + float(location[1])
618
-
619
- avg_coords[0] = avg_coords[0] / len(locations_str)
620
- avg_coords[1] = avg_coords[1] / len(locations_str)
621
 
622
- for location in locations_str:
623
- location = location.split(',')
624
- locations.append([ float(location[0]) - avg_coords[0], float(location[1]) - avg_coords[1] ])
625
  print(locations)
626
 
627
  # Process the video and get the path of the output video
628
  output_video_path = make_video(uploaded_video,encoder=model_type)
629
- output_video_path.append(locations)
630
 
631
- return output_video_path
632
 
633
  submit.click(on_submit, inputs=[input_video, model_type, coords], outputs=[processed_video, processed_zip, output_frame, output_depth, coords])
634
  render.click(partial(get_mesh), inputs=[output_frame, output_depth, blur_in, load_all], outputs=[result])
 
14
  from functools import partial
15
  import spaces
16
  from zipfile import ZipFile
17
+ import json
18
 
19
  from depth_anything.dpt import DepthAnything
20
  from depth_anything.util.transform import Resize, NormalizeImage, PrepareForNet
 
452
  selected = gr.Number(elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
453
  output_frame.select(fn=select_frame, inputs=None, outputs=[output_depth, selected], show_progress='hidden')
454
  output_depth.select(fn=select_frame, inputs=None, outputs=[output_frame, selected], show_progress='hidden')
455
+ example_coords = """[
456
+ {latLng: { lat: 50.07379596793083, lng: 14.437146122950555 } },
457
+ {latLng: { lat: 50.073799567020004, lng: 14.437146774240507 } },
458
+ {latLng: { lat: 50.07377647505558, lng: 14.437161000659017 } },
459
+ {latLng: { lat: 50.07379496839027, lng: 14.437148958238538 } },
460
+ {latLng: { lat: 50.073823157821664, lng: 14.437124189538856 } }
461
+ ]"""
462
+ coords = gr.JSON(elem_id="coords", value=example_coords, label="Precise coordinates", show_label=False)
463
  offset = gr.HTML(value="""<svg id='offset' height='256' width='256' viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;background-color:transparent;' onpointerdown='
464
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
465
  var evt = document.createEvent(\"Event\");
 
612
  locations = []
613
 
614
  if not coordinates:
615
+ locations = json.loads(example_coords)
616
  else:
617
+ locations = json.loads(coordinates)
 
 
 
 
 
 
 
 
 
 
618
 
619
+ for location in locations:
620
+ location = location.latLng
 
621
  print(locations)
622
 
623
  # Process the video and get the path of the output video
624
  output_video_path = make_video(uploaded_video,encoder=model_type)
 
625
 
626
+ return output_video_path + (locations)
627
 
628
  submit.click(on_submit, inputs=[input_video, model_type, coords], outputs=[processed_video, processed_zip, output_frame, output_depth, coords])
629
  render.click(partial(get_mesh), inputs=[output_frame, output_depth, blur_in, load_all], outputs=[result])