HYeungLee commited on
Commit
72e9674
·
1 Parent(s): 7d23005

use iframe

Browse files
Files changed (3) hide show
  1. app.py +6 -123
  2. requirements.txt +1 -0
  3. templates/index.html +33 -0
app.py CHANGED
@@ -1,129 +1,12 @@
1
- # import argparse
2
- # import gradio as gr
3
- # import cv2
4
- # import os
5
- # import numpy as np
6
- # from gradio_image_prompter import ImagePrompter
7
 
 
8
 
9
- # def video_to_interaction(input_video, frame_selector):
10
- # """
11
- # 1. get the frame from input_video.
12
- # 2. get the interaction from the frame.
13
- # 3. return the interaction.
14
- # Args:
15
- # input_video (_type_): _description_
16
- # frame_selector (_type_): _description_
17
- # interaction (_type_): _description_
18
- # """
19
- # frames = cv2.VideoCapture(input_video)
20
- # interaction = None
21
- # # fps = int(frames.get(cv2.CAP_PROP_FPS))
22
- # frame_id = 0
23
- # if not frames.isOpened():
24
- # gr.Info("Error opening video file")
25
- # else:
26
- # while frames.isOpened():
27
- # ret, frame = frames.read()
28
- # print(frame_id, frame_selector)
29
- # if frame_id == frame_selector:
30
- # interaction = np.array(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
31
- # break
32
- # frame_id += 1
33
- # frames.release()
34
- # if interaction is None:
35
- # gr.Info("Frame not found")
36
- # raise ValueError("Frame not found")
37
- # return {"image": interaction, "points": []}
38
 
 
 
 
39
 
40
- # # VideoEditingDemoUrl = "xxx"
41
- # # ### Point Trajectory Demo [[VideoEditing Demo]]({VideoEditingDemoUrl})
42
- # ProjectPage = "https://taptr.github.io"
43
- # CodeUrl = "https://taptr.github.io"
44
- # PaperUrlV1 = "https://arxiv.org/abs/2403.13042"
45
- # PaperUrlV2 = "https://arxiv.org/abs/2407.16291"
46
- # PaperUrlV3 = "https://arxiv.org/abs/2411.18671"
47
- # with gr.Blocks(title="TAPTRv3") as demo:
48
- # title_markdown = (f"""
49
- # # TAPTRv3: Spatial and Temporal Context Foster Robust Tracking of Any Point in Long Video
50
- # ## TAPTR: Track Any Point TRansformer
51
- # [[TAPTR-Series Project Page]]({ProjectPage}) [[TAPTR-Series Repository]]({CodeUrl}) [[Paper-TAPTRv1]]({PaperUrlV1}) [[Paper-TAPTRv2]]({PaperUrlV2}) [[Paper-TAPTRv3]]({PaperUrlV3})
52
- # """)
53
- # tips = (f"""
54
- # **Usage** \\
55
- # 1. Upload a video in Input Video module. \\
56
- # 2. Select a frame in Frame Selector module, the corresponding frame will be shown in Interaction module. (The first frame is selected by default.) \\
57
- # 3. Click on the Interaction module to specify the points to be tracked. \\
58
- # 4. Click on Submit button to start tracking the points. \\
59
- # 5. The output video will be shown in Output Video module. \\
60
- # More details, please refer to the example video. \\
61
- # **Note** \\
62
- # 1. TAPTR has broad application scenarios, such as slam, AR, motion capture, and video editing. If you have any collaboration intentions, please contact us. \\
63
- # 2. Limited by the hardware our demo running on, a video that is too long may result in the long machine occupation, so we reject the video longer than 600 frames. \\
64
- # 3. If you have any questions feel free to contact us or open an issue in our [repo]({CodeUrl}).
65
- # """)
66
- # gr.Markdown(title_markdown)
67
- # with gr.Row():
68
- # with gr.Column(scale=0.5):
69
- # input_video = gr.Video(label="Input Video", height=300)
70
- # use_globalmatching = gr.Checkbox(label="Automatically Trigger Global Matching to Reestablish Tracking.", value=False)
71
- # user_specified_retrack = gr.Textbox(label="Manually Specify Frames for Global Matching to Reestablish Tracking.", placeholder="[ ]")
72
- # frame_selector = gr.Slider(minimum=0, maximum=20, value=0, label="Frame Selector")
73
- # submit_btn = gr.Button("Submit")
74
- # if os.path.exists("./assets/example_videos/Box.mp4"):
75
- # with gr.Row():
76
- # gr.Examples(examples=[
77
- # [f"./assets/example_videos/Box.mp4"],
78
- # ], inputs=[input_video], label="Example-Box")
79
- # gr.Examples(examples=[
80
- # [f"./assets/example_videos/Sofa.mp4"],
81
- # ], inputs=[input_video], label="Example-Sofa")
82
- # gr.Examples(examples=[
83
- # [f"./assets/example_videos/RabbitAndYogurt.mp4"],
84
- # ], inputs=[input_video], label="Example-RabbitAndYogurt")
85
- # gr.Examples(examples=[
86
- # [f"./assets/example_videos/RollingBasketball.mp4"],
87
- # ], inputs=[input_video], label="Example-RollingBasketball")
88
- # gr.Examples(examples=[
89
- # [f"./assets/example_videos/Goldfish.mp4"],
90
- # ], inputs=[input_video], label="Example-Goldfish")
91
- # gr.Examples(examples=[
92
- # [f"./assets/example_videos/Jellyfish.mp4"],
93
- # ], inputs=[input_video], label="Example-Jellyfish")
94
- # gr.Examples(examples=[
95
- # [f"./assets/example_videos/HandOcclusion.mp4"],
96
- # ], inputs=[input_video], label="Example-HandOcclusion")
97
- # gr.Examples(examples=[
98
- # [f"./assets/example_videos/PaperOcclusion.mp4"],
99
- # ], inputs=[input_video], label="Example-PaperOcclusion")
100
- # if os.path.exists("./assets/PointTracking.mp4"):
101
- # usage_video = gr.Video(label="Usage", height=250, value="./assets/PointTracking.mp4")
102
- # gr.Markdown(tips)
103
- # with gr.Column():
104
- # interaction = ImagePrompter(label="Interaction", interactive=True, height=650)
105
- # output_video = gr.Video(label="Output Video", height=650)
106
- # input_video.change(fn=video_to_interaction, inputs=[input_video, frame_selector], outputs=[interaction])
107
- # frame_selector.change(fn=video_to_interaction, inputs=[input_video, frame_selector], outputs=[interaction])
108
- # submit_btn.click(fn=process_one_video, inputs=[input_video, frame_selector, interaction, use_globalmatching, user_specified_retrack], outputs=[output_video])
109
- # demo.queue()
110
 
