not save to local
Browse files- app.py +19 -4
- templates/tagger.html +7 -3
app.py
CHANGED
|
@@ -3,15 +3,15 @@ import shutil
|
|
| 3 |
import uuid
|
| 4 |
import logging
|
| 5 |
|
| 6 |
-
from flask import Flask, redirect, url_for, request, flash, session
|
| 7 |
from flask import render_template
|
| 8 |
from flask import send_file
|
| 9 |
|
| 10 |
logger = logging.getLogger(__name__)
|
| 11 |
logging.basicConfig(level=logging.INFO)
|
| 12 |
|
| 13 |
-
UPLOAD_FOLDER = '/
|
| 14 |
-
OUT_FOLDER = '/
|
| 15 |
|
| 16 |
app = Flask(__name__)
|
| 17 |
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
|
|
@@ -142,10 +142,25 @@ def download():
|
|
| 142 |
anno_path = get_anno_path(user_id)
|
| 143 |
img_dir = get_images_directory(user_id)
|
| 144 |
shutil.copyfile(anno_path, f'{img_dir}/annotations_pascal_voc.csv')
|
|
|
|
|
|
|
| 145 |
shutil.make_archive('final', 'zip', img_dir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
return send_file('final.zip',
|
| 147 |
mimetype='text/csv',
|
| 148 |
-
download_name='
|
| 149 |
as_attachment=True)
|
| 150 |
|
| 151 |
if __name__ == "__main__":
|
|
|
|
| 3 |
import uuid
|
| 4 |
import logging
|
| 5 |
|
| 6 |
+
from flask import Flask, redirect, url_for, request, flash, session, after_this_request
|
| 7 |
from flask import render_template
|
| 8 |
from flask import send_file
|
| 9 |
|
| 10 |
logger = logging.getLogger(__name__)
|
| 11 |
logging.basicConfig(level=logging.INFO)
|
| 12 |
|
| 13 |
+
UPLOAD_FOLDER = './images'
|
| 14 |
+
OUT_FOLDER = './anno'
|
| 15 |
|
| 16 |
app = Flask(__name__)
|
| 17 |
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
|
|
|
|
| 142 |
anno_path = get_anno_path(user_id)
|
| 143 |
img_dir = get_images_directory(user_id)
|
| 144 |
shutil.copyfile(anno_path, f'{img_dir}/annotations_pascal_voc.csv')
|
| 145 |
+
download_zip = os.path.join(img_dir, 'final')
|
| 146 |
+
print(download_zip)
|
| 147 |
shutil.make_archive('final', 'zip', img_dir)
|
| 148 |
+
# shutil.make_archive(base_name=download_zip,
|
| 149 |
+
# format='zip',
|
| 150 |
+
# base_dir=img_dir)
|
| 151 |
+
|
| 152 |
+
@after_this_request
|
| 153 |
+
def remove_directory(response):
|
| 154 |
+
try:
|
| 155 |
+
shutil.rmtree(img_dir)
|
| 156 |
+
os.remove(anno_path)
|
| 157 |
+
except Exception as e:
|
| 158 |
+
print(f"Error deleting directory {img_dir}: {e}")
|
| 159 |
+
return response
|
| 160 |
+
|
| 161 |
return send_file('final.zip',
|
| 162 |
mimetype='text/csv',
|
| 163 |
+
download_name='annotated_data.zip',
|
| 164 |
as_attachment=True)
|
| 165 |
|
| 166 |
if __name__ == "__main__":
|
templates/tagger.html
CHANGED
|
@@ -59,9 +59,13 @@
|
|
| 59 |
<h1 class="text-3xl sm:text-4xl font-bold text-gray-800 leading-tight">
|
| 60 |
🇰🇭 For the development of AI 🇰🇭
|
| 61 |
</h1>
|
| 62 |
-
<h3>One annotation takes 2 steps:
|
| 63 |
-
<
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
</div>
|
| 66 |
|
| 67 |
<!-- Right Section: Placeholder (can be used for user avatar/menu later) -->
|
|
|
|
| 59 |
<h1 class="text-3xl sm:text-4xl font-bold text-gray-800 leading-tight">
|
| 60 |
🇰🇭 For the development of AI 🇰🇭
|
| 61 |
</h1>
|
| 62 |
+
<h3>One annotation takes 2 steps:</h3>
|
| 63 |
+
<div class="mb-4">
|
| 64 |
+
<h4>1. Create bounding box by click and drag on the image,</h4>
|
| 65 |
+
<h4>2. Enter label for the bounding box</h4>
|
| 66 |
+
</div>
|
| 67 |
+
<h4>Move to the next image by clicking on ➡️ or ✅ at the right</h4>
|
| 68 |
+
<h5>Loading images may take a few seconds. Please wait...</h5>
|
| 69 |
</div>
|
| 70 |
|
| 71 |
<!-- Right Section: Placeholder (can be used for user avatar/menu later) -->
|