How to input images and have them count only
Opened this issue · 4 comments
I was able to successfully run the test case using train_val.py, but when I wanted to test the effect of this code on the general image case, I couldn't figure out how to get the count results by inputting only the query image we had prepared and the cropped support image.
Do I have to prepare a json file with the boxes and points information?
If anyone is reading this, I would like to know.
I write this description with DeepL , so sorry for some discomfort.
Hello, thanks for your question.
Our codes have two settings.
- The support images are in the query image.
- The support images are not in the query image.
I think you are in the second case.
In this case, you need to:
-
First, pre-train the model in FSC-147. Please directly run this shell https://github.com/zhiyuanyou/SAFECount/blob/main/experiments/FSC147_to_CARPK/pretrain/pretrain_torch.sh.
-
Second, organize your support images as
exemplar.json
. Please refer to https://github.com/zhiyuanyou/SAFECount/blob/main/data/CARPK_devkit/exemplar.json and organize your own json file. -
Then, with the pre-trained weights and
exemplar.json
, you need to set theexemplar.json
in your own config file (Please refer to https://github.com/zhiyuanyou/SAFECount/blob/main/experiments/CARPK/config.yaml) and run eval shell (The same as https://github.com/zhiyuanyou/SAFECount/blob/main/experiments/CARPK/eval_torch.sh).
Feel free to let me know if you have further questions.
Just to clarify:
I have arbitrary templates (small images as patches) and I want to count similar ones (object detection with bounding boxes) in a very large image. Is SAFECount
suitable for this kind of out-of-the-box template-matching and few-shot object detection WITHOUT training? Do we need to train for each object category for this to work?
@zhiyuanyou , Thank you very much for your detailed advice. I will try it out based on your suggestions.
@ogencoglu
As stated in the paper, SAFECount is not class-specific, so individual training for each object class is not considered necessary. Sorry if I'm wrong.
Just to clarify:
I have arbitrary templates (small images as patches) and I want to count similar ones (object detection with bounding boxes) in a very large image. Is
SAFECount
suitable for this kind of out-of-the-box template-matching and few-shot object detection WITHOUT training? Do we need to train for each object category for this to work?
SAFECount does not need re-training to count. But it does need pre-training.
Please see Sec. 1.3 in README for pre-training and evaluation on other datasets.
The pre-training scripts is https://github.com/zhiyuanyou/SAFECount/blob/main/experiments/FSC147_to_CARPK/pretrain/pretrain_torch.sh.
Here the pre-trained weights are not provided. You need to pre-train the model on FSC-147, then evaluate it on downstream counting tasks.