Download Objectdetection/objectdetection.py from Goutham204/Object_detection: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/Goutham204/Object_detection/resolve/c20cd657ed6454ff69ee811cfeccee00a6e07b6e/Objectdetection/objectdetection.py
- Command line
-
hf download hf://Goutham204/Object_detection@c20cd657ed6454ff69ee811cfeccee00a6e07b6e/Objectdetection/objectdetection.py
-
curl -L -o objectdetection.py https://huggingface.co/Goutham204/Object_detection/resolve/c20cd657ed6454ff69ee811cfeccee00a6e07b6e/Objectdetection/objectdetection.py
1.11 kB
| 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) | |
| 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) | |
| def send_static(path): | |
| return send_from_directory('static', path) | |
| if __name__ == '__main__': | |
| app.run(debug=True) | |