111
-
112
- # if __name__ == "__main__":
113
- # global DemoCore
114
- # args = get_args()
115
- # DemoCore = Demo(args)
116
- # demo.launch(server_name="0.0.0.0", server_port=10006)
117
-
118
-
119
- import gradio as gr
120
-
121
- # 本地服务的公网 URL
122
- LOCAL_DEMO_URL = "taptr.deepdataspace.com"
123
-
124
- # 加载本地 Demo
125
- demo = gr.Blocks.load(LOCAL_DEMO_URL)
126
-
127
- # 启动 Hugging Face 的 Gradio 界面
128
  if __name__ == "__main__":
129
- demo.launch()
 
1
+ from flask import Flask, render_template
 
 
 
 
 
2
 
3
+ app = Flask(__name__)
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ @app.route("/")
7
+ def index():
8
+ return render_template("index.html")
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  if __name__ == "__main__":
12
+ app.run()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ flask
templates/index.html ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width" />
7
+ <title>My static Space</title>
8
+ <style>
9
+ body {
10
+ margin: 0;
11
+ }
12
+ .space {
13
+ max-width: 100%;
14
+ max-height: 100%;
15
+ width: 100vw;
16
+ height: 100vh;
17
+ overflow: hidden;
18
+ }
19
+ .iframe {
20
+ min-width: 100%;
21
+ min-height: 100%;
22
+ }
23
+ </style>
24
+ </head>
25
+
26
+ <body>
27
+ <div class="space">
28
+ <iframe class="iframe" allowfullscreen="true" frameborder="0" src="https://taptr.deepdataspace.com">
29
+ </iframe>
30
+ </div>
31
+ </body>
32
+
33
+ </html>