Update app.py
Browse files
app.py
CHANGED
|
@@ -29,45 +29,89 @@ def index():
|
|
| 29 |
<!DOCTYPE html>
|
| 30 |
<html>
|
| 31 |
<head>
|
| 32 |
-
<title>Gesture Detection
|
| 33 |
<style>
|
| 34 |
-
body {
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
</style>
|
| 37 |
</head>
|
| 38 |
<body>
|
| 39 |
<h1>Gesture Detection</h1>
|
|
|
|
| 40 |
<form id="upload-form">
|
|
|
|
| 41 |
<input type="file" id="image" name="image" accept="image/*" required />
|
| 42 |
<button type="submit">Detect Gesture</button>
|
| 43 |
</form>
|
| 44 |
|
| 45 |
<div class="result" id="result"></div>
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
<script>
|
| 48 |
const form = document.getElementById("upload-form");
|
| 49 |
const resultDiv = document.getElementById("result");
|
| 50 |
-
|
| 51 |
form.addEventListener("submit", async (e) => {
|
| 52 |
e.preventDefault();
|
| 53 |
const imageInput = document.getElementById("image");
|
| 54 |
const file = imageInput.files[0];
|
| 55 |
-
|
| 56 |
const formData = new FormData();
|
| 57 |
formData.append("image", file);
|
| 58 |
-
|
| 59 |
resultDiv.innerHTML = "Processing...";
|
| 60 |
-
|
| 61 |
const response = await fetch("/detect", {
|
| 62 |
method: "POST",
|
| 63 |
body: formData
|
| 64 |
});
|
| 65 |
-
|
| 66 |
if (!response.ok) {
|
| 67 |
resultDiv.innerHTML = "Error detecting gesture.";
|
| 68 |
return;
|
| 69 |
}
|
| 70 |
-
|
| 71 |
const data = await response.json();
|
| 72 |
resultDiv.innerHTML = `
|
| 73 |
<p><strong>Total Detections:</strong> ${data.total_detections}</p>
|
|
|
|
| 29 |
<!DOCTYPE html>
|
| 30 |
<html>
|
| 31 |
<head>
|
| 32 |
+
<title>Gesture Detection</title>
|
| 33 |
<style>
|
| 34 |
+
body {
|
| 35 |
+
font-family: Arial, sans-serif;
|
| 36 |
+
background-color: #f4f4f4;
|
| 37 |
+
padding: 40px;
|
| 38 |
+
max-width: 700px;
|
| 39 |
+
margin: auto;
|
| 40 |
+
}
|
| 41 |
+
h1 {
|
| 42 |
+
text-align: center;
|
| 43 |
+
color: #333;
|
| 44 |
+
}
|
| 45 |
+
form, .nav-buttons {
|
| 46 |
+
background-color: white;
|
| 47 |
+
padding: 20px;
|
| 48 |
+
border-radius: 10px;
|
| 49 |
+
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
| 50 |
+
margin-bottom: 20px;
|
| 51 |
+
}
|
| 52 |
+
input[type="file"] {
|
| 53 |
+
display: block;
|
| 54 |
+
margin-bottom: 10px;
|
| 55 |
+
}
|
| 56 |
+
button {
|
| 57 |
+
padding: 10px 20px;
|
| 58 |
+
font-size: 16px;
|
| 59 |
+
background-color: #007BFF;
|
| 60 |
+
color: white;
|
| 61 |
+
border: none;
|
| 62 |
+
border-radius: 5px;
|
| 63 |
+
cursor: pointer;
|
| 64 |
+
}
|
| 65 |
+
button:hover {
|
| 66 |
+
background-color: #0056b3;
|
| 67 |
+
}
|
| 68 |
+
.result img {
|
| 69 |
+
max-width: 100%;
|
| 70 |
+
margin-top: 10px;
|
| 71 |
+
}
|
| 72 |
+
.nav-buttons {
|
| 73 |
+
text-align: center;
|
| 74 |
+
}
|
| 75 |
+
.nav-buttons a {
|
| 76 |
+
text-decoration: none;
|
| 77 |
+
margin: 0 10px;
|
| 78 |
+
}
|
| 79 |
</style>
|
| 80 |
</head>
|
| 81 |
<body>
|
| 82 |
<h1>Gesture Detection</h1>
|
| 83 |
+
|
| 84 |
<form id="upload-form">
|
| 85 |
+
<label for="image">Upload image for detection:</label>
|
| 86 |
<input type="file" id="image" name="image" accept="image/*" required />
|
| 87 |
<button type="submit">Detect Gesture</button>
|
| 88 |
</form>
|
| 89 |
|
| 90 |
<div class="result" id="result"></div>
|
| 91 |
|
| 92 |
+
<div class="nav-buttons">
|
| 93 |
+
<p>Or try real-time detection:</p>
|
| 94 |
+
<a href="/webcam"><button>Open Webcam Detection</button></a>
|
| 95 |
+
</div>
|
| 96 |
+
|
| 97 |
<script>
|
| 98 |
const form = document.getElementById("upload-form");
|
| 99 |
const resultDiv = document.getElementById("result");
|
|
|
|
| 100 |
form.addEventListener("submit", async (e) => {
|
| 101 |
e.preventDefault();
|
| 102 |
const imageInput = document.getElementById("image");
|
| 103 |
const file = imageInput.files[0];
|
|
|
|
| 104 |
const formData = new FormData();
|
| 105 |
formData.append("image", file);
|
|
|
|
| 106 |
resultDiv.innerHTML = "Processing...";
|
|
|
|
| 107 |
const response = await fetch("/detect", {
|
| 108 |
method: "POST",
|
| 109 |
body: formData
|
| 110 |
});
|
|
|
|
| 111 |
if (!response.ok) {
|
| 112 |
resultDiv.innerHTML = "Error detecting gesture.";
|
| 113 |
return;
|
| 114 |
}
|
|
|
|
| 115 |
const data = await response.json();
|
| 116 |
resultDiv.innerHTML = `
|
| 117 |
<p><strong>Total Detections:</strong> ${data.total_detections}</p>
|