freealise commited on
Commit
ec6e24b
1 Parent(s): 59f0d02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -6
app.py CHANGED
@@ -20,6 +20,7 @@ from depth_anything.util.transform import Resize, NormalizeImage, PrepareForNet
20
  from moviepy.editor import *
21
 
22
  frame_selected = 0
 
23
 
24
  def zip_files(files_in, files_out):
25
  with ZipFile("depth_result.zip", "w") as zipObj:
@@ -526,17 +527,32 @@ with gr.Blocks(css=css) as demo:
526
  ctxt.drawImage(this, 0, 0);
527
  '/><br/>
528
  <canvas id='cnv_out'/>""")
529
- example_coords = ['50.07379596793083,14.437146122950555 50.073799567020004,14.43714677424050 50.07377647505558,14.437161000659017 50.07379496839027,14.437148958238538 50.073823157821664,14.437124189538856']
530
- with gr.Accordion(label="Coordinates", open=False):
531
- coords = gr.Textbox(value=example_coords[0], label="Precise locations", show_label=False)
532
  render = gr.Button("Render")
533
 
534
  def on_submit(uploaded_video,model_type,coordinates):
535
-
 
536
  if not coordinates:
537
- print(example_coords[0])
538
  else:
539
- print(coordinates)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
 
541
  # Process the video and get the path of the output video
542
  output_video_path = make_video(uploaded_video,encoder=model_type)
 
20
  from moviepy.editor import *
21
 
22
  frame_selected = 0
23
+ locations = []
24
 
25
  def zip_files(files_in, files_out):
26
  with ZipFile("depth_result.zip", "w") as zipObj:
 
527
  ctxt.drawImage(this, 0, 0);
528
  '/><br/>
529
  <canvas id='cnv_out'/>""")
530
+ example_coords = '50.07379596793083,14.437146122950555 50.073799567020004,14.437146774240507 50.07377647505558,14.437161000659017 50.07379496839027,14.437148958238538 50.073823157821664,14.437124189538856'
531
+ with gr.Accordion(label="Locations", open=False):
532
+ coords = gr.Textbox(value=example_coords, label="Precise coordinates", show_label=False)
533
  render = gr.Button("Render")
534
 
535
  def on_submit(uploaded_video,model_type,coordinates):
536
+
537
+ global locations
538
  if not coordinates:
539
+ locations = example_coords.split()
540
  else:
541
+ locations = coordinates.split()
542
+ print(locations)
543
+
544
+ avg_coords = [0.0, 0.0]
545
+ for location in locations:
546
+ location = location.split(',')
547
+ avg_coords[0] = avg_coords[0] + location[0]
548
+ avg_coords[1] = avg_coords[1] + location[1]
549
+ avg_coords[0] = avg_coords[0] / len(locations)
550
+ avg_coords[1] = avg_coords[1] / len(locations)
551
+
552
+ for location in locations:
553
+ location[0] = location[0] - avg_coords[0]
554
+ location[1] = location[1] - avg_coords[1]
555
+ print(locations)
556
 
557
  # Process the video and get the path of the output video
558
  output_video_path = make_video(uploaded_video,encoder=model_type)