Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
10 changes: 10 additions & 0 deletions submissions/T-075_Turinators/code/Test Code
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from ultralytics import YOLO

model = YOLO('best _new.pt')

input_image_path = 'test2[1].jpg' # Apni image ka naam yahan likhein

results = model(input_image_path)

print("Prediction is complete.")
results[0].show()
15 changes: 15 additions & 0 deletions submissions/T-075_Turinators/code/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Created by venv; see https://docs.python.org/3/library/venv.html

__pycache__/
*.pyc
venv/
.env/
.venv/
pyvenv.cfg
Scripts
Lib
Include
share
temp_frames
uploads
outputs
49 changes: 49 additions & 0 deletions submissions/T-075_Turinators/code/backend/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Importing flask module in the project is mandatory
# An object of Flask class is our WSGI application.
from flask import Flask, request, jsonify, send_file, Response, send_from_directory
import os
from flask_cors import CORS
import test

# Flask constructor takes the name of
# current module (__name__) as argument.
app = Flask(__name__)
UPLOAD_FOLDER = "uploads"
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
OUTPUT_FOLDER = "outputs"
os.makedirs(OUTPUT_FOLDER, exist_ok=True)
CORS(app)
# The route() function of the Flask class is a decorator,
# which tells the application which URL should call
# the associated function.
@app.route('/')
# ‘/’ URL is bound with hello_world() function.
def hello_world():
return 'Hello World!!'

@app.route('/upload', methods=['POST'])
def upload():
if "video" not in request.files:
return jsonify({"error": "No video uploaded"}), 400

video = request.files["video"]
filename = video.filename
save_path = os.path.join(UPLOAD_FOLDER, filename)
video.save(save_path)
print("Video saved at", save_path)
output_path = test.process_video(filename, "best_new.pt")
return jsonify({"url": f"http://localhost:5000/output/{output_path}"})


@app.route('/output/<filename>')
def serve_output(filename):
print(filename)
return send_file(os.path.join('outputs', filename), as_attachment=True)


# main driver function
if __name__ == '__main__':

# run() method of Flask class runs the application
# on the local development server.
app.run(debug=True)
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions submissions/T-075_Turinators/code/backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ultralytics
numpy
opencv-python
flask
68 changes: 68 additions & 0 deletions submissions/T-075_Turinators/code/backend/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vahan Sarthi</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- Navbar -->
<nav class="navbar">
Vahan Sarthi
</nav>

<!-- Main Container -->
<div class="main-container">
<!-- Sidebar -->
<div class="sidebar">
<div class="sidebar-item">
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.81825 1.18188C7.64251 1.00615 7.35759 1.00615 7.18185 1.18188L4.18185 4.18188C4.00611 4.35762 4.00611 4.64254 4.18185 4.81828C4.35759 4.99401 4.64251 4.99401 4.81825 4.81828L7.05005 2.58648V9.49996C7.05005 9.74849 7.25152 9.94996 7.50005 9.94996C7.74858 9.94996 7.95005 9.74849 7.95005 9.49996V2.58648L10.1819 4.81828C10.3576 4.99401 10.6425 4.99401 10.8182 4.81828C10.994 4.64254 10.994 4.35762 10.8182 4.18188L7.81825 1.18188ZM2.5 9.99997C2.77614 9.99997 3 10.2238 3 10.5V12C3 12.5538 3.44565 13 3.99635 13H11.0012C11.5529 13 12 12.5528 12 12V10.5C12 10.2238 12.2239 9.99997 12.5 9.99997C12.7761 9.99997 13 10.2238 13 10.5V12C13 13.104 12.1062 14 11.0012 14H3.99635C2.89019 14 2 13.103 2 12V10.5C2 10.2238 2.22386 9.99997 2.5 9.99997Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"/>
</svg>
Upload Code
</div>
<div class="sidebar-item">
About Us
</div>
<div class="sidebar-item">
Dataset
</div>
<div class="sidebar-item">
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.49933 0.25C3.49635 0.25 0.25 3.49593 0.25 7.50024C0.25 10.703 2.32715 13.4206 5.2081 14.3797C5.57084 14.446 5.70302 14.2222 5.70302 14.0299C5.70302 13.8576 5.69679 13.4019 5.69323 12.797C3.67661 13.235 3.25112 11.825 3.25112 11.825C2.92132 10.9874 2.44599 10.7644 2.44599 10.7644C1.78773 10.3149 2.49584 10.3238 2.49584 10.3238C3.22353 10.375 3.60629 11.0711 3.60629 11.0711C4.25298 12.1788 5.30335 11.8588 5.71638 11.6732C5.78225 11.205 5.96962 10.8854 6.17658 10.7043C4.56675 10.5209 2.87415 9.89918 2.87415 7.12104C2.87415 6.32925 3.15677 5.68257 3.62053 5.17563C3.54576 4.99226 3.29697 4.25521 3.69174 3.25691C3.69174 3.25691 4.30015 3.06196 5.68522 3.99973C6.26337 3.83906 6.8838 3.75895 7.50022 3.75583C8.1162 3.75895 8.73619 3.83906 9.31523 3.99973C10.6994 3.06196 11.3069 3.25691 11.3069 3.25691C11.7026 4.25521 11.4538 4.99226 11.3795 5.17563C11.8441 5.68257 12.1245 6.32925 12.1245 7.12104C12.1245 9.9063 10.4292 10.5192 8.81452 10.6985C9.07444 10.9224 9.30633 11.3648 9.30633 12.0413C9.30633 13.0102 9.29742 13.7922 9.29742 14.0299C9.29742 14.2239 9.42828 14.4496 9.79591 14.3788C12.6746 13.4179 14.75 10.7025 14.75 7.50024C14.75 3.49593 11.5036 0.25 7.49933 0.25Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"/>
</svg>
</div>
</div>

