martinzlocha / anchor-optimization Goto Github PK
View Code? Open in Web Editor NEWAnchor optimization for RetinaNet.
License: GNU General Public License v3.0
Anchor optimization for RetinaNet.
License: GNU General Public License v3.0
python optimize_anchors.py annotations.csv --no-resize --include-stride --seed=1
fails with error:
Traceback (most recent call last):
File "optimize_anchors.py", line 10, in <module>
from compute_overlap import compute_overlap
File "__init__.pxd", line 872, in init compute_overlap
ValueError: numpy.ufunc has the wrong size, try recompiling. Expected 192, got 216
What's happening? My environment: a Docker container with
Ubuntu 18.04.3 LTS
Python 3.6.8
pip -list
output:
Package Version
---------------------- ---------
absl-py 0.8.0
anchor-optimization 0.0.1
astor 0.8.0
attrs 19.1.0
audioread 2.1.8
backcall 0.1.0
bleach 3.1.0
cloudpickle 1.2.2
cupy 6.3.0
cycler 0.10.0
Cython 0.29.13
decorator 4.4.0
defusedxml 0.6.0
entrypoints 0.3
fastrlock 0.4
future 0.17.1
gast 0.2.2
google-pasta 0.1.7
graphsurgeon 0.4.1
grpcio 1.23.0
h5py 2.9.0
horovod 0.18.0
ipykernel 5.1.2
ipython 7.8.0
ipython-genutils 0.2.0
jedi 0.15.1
Jinja2 2.10.1
joblib 0.13.2
json5 0.8.5
jsonschema 3.0.2
jupyter-client 5.3.1
jupyter-core 4.5.0
jupyter-tensorboard 0.1.10
jupyterlab 1.0.2
jupyterlab-server 1.0.0
jupytext 1.2.3
Keras 2.3.1
Keras-Applications 1.0.6
Keras-Preprocessing 1.0.5
keras-resnet 0.1.0
keras-retinanet 0.5.1
kiwisolver 1.1.0
librosa 0.6.3
llvmlite 0.29.0
Markdown 3.1.1
MarkupSafe 1.1.1
matplotlib 3.1.1
mistune 0.8.4
mock 3.0.5
mpi4py 3.0.2
nbconvert 5.6.0
nbformat 4.4.0
nltk 3.2.5
notebook 5.7.8
numba 0.44.1
numpy 1.14.5
nvidia-dali 0.13.0
nvidia-dali-tf-plugin 0.13.0
opencv-python 4.1.1.26
pandas 0.23.0
pandocfilters 1.4.2
parso 0.5.1
pexpect 4.7.0
pickleshare 0.7.5
Pillow 5.4.1
pip 19.2.3
portpicker 1.3.1
progressbar2 3.47.0
prometheus-client 0.7.1
prompt-toolkit 2.0.9
protobuf 3.9.1
psutil 5.6.3
ptyprocess 0.6.0
pycocotools 2.0.0
Pygments 2.4.2
pyparsing 2.4.2
pyrsistent 0.15.4
python-dateutil 2.8.0
python-speech-features 0.6
python-utils 2.3.0
pytz 2019.2
PyYAML 5.1.2
pyzmq 18.1.0
resampy 0.2.1
sacrebleu 1.3.6
scikit-learn 0.21.3
scipy 1.3.1
Send2Trash 1.5.0
sentencepiece 0.1.82
setuptools 41.2.0
six 1.12.0
tensorboard 1.14.0+nv
tensorflow-estimator 1.14.0
tensorflow-gpu 1.14.0+nv
tensorrt 6.0.1.4
termcolor 1.1.0
terminado 0.8.2
testpath 0.4.2
tornado 6.0.3
tqdm 4.36.0
traitlets 4.3.2
typing 3.7.4.1
uff 0.6.5
wcwidth 0.1.7
webencodings 0.5.1
Werkzeug 0.15.6
wheel 0.33.6
wrapt 1.11.2
I have python 3.7
, keras-retinanet 0.5.1
from pip and tensorflow-gpu 1.13.1
as required by keras-retinanet
. When I remove the tf 2.0 cpu version which is installed by default while setup a new error pops "AttributeError: module 'tensorflow' has no attribute 'name_scope'"
Hello.
I'm using SSD Inception v2 architecture and want to leverage this script to figure out the best anchor parameters for my custom dataset. In my understanding, the current codebase uses the default parameters for Keras-Retinanet and has some other minor dependencies.
I just wanted to initiate the discussion and see if any work has already been done along the line. Also, if required, lay down the list of tasks that are needed to achieve the above objective.
Thank you,
Aneesh
Give me this error
Using TensorFlow backend. Loading object dimensions. Traceback (most recent call last): File "anchor-optimization/optimize_anchors.py", line 131, in <module> x1, y1, x2, y2 = list(map(lambda x: int(x), row[1:5])) ValueError: not enough values to unpack (expected 4, got 1)
Hi, i would be really grateful if you could please help out in following queries:
i. Is this a good approach/recommended to change anchor area from 32^ - 512^2 to 16^2 to 256^ to meet the small size objects? Since increasing the no. of anchors also increases the computational time.
ii. If i change anchor size from [32, 64, 128, 256, 512] to [16, 32, 64, 128, 256] then how would i change the aspect ratio and scale values, means how to set the ratio and scale parameters values when i change the anchor size.
iii. In a particular dataset, how may i know that what is the smallest and largest size (in pixels) of an object so that i could decide about anchor sizes and areas.
Thanks,
Please tell me how do I run the code using my Nvidia GPU. I have already installed tensorflow-gpu.
Hello @martinzlocha
Thank you for the nice anchor-optimization tool!
I was wondering how I can interpret the anchor scale output? Is it a fraction of the default anchor size:
My goal is to optimize the anchor aspect ratios and the scales for YOLACT++. The aspect ratios can be easily copy-pasted, but the scales are in a different format. YOLACT uses absolute values instead of fractions. YOLACT uses a maximum image-size of 550 pixels: https://github.com/dbolya/yolact/blob/57b8f2d95e62e2e649b382f516ab41f949b57239/data/config.py#L664
When I executed the command below:
anchor-optimization yolact/data/custom/train/boxes.csv --ratios=3 --scales=5 --image-max-side 550
This output was generated:
State: 0.12784
Ratios: [0.461, 1.0, 2.168]
Scales: [0.4, 0.458, 0.527, 0.689, 1.2]
I'm a bit confused as the 'pred_scales' of YOLACT are:
[24, 48, 96, 192, 384]
https://github.com/dbolya/yolact/blob/57b8f2d95e62e2e649b382f516ab41f949b57239/data/config.py#L779
Can someone help me with the right interpretation?
Thanks in advance,
Pieter
File "c:\programdata\miniconda3\lib\site-packages\anchor_optimization\optimize_anchors.py", line 193, in anchors_optimize
x1, y1, x2, y2 = list(map(lambda x: int(x), row[1:5]))
ValueError: not enough values to unpack (expected 4, got 0)
and this problem:
Invalid argument: 'C:\Users\Administrator\Desktop\\ufeff"C:\Users\Administrator\Desktop\all1020\2021102010.jpg'
My dataset contains many images with large size (above 2000*2000) and have different shapes and size of classes. From what I saw when use debug.py
file from keras-retinanet, all small objects are fine with generated anchors, but with large objects ( > 20% of image width), no anchor matches. One of them is below:
I think many red boxes has made my traning process went into a trouble, when mAP value that calculated at the end of every epoch was 0.0000. How can I deal with this problem?
Hi guys, for the requirements I see you are using tensorflow rather than tensorflow-gpu.
I have tensorflow-gpu installed. Can I remove tensorflow from the requirements to be downloaded and run the code normally?
I run code in Python 3.6, I haven't 3.7 available,
When I run python optimize_anchors.py annotations.csv
I get the error:
Using TensorFlow backend.
Loading object dimensions.
Traceback (most recent call last):
File "optimize_anchors.py", line 137, in <module>
scale = compute_resize_scale(img.shape, min_side=args.image_min_side, max_side=args.image_max_side)
AttributeError: 'JpegImageFile' object has no attribute 'shape'
Hi!
First of all thanks for the contribution. In the default configuration the script worked out fine for me. I have a dataset with very small rectangles (256x256 images with small objects on it). For that reason I changed to bounds to allow a smaller value (I changed it here: https://github.com/martinzlocha/anchor-optimization/blob/master/optimize_anchors.py#L174) which worked fine and it printed that there are only 9 labels without a matching anchor, which is very good for my 2000+ images dataset. The full print here:
Current best anchor configuration
Ratios: [0.343, 0.77, 1.0, 1.298, 2.916]
Scales: [0.103, 0.129, 0.164]
Number of labels that don't have any matching anchor: 9
I ran your script like this:
python optimize_anchors.py --image-max-side 256 --image-min-side 256 --ratios 5 dataset.csv
But when I plug these values in the config and run the debug.py script from keras-retinanet like this:
python keras_retinanet/bin/debug.py --image-min-side 256 --image-max-side 256 --config config.ini csv dataset.csv classes.csv
very many boxes are drawn red (much more than half of the boxes of my full dataset).
Is there a limitation for the bounds of the scales that I don't know about?
Thanks in advance
Is there a possibility to specify base sizes and strides for calculation?
Current best anchor configuration
Ratios: [0.401, 1.0, 2.497]
Scales: [0.747, 1.103, 1.398]
Number of labels that don't have any matching anchor: 56047
Current best anchor configuration
Ratios: [0.355, 1.0, 2.816]
Scales: [0.582, 1.541, 1.873]
Number of labels that don't have any matching anchor: 51863
Current best anchor configuration
Ratios: [0.29, 1.0, 3.453]
Scales: [0.931, 0.99, 1.056]
Number of labels that don't have any matching anchor: 46175
Current best anchor configuration
Ratios: [0.254, 1.0, 3.944]
Scales: [0.867, 1.148, 1.549]
Number of labels that don't have any matching anchor: 39772
Current best anchor configuration
Ratios: [0.251, 1.0, 3.99]
Scales: [0.818, 0.994, 1.783]
Number of labels that don't have any matching anchor: 39665
Current best anchor configuration
Ratios: [0.251, 1.0, 3.99]
Scales: [0.994, 1.246, 1.387]
Number of labels that don't have any matching anchor: 39424
Current best anchor configuration
Ratios: [0.251, 1.0, 3.981]
Scales: [0.853, 1.29, 1.382]
Number of labels that don't have any matching anchor: 40024
Current best anchor configuration
Ratios: [0.251, 1.0, 3.978]
Scales: [1.113, 1.289, 1.713]
Number of labels that don't have any matching anchor: 39559
Current best anchor configuration
Ratios: [0.251, 1.0, 3.991]
Scales: [0.812, 1.37, 1.965]
Number of labels that don't have any matching anchor: 39546
Current best anchor configuration
Ratios: [0.25, 1.0, 3.998]
Scales: [0.824, 1.232, 1.781]
Number of labels that don't have any matching anchor: 39590
Current best anchor configuration
Ratios: [0.25, 1.0, 3.994]
Scales: [0.605, 1.048, 1.64]
Number of labels that don't have any matching anchor: 39333
this was the best anchor configuration i've got and i used --no-resize with image of size 1500*1500. how do i obtain better results without and dataset is huge to use --include-stride.
Hi,
I'm getting this error messagem when runing:
$ python anchor_optimization\optimize_anchors.py test.csv
Traceback (most recent call last):
File "E:\anchor-optimization\anchor_optimization\optimize_anchors.py", line 11, in <module>
from keras_retinanet.preprocessing.csv_generator import _open_for_csv
File "C:\Users\USER\anaconda3\envs\keras_env\lib\site-packages\keras_retinanet\preprocessing\csv_generator.py", line 18, in <module>
from .generator import Generator
File "C:\Users\USER\anaconda3\envs\keras_env\lib\site-packages\keras_retinanet\preprocessing\generator.py", line 39, in <module>
class Generator(keras.utils.Sequence):
AttributeError: module 'keras.utils' has no attribute 'Sequence'
Tensorflow version: 2.7.0
Any help?
Which value of --no-resize will give a better result, True of False?
It looks like that True (i.e. resizing the bounding box) is better.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.