Skip to content

Commit

Permalink
[FIX] Fix the visualise function
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCretois committed Jul 4, 2023
1 parent 2fa0e10 commit 6568cd4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ RUN git clone https://github.com/ultralytics/yolov5.git && \

RUN git clone https://github.com/microsoft/CameraTraps.git && \
cd /app/CameraTraps && \
git checkout b357366183c72c76eb9c4cd84166c3c9b2f84af5
git checkout a1e7c154b43f0982d2f41ffa9359daac666557fb

# Clone the repo that converts the .json file into an sqlite database
RUN git clone https://github.com/NINAnor/md_json2sqlite
Expand Down
9 changes: 5 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ def dl_db(n_clicks):
Input('download-pics-button', 'n_clicks')
)
def dl_bbox_pics(n_clicks):
if n_clicks==1:
if n_clicks>=1:
visualise_bbox("list_of_detections.json", BBOX_FOLDER, UPLOAD_FOLDER)
shutil.make_archive('processed_pics.zip', 'zip', BBOX_FOLDER)
if os.path.exists('processed_pics.zip'):
return dcc.send_file('processed_pics.zip')
zip_filename = shutil.make_archive('processed_pics', 'zip', BBOX_FOLDER) # Note that I removed the '.zip' extension here, as make_archive adds it itself

if os.path.exists(zip_filename):
return dcc.send_file(zip_filename)
else:
return "No pictures have been processed"

Expand Down
11 changes: 4 additions & 7 deletions apputils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ def to_sqlite(input_json, output_db):
main(input_json, output_db, False)

def visualise_bbox(detection_json, outfolder, infolder):
import subprocess
subprocess.run(["python",
"/app/CameraTraps/visualization/visualize_detector_output.py",
detection_json,
outfolder,
"-c", "0.8",
"-i", infolder])
os.system(f"python /app/CameraTraps/visualization/visualize_detector_output.py \
{detection_json} \
{outfolder} \
-i {infolder}")

0 comments on commit 6568cd4

Please sign in to comment.