<!-- App Content -->
<div class="app-content">
<!-- Toast Container -->
<div id="toast-container"></div>

<!-- Upload Section -->
<div class="upload-section">
<div id="loading-section" style="display: none;">
<p>Loading...</p>
</div>
<div id="upload-content">
<svg width="75" height="75" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.81825 1.18188C7.64251 1.00615 7.35759 1.00615 7.18185 1.18188L4.18185 4.18188C4.00611 4.35762 4.00611 4.64254 4.18185 4.81828C4.35759 4.99401 4.64251 4.99401 4.81825 4.81828L7.05005 2.58648V9.49996C7.05005 9.74849 7.25152 9.94996 7.50005 9.94996C7.74858 9.94996 7.95005 9.74849 7.95005 9.49996V2.58648L10.1819 4.81828C10.3576 4.99401 10.6425 4.99401 10.8182 4.81828C10.994 4.64254 10.994 4.35762 10.8182 4.18188L7.81825 1.18188ZM2.5 9.99997C2.77614 9.99997 3 10.2238 3 10.5V12C3 12.5538 3.44565 13 3.99635 13H11.0012C11.5529 13 12 12.5528 12 12V10.5C12 10.2238 12.2239 9.99997 12.5 9.99997C12.7761 9.99997 13 10.2238 13 10.5V12C13 13.104 12.1062 14 11.0012 14H3.99635C2.89019 14 2 13.103 2 12V10.5C2 10.2238 2.22386 9.99997 2.5 9.99997Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"/>
</svg>
<input type="file" id="video-input" accept="video/*">
<button id="upload-btn" class="upload-button">Upload</button>
</div>
</div>

<!-- Output Video Section -->
<div id="output-section" class="output-section" style="display: none;">
<video id="output-video" width="420" height="240" controls preload="metadata">
<source id="video-source" type="video/mp4">
</video>
</div>
</div>
</div>

<script src="script.js"></script>
</body>
</html>
83 changes: 83 additions & 0 deletions submissions/T-075_Turinators/code/backend/templates/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// State management
let selectedFile = null;
let loading = false;

// DOM elements
const videoInput = document.getElementById('video-input');
const uploadBtn = document.getElementById('upload-btn');
const uploadContent = document.getElementById('upload-content');
const loadingSection = document.getElementById('loading-section');
const outputSection = document.getElementById('output-section');
const outputVideo = document.getElementById('output-video');
const videoSource = document.getElementById('video-source');
const toastContainer = document.getElementById('toast-container');

// Event listeners
videoInput.addEventListener('change', (e) => {
selectedFile = e.target.files[0] || null;
});

uploadBtn.addEventListener('click', handleUpload);

// Toast function
function showToast(message, duration = 3000) {
const toast = document.createElement('div');
toast.className = 'toast';
toast.textContent = message;

toastContainer.appendChild(toast);

setTimeout(() => {
toast.classList.add('fade-out');
setTimeout(() => {
toastContainer.removeChild(toast);
}, 300);
}, duration);
}

// Handle file upload
async function handleUpload() {
if (!selectedFile) {
showToast('Please select a file');
return;
}

setLoading(true);

const formData = new FormData();
formData.append('video', selectedFile);

try {
const response = await fetch('http://localhost:5000/upload', {
method: 'POST',
body: formData
});

const data = await response.json();
console.log(data);

// Display output video
videoSource.src = data.url;
outputVideo.load();
outputSection.style.display = 'block';

showToast('Upload successful!');
} catch (error) {
console.error('Upload error:', error);
showToast('Upload failed. Please try again.');
} finally {
setLoading(false);
}
}

// Toggle loading state
function setLoading(isLoading) {
loading = isLoading;
if (isLoading) {
uploadContent.style.display = 'none';
loadingSection.style.display = 'block';
} else {
uploadContent.style.display = 'flex';
loadingSection.style.display = 'none';
}
}
Loading