diff --git a/app_test.py b/app_test.py new file mode 100644 index 0000000..80af21c --- /dev/null +++ b/app_test.py @@ -0,0 +1,23 @@ +import gradio as gr + +def update_iframe(slider_value): + return f''' + + + ''' + +iface = gr.Interface( + fn=update_iframe, + inputs=gr.inputs.Slider(minimum=0, maximum=100, step=1, default=50), + outputs=gr.outputs.HTML(), + allow_flagging=False, +) + +iface.launch(server_name='0.0.0.0', server_port=12212) diff --git a/template.html b/template.html new file mode 100644 index 0000000..c476716 --- /dev/null +++ b/template.html @@ -0,0 +1,27 @@ + + + + + + + Gradio Video Pause Time + + + + + + diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..3348583 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,50 @@ + + + + + + + Video Object Segmentation + + + +

Video Object Segmentation

+ + + +
+ + +
+ + +
+ Download Video + + + + + diff --git a/text_server.py b/text_server.py new file mode 100644 index 0000000..a0623a3 --- /dev/null +++ b/text_server.py @@ -0,0 +1,72 @@ +import os +import sys +import cv2 +import time +import json +import queue +import numpy as np +import requests +import concurrent.futures +from PIL import Image +from flask import Flask, render_template, request, jsonify, send_file +import torchvision +import torch + +from demo import automask_image_app, automask_video_app, sahi_autoseg_app +sys.path.append(sys.path[0] + "/tracker") +sys.path.append(sys.path[0] + "/tracker/model") +from track_anything import TrackingAnything +from track_anything import parse_augment + +# ... (all the functions defined in the original code except the Gradio part) + +app = Flask(__name__) +app.config['UPLOAD_FOLDER'] = './uploaded_videos' +app.config['ALLOWED_EXTENSIONS'] = {'mp4', 'avi', 'mov', 'mkv'} + + +def allowed_file(filename): + return '.' in filename and filename.rsplit('.', 1)[1].lower() in app.config['ALLOWED_EXTENSIONS'] + +@app.route("/") +def index(): + return render_template("index.html") + +@app.route("/upload_video", methods=["POST"]) +def upload_video(): + # ... (handle video upload and processing) + return jsonify(status="success", data=video_data) + +@app.route("/template_select", methods=["POST"]) +def template_select(): + # ... (handle template selection and processing) + return jsonify(status="success", data=template_data) + +@app.route("/sam_refine", methods=["POST"]) +def sam_refine_request(): + # ... (handle sam refine and processing) + return jsonify(status="success", data=sam_data) + +@app.route("/track_video", methods=["POST"]) +def track_video(): + # ... (handle video tracking and processing) + return jsonify(status="success", data=tracking_data) + +@app.route("/track_image", methods=["POST"]) +def track_image(): + # ... (handle image tracking and processing) + return jsonify(status="success", data=tracking_data) + +@app.route("/download_video", methods=["GET"]) +def download_video(): + try: + return send_file("output.mp4", attachment_filename="output.mp4") + except Exception as e: + return str(e) + +if __name__ == "__main__": + app.run(debug=True, host="0.0.0.0", port=args.port) + + +if __name__ == '__main__': + app.run(host="0.0.0.0",port=12212, debug=True)