from flask import Flask, render_template, request, send_from_directory import os from model_loader import get_model from utils import process_video app = Flask(__name__) UPLOAD_FOLDER = 'static/uploads' RESULT_FOLDER = 'static/results' os.makedirs(UPLOAD_FOLDER, exist_ok=True) os.makedirs(RESULT_FOLDER, exist_ok=True) num_classes = 21 model, device = get_model(num_classes) @app.route('/', methods=['GET', 'POST']) def index(): if request.method == 'POST': file = request.files['video'] if file: filepath = os.path.join(UPLOAD_FOLDER, file.filename) file.save(filepath) output_path = os.path.join(RESULT_FOLDER, 'result_' + file.filename) result_path = process_video(filepath, model, output_path, device) return render_template('index.html', video_result=result_path) return render_template('index.html', video_result=None) @app.route('/static/') def send_static(path): return send_from_directory('static', path) if __name__ == '__main__': app.run(debug=True)