Open TakuyaYashima opened 1 year ago
Here's one way for that.
Run the cells until where you download the pretrained weight.
Instead of uploading one single image, make directories for input and output images first.
!mkdir inputs && mkdir outputs
Upload images of interest via Colaboratory UI or use files.upload()
for multiple times and save them in inputs
.
Import some packages.
import os
import shutil
import subprocess
Run the script below.
for i, image in enumerate(os.listdir("inputs")):
if os.path.splitext(image)[1] not in ('.jpg', '.jpeg', '.png', '.webp'):
continue
cmd = ["python", "src/demo.py", "ctdet",
"--dataset", dataset,
"--arch", architecture,
"--num_layers", str(num_layer),
"--trained_model_path", param_path,
"--demo", "inputs/" + image,
"--gpus", "0",
"--debug", "1",
"--save_dir", "outputs"]
_ = subprocess.run(cmd)
shutil.move("outputs/ctdet.jpg",
f"outputs/{os.path.splitext(image)[0]}.jpg")
You should find the images with anchor boxes in outputs
. You can download them by Colaboratory UI.
Also I found that currently the Colab demo does not work as is.
--checkpoint
is obsolete and that must be changed to --trained_model_path
probably due to this commit.
We got a question in CenterNet Colab demo tutorial in Youtube.