Spaces:
Runtime error
Runtime error
kshipra-jadav commited on
Commit ·
9f60c09
1
Parent(s): 99a26f4
add total faces counter
Browse files- app.py +2 -2
- templates/pg1.html +1 -0
app.py
CHANGED
|
@@ -73,12 +73,12 @@ def detect_faces():
|
|
| 73 |
for (x, y, w, h) in unique_detected_faces:
|
| 74 |
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 3)
|
| 75 |
|
| 76 |
-
img = cv2.putText(img, f"{len(unique_detected_faces)} Faces", (100, 300), cv2.FONT_HERSHEY_SIMPLEX, 6, (0, 0, 0), 10)
|
| 77 |
|
| 78 |
_, buffer = cv2.imencode(".jpg", cv2.resize(img, (0, 0), fx=0.5, fy=0.5))
|
| 79 |
b64 = base64.b64encode(buffer)
|
| 80 |
|
| 81 |
-
return render_template("pg1.html", img_data = b64.decode('utf-8'))
|
| 82 |
|
| 83 |
if __name__ == '__main__':
|
| 84 |
app.run(debug=False)
|
|
|
|
| 73 |
for (x, y, w, h) in unique_detected_faces:
|
| 74 |
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 3)
|
| 75 |
|
| 76 |
+
# img = cv2.putText(img, f"{len(unique_detected_faces)} Faces", (100, 300), cv2.FONT_HERSHEY_SIMPLEX, 6, (0, 0, 0), 10)
|
| 77 |
|
| 78 |
_, buffer = cv2.imencode(".jpg", cv2.resize(img, (0, 0), fx=0.5, fy=0.5))
|
| 79 |
b64 = base64.b64encode(buffer)
|
| 80 |
|
| 81 |
+
return render_template("pg1.html", img_data = b64.decode('utf-8'), faces=len(unique_detected_faces))
|
| 82 |
|
| 83 |
if __name__ == '__main__':
|
| 84 |
app.run(debug=False)
|
templates/pg1.html
CHANGED
|
@@ -227,6 +227,7 @@
|
|
| 227 |
</form>
|
| 228 |
<div id="imagePreviewContainer">
|
| 229 |
{% if img_data: %}
|
|
|
|
| 230 |
<h2>Image Preview</h2>
|
| 231 |
<div>
|
| 232 |
<img id="imagePreview" src="data:image/jpeg;base64,{{ img_data }}" width="800" height="600">
|
|
|
|
| 227 |
</form>
|
| 228 |
<div id="imagePreviewContainer">
|
| 229 |
{% if img_data: %}
|
| 230 |
+
<h3>Total Faces {{faces}}</h3>
|
| 231 |
<h2>Image Preview</h2>
|
| 232 |
<div>
|
| 233 |
<img id="imagePreview" src="data:image/jpeg;base64,{{ img_data }}" width="800" height="600">
|