From fc3503ff4e90c4a58add24ca308cb21dffdf530c Mon Sep 17 00:00:00 2001 From: forresti Date: Wed, 15 Jan 2014 12:22:32 -0800 Subject: [PATCH 01/92] import of ffld patchwork code; initial skeleton of pyramid stitching and its python iface --- Makefile | 2 +- python/caffe/imagenet/featpyramid_tests.py | 69 ++ python/caffe/pycaffe.cpp | 57 + python/caffe/stitch_pyramid/COPYING.txt | 674 +++++++++++ python/caffe/stitch_pyramid/JPEGImage.cpp | 340 ++++++ python/caffe/stitch_pyramid/JPEGImage.h | 106 ++ python/caffe/stitch_pyramid/JPEGPyramid.cpp | 110 ++ python/caffe/stitch_pyramid/JPEGPyramid.h | 127 ++ python/caffe/stitch_pyramid/Patchwork.cpp | 279 +++++ python/caffe/stitch_pyramid/Patchwork.h | 129 ++ .../caffe/stitch_pyramid/PyramidStitcher.cpp | 54 + python/caffe/stitch_pyramid/PyramidStitcher.h | 22 + python/caffe/stitch_pyramid/README.txt | 29 + python/caffe/stitch_pyramid/Rectangle.cpp | 151 +++ python/caffe/stitch_pyramid/Rectangle.h | 121 ++ python/caffe/stitch_pyramid/SimpleOpt.h | 1060 +++++++++++++++++ python/caffe/stitch_pyramid/build/Makefile | 50 + python/caffe/stitch_pyramid/build/demo.sh | 5 + .../build/stitch_pyramid_pascal.sh | 21 + .../stitch_pyramid/test_stitch_pyramid.cpp | 198 +++ 20 files changed, 3603 insertions(+), 1 deletion(-) create mode 100644 python/caffe/imagenet/featpyramid_tests.py create mode 100644 python/caffe/stitch_pyramid/COPYING.txt create mode 100644 python/caffe/stitch_pyramid/JPEGImage.cpp create mode 100644 python/caffe/stitch_pyramid/JPEGImage.h create mode 100644 python/caffe/stitch_pyramid/JPEGPyramid.cpp create mode 100644 python/caffe/stitch_pyramid/JPEGPyramid.h create mode 100644 python/caffe/stitch_pyramid/Patchwork.cpp create mode 100644 python/caffe/stitch_pyramid/Patchwork.h create mode 100644 python/caffe/stitch_pyramid/PyramidStitcher.cpp create mode 100644 python/caffe/stitch_pyramid/PyramidStitcher.h create mode 100644 python/caffe/stitch_pyramid/README.txt create mode 100644 python/caffe/stitch_pyramid/Rectangle.cpp create mode 100644 python/caffe/stitch_pyramid/Rectangle.h create mode 100644 python/caffe/stitch_pyramid/SimpleOpt.h create mode 100644 python/caffe/stitch_pyramid/build/Makefile create mode 100755 python/caffe/stitch_pyramid/build/demo.sh create mode 100755 python/caffe/stitch_pyramid/build/stitch_pyramid_pascal.sh create mode 100644 python/caffe/stitch_pyramid/test_stitch_pyramid.cpp diff --git a/Makefile b/Makefile index 54437f1e914..2eccdc40e0e 100644 --- a/Makefile +++ b/Makefile @@ -142,7 +142,7 @@ examples: init $(EXAMPLE_BINS) py$(PROJECT): py py: init $(STATIC_NAME) $(PY$(PROJECT)_SRC) $(PROTO_GEN_PY) - $(CXX) -shared -o $(PY$(PROJECT)_SO) $(PY$(PROJECT)_SRC) \ + $(CXX) -shared -o $(PY$(PROJECT)_SO) $(PY$(PROJECT)_SRC) -L./python/caffe/stitch_pyramid/build -lPyramidStitcher -I./python/caffe/stitch_pyramid \ $(STATIC_NAME) $(CXXFLAGS) $(PYTHON_LDFLAGS) @echo diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py new file mode 100644 index 00000000000..fe6f0581457 --- /dev/null +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -0,0 +1,69 @@ +''' +test cases for multiscale pyramids of Convnet features. + + used power_wrapper.py as a starting point. + + +example usage: +python featpyramid_tests.py --images_file=image_cat.txt --crop_mode=selective_search --model_def=../../../examples/imagenet_deploy.prototxt --pretrained_model=../../../alexnet_train_iter_470000 --output=selective_cat.h5 + +''' + +import numpy as np +import os +import sys +import gflags +import pandas as pd +import time +import skimage.io +import skimage.transform +import selective_search_ijcv_with_python as selective_search +import caffe + +#parameters to consider passing to C++ Caffe::featpyramid... +# image filename +# num scales (or something to control this) +# padding amount +# [batchsize is defined in prototxt... fine.] + +#hopefully caffenet is passed by ref... +def test_pyramid_IO(caffenet, imgFname): + #TODO + + #caffenet.testIO() + example_np_array = caffenet.testIO() #just return an array with 1 2 3 4... + #example_np_arrays = caffenet.testIO_multiPlane() #return array of arrays + + print example_np_array + print example_np_array[0].shape + + caffenet.testString('hi') + caffenet.testInt(1337) +''' +def featpyramid(caffenet, imgFname, [params]): + stitched_pyra = caffenet.extract_featpyramid(imgFname, [params]) + + pyra = unstitch_pyra(stitched_pyra) #alternatively, do this in C++ inside extract_featpyramid() + + return pyra +''' + + +if __name__ == "__main__": + + #pretend that these flags came off the command line: + imgFname = './pascal_009959.jpg' + model_def = '../../../examples/imagenet_deploy.prototxt' + pretrained_model = '../../../alexnet_train_iter_470000' + use_gpu = True + + caffenet = caffe.CaffeNet(model_def, pretrained_model) + caffenet.set_phase_test() + if use_gpu: + caffenet.set_mode_gpu() + + + #experiments... + test_pyramid_IO(caffenet, imgFname) + + diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index c32194ef998..ab617cc9c24 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -13,6 +13,7 @@ #include // NOLINT(build/include_order) #include "caffe/caffe.hpp" +#include "stitch_pyramid/PyramidStitcher.h" //also includes JPEGImage, Patchwork, etc // Temporary solution for numpy < 1.7 versions: old macro, no promises. // You're strongly advised to upgrade to >= 1.7. @@ -216,6 +217,58 @@ struct CaffeNet { } } + //void testIO(){ } //dummy example + + //float* -> numpy -> boost python (which can be returned to Python) + boost::python::object array_to_boostPython_4d(float* pyramid_float, + int nbPlanes, int depth_, int MaxHeight_, int MaxWidth_) + { + + npy_intp dims[4] = {nbPlanes, depth_, MaxHeight_, MaxWidth_}; //in floats + PyArrayObject* pyramid_float_py = (PyArrayObject*)PyArray_New( &PyArray_Type, 4, dims, NPY_FLOAT, 0, pyramid_float, 0, 0, 0 ); //not specifying strides + + //thanks: stackoverflow.com/questions/19185574 + boost::python::object pyramid_float_py_boost(boost::python::handle<>((PyObject*)pyramid_float_py)); + return pyramid_float_py_boost; + } + + //return a list containing one 4D numpy/boost array. (toy example) + boost::python::list testIO() + { + int nbPlanes = 1; + int depth_ = 1; + int MaxHeight_ = 10; + int MaxWidth_ = 10; + + //prepare data that we'll send to Python + float* pyramid_float = (float*)malloc(sizeof(float) * nbPlanes * depth_ * MaxHeight_ * MaxWidth_); + memset(pyramid_float, 0, sizeof(float) * nbPlanes * depth_ * MaxHeight_ * MaxWidth_); + pyramid_float[10] = 123; //test -- see if it shows up in Python + + boost::python::object pyramid_float_py_boost = array_to_boostPython_4d(pyramid_float, nbPlanes, depth_, MaxHeight_, MaxWidth_); + + boost::python::list blobs_top_boost; //list to return + blobs_top_boost.append(pyramid_float_py_boost); //put the output array in list + + return blobs_top_boost; //compile error: return-statement with no value + } + + void testString(string st){ + printf(" string from python: %s \n", st.c_str()); + } + + void testInt(int i){ + printf(" int from python: %d \n", i); + } + + void extract_featpyramid(string file){ + + int padding = 8; + int interval = 10; + Patchwork patchwork = stitch_pyramid(file, padding, interval); + + } + // The caffe::Caffe utility functions. void set_mode_cpu() { Caffe::set_mode(Caffe::CPU); } void set_mode_gpu() { Caffe::set_mode(Caffe::GPU); } @@ -261,6 +314,10 @@ BOOST_PYTHON_MODULE(pycaffe) { .def("set_phase_train", &CaffeNet::set_phase_train) .def("set_phase_test", &CaffeNet::set_phase_test) .def("set_device", &CaffeNet::set_device) + .def("testIO", &CaffeNet::testIO) //Forrest's test (return a numpy array) + .def("testString", &CaffeNet::testString) + .def("testInt", &CaffeNet::testInt) + .def("extract_featpyramid", &CaffeNet::extract_featpyramid) //NEW .def("blobs", &CaffeNet::blobs) .def("params", &CaffeNet::params); diff --git a/python/caffe/stitch_pyramid/COPYING.txt b/python/caffe/stitch_pyramid/COPYING.txt new file mode 100644 index 00000000000..94a9ed024d3 --- /dev/null +++ b/python/caffe/stitch_pyramid/COPYING.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/python/caffe/stitch_pyramid/JPEGImage.cpp b/python/caffe/stitch_pyramid/JPEGImage.cpp new file mode 100644 index 00000000000..78a09322507 --- /dev/null +++ b/python/caffe/stitch_pyramid/JPEGImage.cpp @@ -0,0 +1,340 @@ +//-------------------------------------------------------------------------------------------------- +// Implementation of the paper "Exact Acceleration of Linear Object Detectors", 12th European +// Conference on Computer Vision, 2012. +// +// Copyright (c) 2012 Idiap Research Institute, +// Written by Charles Dubout +// +// This file is part of FFLD (the Fast Fourier Linear Detector) +// +// FFLD is free software: you can redistribute it and/or modify it under the terms of the GNU +// General Public License version 3 as published by the Free Software Foundation. +// +// FFLD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +// Public License for more details. +// +// You should have received a copy of the GNU General Public License along with FFLD. If not, see +// . +//-------------------------------------------------------------------------------------------------- + +#include "JPEGImage.h" + +#include +#include + +#include +#include + +using namespace FFLD; +using namespace std; + +JPEGImage::JPEGImage() : width_(0), height_(0), depth_(0) +{ +} + +JPEGImage::JPEGImage(int width, int height, int depth, const uint8_t * bits) : width_(0), +height_(0), depth_(0) +{ + if ((width <= 0) || (height <= 0) || (depth <= 0)) + return; + + width_ = width; + height_ = height; + depth_ = depth; + bits_.resize(width * height * depth); + + if (bits) + copy(bits, bits + bits_.size(), bits_.begin()); +} + +JPEGImage::JPEGImage(const string & filename) : width_(0), height_(0), depth_(0) +{ + // Load the image + FILE * file = fopen(filename.c_str(), "rb"); + + if (!file) + return; + + jpeg_decompress_struct cinfo; + jpeg_error_mgr jerr; + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + jpeg_stdio_src(&cinfo, file); + + if ((jpeg_read_header(&cinfo, TRUE) != JPEG_HEADER_OK) || (cinfo.data_precision != 8) || + !jpeg_start_decompress(&cinfo)) { + fclose(file); + return; + } + + vector bits(cinfo.image_width * cinfo.image_height * cinfo.num_components); + + for (int y = 0; y < cinfo.image_height; ++y) { + JSAMPLE * row = static_cast(&bits[y * cinfo.image_width * cinfo.num_components]); + + if (jpeg_read_scanlines(&cinfo, &row, 1) != 1) { + fclose(file); + return; + } + } + + jpeg_finish_decompress(&cinfo); + + fclose(file); + + // Recopy everyting if the loading was successful + width_ = cinfo.image_width; + height_ = cinfo.image_height; + depth_ = cinfo.num_components; + bits_.swap(bits); +} + +int JPEGImage::width() const +{ + return width_; +} + +int JPEGImage::height() const +{ + return height_; +} + +int JPEGImage::depth() const +{ + return depth_; +} + +const uint8_t * JPEGImage::bits() const +{ + return empty() ? 0 : &bits_[0]; +} + +uint8_t * JPEGImage::bits() +{ + return empty() ? 0 : &bits_[0]; +} + +const uint8_t * JPEGImage::scanLine(int y) const +{ + return (empty() || (y >= height_)) ? 0 : &bits_[y * width_ * depth_]; +} + +uint8_t * JPEGImage::scanLine(int y) +{ + return (empty() || (y >= height_)) ? 0 : &bits_[y * width_ * depth_]; +} + +bool JPEGImage::empty() const +{ + return (width() <= 0) || (height() <= 0) || (depth() <= 0); +} + +void JPEGImage::save(const string & filename, int quality) const +{ + if (empty()) + return; + + FILE * file = fopen(filename.c_str(), "wb"); + + if (!file) + return; + + jpeg_compress_struct cinfo; + jpeg_error_mgr jerr; + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + jpeg_stdio_dest(&cinfo, file); + + cinfo.image_width = width_; + cinfo.image_height = height_; + cinfo.input_components = depth_; + cinfo.in_color_space = (depth_ == 1) ? JCS_GRAYSCALE : JCS_RGB; + + jpeg_set_defaults(&cinfo); + jpeg_set_quality(&cinfo, quality, TRUE); + jpeg_start_compress(&cinfo, TRUE); + + for (int y = 0; y < height_; ++y) { + const JSAMPLE * row = static_cast(&bits_[y * width_ * depth_]); + jpeg_write_scanlines(&cinfo, const_cast(&row), 1); + } + + jpeg_finish_compress(&cinfo); + + fclose(file); +} + +JPEGImage JPEGImage::resize(int width, int height) const +{ + // Empty image + if ((width <= 0) || (height <= 0)) + return JPEGImage(); + + // Same dimensions + if ((width == width_) && (height == height_)) + return *this; + + JPEGImage result; + + result.width_ = width; + result.height_ = height; + result.depth_ = depth_; + result.bits_.resize(width * height * depth_); + + // Resize the image at each octave + int srcWidth = width_; + int srcHeight = height_; + + vector tmpSrc; + vector tmpDst; + + float scale = 0.5f; + int halfWidth = width_ * scale + 0.5f; + int halfHeight = height_ * scale + 0.5f; + + while ((width <= halfWidth) && (height <= halfHeight)) { + if (tmpDst.empty()) + tmpDst.resize(halfWidth * halfHeight * depth_); + + Resize(tmpSrc.empty() ? &bits_[0] : &tmpSrc[0], srcWidth, srcHeight, &tmpDst[0], halfWidth, + halfHeight, depth_); + + // Dst becomes src + tmpSrc.swap(tmpDst); + srcWidth = halfWidth; + srcHeight = halfHeight; + + // Next octave + scale *= 0.5f; + halfWidth = width_ * scale + 0.5f; + halfHeight = height_ * scale + 0.5f; + } + + Resize(tmpSrc.empty() ? &bits_[0] : &tmpSrc[0], srcWidth, srcHeight, &result.bits_[0], width, + height, depth_); + + return result; +} + +JPEGImage JPEGImage::crop(int x, int y, int width, int height) const +{ + // Empty image + if ((width <= 0) || (height <= 0) || (x + width <= 0) || (y + height <= 0) || (x >= width_) || + (y >= height_)) + return JPEGImage(); + + // Crop the coordinates to the image + width = min(x + width - 1, width_ - 1) - max(x, 0) + 1; + height = min(y + height - 1, height_ - 1) - max(y, 0) + 1; + x = max(x, 0); + y = max(y, 0); + + JPEGImage result; + + result.width_ = width; + result.height_ = height; + result.depth_ = depth_; + result.bits_.resize(width * height * depth_); + + for (int y2 = 0; y2 < height; ++y2) + for (int x2 = 0; x2 < width; ++x2) + for (int i = 0; i < depth_; ++i) + result.bits_[(y2 * width + x2) * depth_ + i] = + bits_[((y + y2) * width_ + x + x2) * depth_ + i]; + + return result; +} + +//TODO: remove const? +JPEGImage JPEGImage::pad(int padx, int pady) const +{ + // empty image + if( (padx < 0) || (pady < 0) ) + return JPEGImage(); + + int srcWidth = this->width(); + int srcHeight = this->height(); + + // new size with padding + int dstWidth = srcWidth + 2*padx; + int dstHeight = srcHeight + 2*pady; + + JPEGImage result; + result.width_ = dstWidth; + result.height_ = dstHeight; + result.depth_ = depth_; + result.bits_.resize(dstWidth * dstHeight * depth_); + + //rectangle packing offsets: + int x_off = padx; + int y_off = pady; + + //copy to padded image + for (int y = 0; y < srcHeight; y++){ + for (int x = 0; x < srcWidth; x++){ + for (int ch = 0; ch < depth_; ch++){ + + //result.bits_[...] = this->bits_[...]; + result.bits_[(y+y_off)*dstWidth*depth_ + (x+x_off)*depth_ + ch] = this->bits_[y*srcWidth*depth_ + x*depth_ + ch]; + } + } + } + return result; +} + +// Bilinear interpolation coefficient +namespace FFLD +{ +namespace detail +{ +struct Bilinear +{ + int x0; + int x1; + float a; + float b; +}; +} +} + +void JPEGImage::Resize(const uint8_t * src, int srcWidth, int srcHeight, uint8_t * dst, + int dstWidth, int dstHeight, int depth) +{ + if ((srcWidth == dstWidth) && (srcHeight == dstHeight)) { + copy(src, src + srcWidth * srcHeight * depth, dst); + return; + } + + const float xScale = static_cast(srcWidth) / dstWidth; + const float yScale = static_cast(srcHeight) / dstHeight; + + // Bilinear interpolation coefficients + vector cols(dstWidth); + + for (int j = 0; j < dstWidth; ++j) { + const float x = min(max((j + 0.5f) * xScale - 0.5f, 0.0f), srcWidth - 1.0f); + cols[j].x0 = x; + cols[j].x1 = min(cols[j].x0 + 1, srcWidth - 1); + cols[j].a = x - cols[j].x0; + cols[j].b = 1.0f - cols[j].a; + } + + for (int i = 0; i < dstHeight; ++i) { + const float y = min(max((i + 0.5f) * yScale - 0.5f, 0.0f), srcHeight - 1.0f); + const int y0 = y; + const int y1 = min(y0 + 1, srcHeight - 1); + const float c = y - y0; + const float d = 1.0f - c; + + for (int j = 0; j < dstWidth; ++j) + for (int k = 0; k < depth; ++k) + dst[(i * dstWidth + j) * depth + k] = + (src[(y0 * srcWidth + cols[j].x0) * depth + k] * cols[j].b + + src[(y0 * srcWidth + cols[j].x1) * depth + k] * cols[j].a) * d + + (src[(y1 * srcWidth + cols[j].x0) * depth + k] * cols[j].b + + src[(y1 * srcWidth + cols[j].x1) * depth + k] * cols[j].a) * c + 0.5f; + } +} diff --git a/python/caffe/stitch_pyramid/JPEGImage.h b/python/caffe/stitch_pyramid/JPEGImage.h new file mode 100644 index 00000000000..f5a87a2e21a --- /dev/null +++ b/python/caffe/stitch_pyramid/JPEGImage.h @@ -0,0 +1,106 @@ +//-------------------------------------------------------------------------------------------------- +// Implementation of the paper "Exact Acceleration of Linear Object Detectors", 12th European +// Conference on Computer Vision, 2012. +// +// Copyright (c) 2012 Idiap Research Institute, +// Written by Charles Dubout +// +// This file is part of FFLD (the Fast Fourier Linear Detector) +// +// FFLD is free software: you can redistribute it and/or modify it under the terms of the GNU +// General Public License version 3 as published by the Free Software Foundation. +// +// FFLD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +// Public License for more details. +// +// You should have received a copy of the GNU General Public License along with FFLD. If not, see +// . +//-------------------------------------------------------------------------------------------------- + +#ifndef FFLD_JPEGIMAGE_H +#define FFLD_JPEGIMAGE_H + +#include +#include +#include + +namespace FFLD +{ +/// The JPEGImage class allows to load/save an image from/to a jpeg file, and to apply basic +/// operations such as resizing or cropping to it. The pixels are stored contiguously in row-major +/// order (scanline 0: RGB RGB RGB, scanline 1: RGB RGB RGB...) +class JPEGImage +{ +public: + /// Constructs an empty image. An empty image has zero size. + JPEGImage(); + + /// Constructs an image with the given @p width, @p height and @p depth, and initializes it from + /// the given @p bits. + /// @note The returned image might be empty if any of the parameters is incorrect. + JPEGImage(int width, int height, int depth, const uint8_t * bits = 0); + + /// Constructs an image and tries to load the image from the jpeg file with the given + /// @p filename. + /// @note The returned image might be empty if the image could not be loaded. + JPEGImage(const std::string & filename); + + /// Returns the width of the image. + int width() const; + + /// Returns the height of the image. + int height() const; + + /// Returns the depth of the image. The image depth is the number of color channels. + int depth() const; + + /// Returns a pointer to the pixel data. + /// @note Returns a null pointer if the image is empty. + const uint8_t * bits() const; + + /// Returns a pointer to the pixel data. Returns a null pointer if the image is empty. + uint8_t * bits(); + + /// Returns a pointer to the pixel data at the scanline with index y. The first scanline is at + /// index 0. Returns a null pointer if the image is empty or if y is out of bounds. + const uint8_t * scanLine(int y) const; + + /// Returns a pointer to the pixel data at the scanline with index y. The first scanline is at + /// index 0. Returns a null pointer if the image is empty or if y is out of bounds. + uint8_t * scanLine(int y); + + /// Returns whether the image is empty. An empty image has zero size. + bool empty() const; + + /// Saves the image to a jpeg file with the given @p filename and @p quality. + void save(const std::string & filename, int quality = 100) const; + + /// Returns a copy of the image scaled to the given @p width and @p height. + /// If either the width or the height is zero or negative, the method returns an empty image. + JPEGImage resize(int width, int height) const; + + /// Returns a copy of a region of the image located at @p x and @p y, and of dimensions @p width + /// and @p height. + /// @note The returned image might be smaller if some of the coordinates are outside the image. + JPEGImage crop(int x, int y, int width, int height) const; + + JPEGImage pad(int x, int y) const; + +private: + // Blur and downscale an image by a factor 2 + static void Halve(const uint8_t * src, int srcWidth, int srcHeight, uint8_t * dst, + int dstWidth, int dstHeight, int depth); + + // Resize an image to the specified dimensions using bilinear interpolation + static void Resize(const uint8_t * src, int srcWidth, int srcHeight, uint8_t * dst, + int dstWidth, int dstHeight, int depth); + + int width_; + int height_; + int depth_; + std::vector bits_; +}; +} + +#endif diff --git a/python/caffe/stitch_pyramid/JPEGPyramid.cpp b/python/caffe/stitch_pyramid/JPEGPyramid.cpp new file mode 100644 index 00000000000..ba44b5b3d35 --- /dev/null +++ b/python/caffe/stitch_pyramid/JPEGPyramid.cpp @@ -0,0 +1,110 @@ +//-------------------------------------------------------------------------------------------------- +// Implementation of the paper "Exact Acceleration of Linear Object Detectors", 12th European +// Conference on Computer Vision, 2012. +// +// Copyright (c) 2012 Idiap Research Institute, +// Written by Charles Dubout +// +// This file is part of FFLD (the Fast Fourier Linear Detector) +// +// FFLD is free software: you can redistribute it and/or modify it under the terms of the GNU +// General Public License version 3 as published by the Free Software Foundation. +// +// FFLD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +// Public License for more details. +// +// You should have received a copy of the GNU General Public License along with FFLD. If not, see +// . +//-------------------------------------------------------------------------------------------------- + +#include "JPEGPyramid.h" + +#include +#include +#include +#include +#include + +//#define DISABLE_HOG_BLOCKS //if defined: just compute hog cells; don't normalize into hog blocks + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +//using namespace Eigen; +using namespace FFLD; +using namespace std; + +JPEGPyramid::JPEGPyramid() : padx_(0), pady_(0), interval_(0) +{ +} + +JPEGPyramid::JPEGPyramid(int padx, int pady, int interval, const vector & levels) : padx_(0), +pady_(0), interval_(0) +{ + if ((padx < 1) || (pady < 1) || (interval < 1)) + return; + + padx_ = padx; + pady_ = pady; + interval_ = interval; + levels_ = levels; +} + +JPEGPyramid::JPEGPyramid(const JPEGImage & image, int padx, int pady, int interval) : padx_(0), +pady_(0), interval_(0) +{ + if (image.empty() || (padx < 1) || (pady < 1) || (interval < 1)) + return; + + // Copmute the number of scales such that the smallest size of the last level is 5 + const int maxScale = ceil(log(min(image.width(), image.height()) / 40.0) / log(2.0)) * interval; + + // Cannot compute the pyramid on images too small + if (maxScale < interval) + return; + + padx_ = padx; + pady_ = pady; + interval_ = interval; + levels_.resize(maxScale + 1); + vector scales(maxScale+1); + +#pragma omp parallel for + for (int i = 0; i <= maxScale; ++i){ + //generic pyramid... not stitched. + + double scale = pow(2.0, static_cast(-i) / interval); + JPEGImage scaled = image.resize(image.width() * scale + 0.5, image.height() * scale + 0.5); + scaled = scaled.pad(padx, pady); //an additional deepcopy. (for efficiency, could have 'resize()' accept padding too + + levels_[i] = scaled; + } +} + +int JPEGPyramid::padx() const +{ + return padx_; +} + +int JPEGPyramid::pady() const +{ + return pady_; +} + +int JPEGPyramid::interval() const +{ + return interval_; +} + +const vector & JPEGPyramid::levels() const +{ + return levels_; +} + +bool JPEGPyramid::empty() const +{ + return levels().empty(); +} + diff --git a/python/caffe/stitch_pyramid/JPEGPyramid.h b/python/caffe/stitch_pyramid/JPEGPyramid.h new file mode 100644 index 00000000000..97c0a8cfa5d --- /dev/null +++ b/python/caffe/stitch_pyramid/JPEGPyramid.h @@ -0,0 +1,127 @@ +//-------------------------------------------------------------------------------------------------- +// Implementation of the paper "Exact Acceleration of Linear Object Detectors", 12th European +// Conference on Computer Vision, 2012. +// +// Copyright (c) 2012 Idiap Research Institute, +// Written by Charles Dubout +// +// This file is part of FFLD (the Fast Fourier Linear Detector) +// +// FFLD is free software: you can redistribute it and/or modify it under the terms of the GNU +// General Public License version 3 as published by the Free Software Foundation. +// +// FFLD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +// Public License for more details. +// +// You should have received a copy of the GNU General Public License along with FFLD. If not, see +// . +//-------------------------------------------------------------------------------------------------- + +#ifndef FFLD_JPEGPYRAMID_H +#define FFLD_JPEGPYRAMID_H + +#include "JPEGImage.h" + +//#include +//#include + +namespace FFLD +{ +/// The JPEGPyramid class computes and stores the HOG features extracted from a jpeg image at +/// multiple scales. The scale of the pyramid level of index @c i is given by the following formula: +/// 2^(1 - @c i / @c interval), so that the first scale is at double the resolution of the original +/// image). Each level is padded with zeros horizontally and vertically by a fixed amount. The last +/// feature is special: it takes the value one in the padding and zero otherwise. +/// @note Define the PASCAL_JPEGPYRAMID_FELZENSZWALB_FEATURES flag during compilation to use +/// Felzenszwalb's original features (slower and not as accurate as they do no angular +/// interpolation, provided for compatibility only). +/// @note Define the PASCAL_JPEGPYRAMID_DOUBLE to use double scalar values instead of float (slower, +/// uses twice the amount of memory, and the increase in precision is not necessarily useful). +class JPEGPyramid +{ +public: + static const int NbChannels = 3; //RGB + + /// Type of a scalar value. +#ifndef FFLD_JPEGPYRAMID_DOUBLE + typedef float Scalar; +#else + typedef double Scalar; +#endif + + /// Type of a matrix. + //typedef Eigen::Matrix Matrix; + +#if 0 + /// Type of a sparse matrix. + typedef Eigen::SparseMatrix SparseMatrix; + + /// Type of a pyramid level cell (fixed-size vector of length NbChannels). + typedef Eigen::Array Cell; +#endif + + /// Type of a pyramid level (matrix of cells). + //typedef Eigen::Matrix Level; + typedef JPEGImage Level; + + /// Constructs an empty pyramid. An empty pyramid has no level. + JPEGPyramid(); + + /// Constructs a pyramid from parameters and a list of levels. + /// @param[in] padx Amount of horizontal zero padding (in cells). + /// @param[in] pady Amount of vertical zero padding (in cells). + /// @param[in] interval Number of levels per octave in the pyramid. + /// @param[in] levels List of pyramid levels. + /// @note The amount of padding and the interval should be at least 1. + JPEGPyramid(int padx, int pady, int interval, const std::vector & levels); + + /// Constructs a pyramid from the JPEGImage of a Scene. + /// @param[in] image The JPEGImage of the Scene. + /// @param[in] padx Amount of horizontal zero padding (in cells). + /// @param[in] pady Amount of vertical zero padding (in cells). + /// @param[in] interval Number of levels per octave in the pyramid. + /// @note The amount of padding and the interval should be at least 1. + JPEGPyramid(const JPEGImage & image, int padx, int pady, int interval = 10); + + /// Returns whether the pyramid is empty. An empty pyramid has no level. + bool empty() const; + + /// Returns the amount of horizontal zero padding (in cells). + int padx() const; + + /// Returns the amount of vertical zero padding (in cells). + int pady() const; + + /// Returns the number of levels per octave in the pyramid. + int interval() const; + + /// Returns the pyramid levels. + /// @note Scales are given by the following formula: 2^(1 - @c index / @c interval). + const std::vector & levels() const; + +private: + int padx_; + int pady_; + int interval_; + std::vector levels_; +}; +} + +#if 0 +// Some compilers complain about the lack of a NumTraits for Eigen::Array +namespace Eigen +{ +template <> +struct NumTraits > : + GenericNumTraits > +{ + static inline FFLD::JPEGPyramid::Scalar dummy_precision() + { + return 0; // Never actually called + } +}; +} +#endif + +#endif diff --git a/python/caffe/stitch_pyramid/Patchwork.cpp b/python/caffe/stitch_pyramid/Patchwork.cpp new file mode 100644 index 00000000000..f0a53e8ece4 --- /dev/null +++ b/python/caffe/stitch_pyramid/Patchwork.cpp @@ -0,0 +1,279 @@ +//-------------------------------------------------------------------------------------------------- +// Implementation of the paper "Exact Acceleration of Linear Object Detectors", 12th European +// Conference on Computer Vision, 2012. +// +// Copyright (c) 2012 Idiap Research Institute, +// Written by Charles Dubout +// +// This file is part of FFLD (the Fast Fourier Linear Detector) +// +// FFLD is free software: you can redistribute it and/or modify it under the terms of the GNU +// General Public License version 3 as published by the Free Software Foundation. +// +// FFLD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +// Public License for more details. +// +// You should have received a copy of the GNU General Public License along with FFLD. If not, see +// . +//-------------------------------------------------------------------------------------------------- + +#include "Patchwork.h" +#include "JPEGPyramid.h" + +#include +#include +#include +#include +#include + +//using namespace Eigen; +using namespace FFLD; +using namespace std; + +int Patchwork::MaxRows_(0); +int Patchwork::MaxCols_(0); +int Patchwork::HalfCols_(0); + +Patchwork::Patchwork() : padx_(0), pady_(0), interval_(0) +{ +} + +Patchwork::Patchwork(const JPEGPyramid & pyramid) : padx_(pyramid.padx()), pady_(pyramid.pady()), +interval_(pyramid.interval()) +{ + nbScales = pyramid.levels().size(); //Patchwork class variable + //cout << " nbScales = " << nbScales << endl; + //printf(" MaxRows_ = %d, MaxCols_=%d \n", MaxRows_, MaxCols_); + + rectangles_.resize(nbScales); + + for (int i = 0; i < nbScales; ++i) { + rectangles_[i].first.setWidth(pyramid.levels()[i].width()); //stitching includes padding in the img size. + rectangles_[i].first.setHeight(pyramid.levels()[i].height()); + } + + // Build the patchwork planes + const int nbPlanes = BLF(rectangles_); + cout << " nbPlanes = " << nbPlanes << endl; + + // Constructs an empty patchwork in case of error + if (nbPlanes <= 0) + return; + + planes_.resize(nbPlanes); + for (int i = 0; i < nbPlanes; ++i) { + //planes_[i] = Plane::Constant(MaxRows_, HalfCols_, Cell::Zero()); + planes_[i] = JPEGImage(MaxCols_, MaxRows_, JPEGPyramid::NbChannels); //JPEGImage(width, height, depth) + } + + int depth = JPEGPyramid::NbChannels; + + // [Forrest implemented... ] + //COPY scaled images -> fixed-size planes +#pragma omp parallel for + for (int i = 0; i < nbScales; ++i) { + + //currPlane is destination + JPEGImage* currPlane = &planes_[rectangles_[i].second]; //TODO: make sure my dereferencing makes sense. (trying to avoid deepcopy) + + //currLevel is source + const JPEGImage* currLevel = &pyramid.levels()[i]; + + int srcWidth = currLevel->width(); + int srcHeight = currLevel->height(); + + int dstWidth = currPlane->width(); + int dstHeight = currPlane->height(); + + //rectangle packing offsets: + int x_off = rectangles_[i].first.x(); + int y_off = rectangles_[i].first.y(); + + for (int y = 0; y < srcHeight; y++){ + for (int x = 0; x < srcWidth; x++){ + for (int ch = 0; ch < JPEGPyramid::NbChannels; ch++){ + + //currPlane.bits[...] = pyramid.levels()[i].data[...]; + currPlane->bits()[((y + y_off)*dstWidth*depth) + ((x + x_off)*depth) + ch] = currLevel->bits()[y*srcWidth*depth + x*depth + ch]; + } + } + } + } +} + +int Patchwork::padx() const +{ + return padx_; +} + +int Patchwork::pady() const +{ + return pady_; +} + +int Patchwork::interval() const +{ + return interval_; +} + +bool Patchwork::empty() const +{ + return planes_.empty(); +} + +bool Patchwork::Init(int maxRows, int maxCols) +{ + // It is an error if maxRows or maxCols are too small + if ((maxRows < 2) || (maxCols < 2)) + return false; + + // Temporary matrices + //JPEGPyramid::Matrix tmp(maxRows * JPEGPyramid::NbChannels, maxCols + 2); + + int dims[2] = {maxRows, maxCols}; + MaxRows_ = maxRows; + MaxCols_ = maxCols; + HalfCols_ = maxCols / 2 + 1; +} + +int Patchwork::MaxRows() +{ + return MaxRows_; +} + +int Patchwork::MaxCols() +{ + return MaxCols_; +} + +namespace FFLD +{ +namespace detail +{ +// Order rectangles by decreasing area. +class AreaComparator +{ +public: + AreaComparator(const vector > & rectangles) : + rectangles_(rectangles) + { + } + + /// Returns whether rectangle @p a comes before @p b. + bool operator()(int a, int b) const + { + const int areaA = rectangles_[a].first.area(); + const int areaB = rectangles_[b].first.area(); + + return (areaA > areaB) || ((areaA == areaB) && (rectangles_[a].first.height() > + rectangles_[b].first.height())); + } + +private: + const vector > & rectangles_; +}; + +// Order free gaps (rectangles) by position and then by size +struct PositionComparator +{ + // Returns whether rectangle @p a comes before @p b + bool operator()(const Rectangle & a, const Rectangle & b) const + { + return (a.y() < b.y()) || + ((a.y() == b.y()) && + ((a.x() < b.x()) || + ((a.x() == b.x()) && + ((a.height() > b.height()) || + ((a.height() == b.height()) && (a.width() > b.width())))))); + } +}; +} +} + +int Patchwork::BLF(vector > & rectangles) +{ + // Order the rectangles by decreasing area. If a rectangle is bigger than MaxRows x MaxCols + // return -1 + vector ordering(rectangles.size()); + + for (int i = 0; i < rectangles.size(); ++i) { + if ((rectangles[i].first.width() > MaxCols_) || (rectangles[i].first.height() > MaxRows_)) + return -1; + + ordering[i] = i; + } + + sort(ordering.begin(), ordering.end(), detail::AreaComparator(rectangles)); + + // Index of the plane containing each rectangle + for (int i = 0; i < rectangles.size(); ++i) + rectangles[i].second = -1; + + vector > gaps; + + // Insert each rectangle in the first gap big enough + for (int i = 0; i < rectangles.size(); ++i) { + pair & rect = rectangles[ordering[i]]; + + // Find the first gap big enough + set::iterator g; + + for (int i = 0; (rect.second == -1) && (i < gaps.size()); ++i) { + for (g = gaps[i].begin(); g != gaps[i].end(); ++g) { + if ((g->width() >= rect.first.width()) && (g->height() >= rect.first.height())) { + rect.second = i; + break; + } + } + } + + // If no gap big enough was found, add a new plane + if (rect.second == -1) { + set plane; + plane.insert(Rectangle(MaxCols_, MaxRows_)); // The whole plane is free + gaps.push_back(plane); + g = gaps.back().begin(); + rect.second = gaps.size() - 1; + } + + // Insert the rectangle in the gap + rect.first.setX(g->x()); + rect.first.setY(g->y()); + + // Remove all the intersecting gaps, and add newly created gaps + for (g = gaps[rect.second].begin(); g != gaps[rect.second].end();) { + if (!((rect.first.right() < g->left()) || (rect.first.bottom() < g->top()) || + (rect.first.left() > g->right()) || (rect.first.top() > g->bottom()))) { + // Add a gap to the left of the new rectangle if possible + if (g->x() < rect.first.x()) + gaps[rect.second].insert(Rectangle(g->x(), g->y(), rect.first.x() - g->x(), + g->height())); + + // Add a gap on top of the new rectangle if possible + if (g->y() < rect.first.y()) + gaps[rect.second].insert(Rectangle(g->x(), g->y(), g->width(), + rect.first.y() - g->y())); + + // Add a gap to the right of the new rectangle if possible + if (g->right() > rect.first.right()) + gaps[rect.second].insert(Rectangle(rect.first.right() + 1, g->y(), + g->right() - rect.first.right(), + g->height())); + + // Add a gap below the new rectangle if possible + if (g->bottom() > rect.first.bottom()) + gaps[rect.second].insert(Rectangle(g->x(), rect.first.bottom() + 1, g->width(), + g->bottom() - rect.first.bottom())); + + // Remove the intersecting gap + gaps[rect.second].erase(g++); + } + else { + ++g; + } + } + } + + return gaps.size(); +} diff --git a/python/caffe/stitch_pyramid/Patchwork.h b/python/caffe/stitch_pyramid/Patchwork.h new file mode 100644 index 00000000000..be875c29669 --- /dev/null +++ b/python/caffe/stitch_pyramid/Patchwork.h @@ -0,0 +1,129 @@ +//-------------------------------------------------------------------------------------------------- +// Implementation of the paper "Exact Acceleration of Linear Object Detectors", 12th European +// Conference on Computer Vision, 2012. +// +// Copyright (c) 2012 Idiap Research Institute, +// Written by Charles Dubout +// +// This file is part of FFLD (the Fast Fourier Linear Detector) +// +// FFLD is free software: you can redistribute it and/or modify it under the terms of the GNU +// General Public License version 3 as published by the Free Software Foundation. +// +// FFLD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +// Public License for more details. +// +// You should have received a copy of the GNU General Public License along with FFLD. If not, see +// . +//-------------------------------------------------------------------------------------------------- + +#ifndef FFLD_PATCHWORK_H +#define FFLD_PATCHWORK_H + +#include "JPEGPyramid.h" +#include "Rectangle.h" + +#include + +namespace FFLD +{ +/// The Patchwork class computes full convolutions much faster than the JPEGPyramid class. +class Patchwork +{ +public: + /// Type of a scalar value. + //typedef std::complex Scalar; + +#if 0 + /// Type of a matrix. + typedef Eigen::Matrix Matrix; + + /// Type of a patchwork plane cell (fixed-size complex vector of size NbChannels). + typedef Eigen::Array Cell; +#endif + + /// Type of a patchwork plane (matrix of cells). + //typedef Eigen::Matrix Plane; + typedef JPEGImage Plane; + + /// Type of a patchwork filter (plane + original filter size). + typedef std::pair > Filter; + + /// Constructs an empty patchwork. An empty patchwork has no plane. + Patchwork(); + + /// Constructs a patchwork from a pyramid. + /// @param[in] pyramid The pyramid of features. + /// @note If the pyramid is larger than the last maxRows and maxCols passed to the Init method + /// the Patchwork will be empty. + /// @note Assumes that the features of the pyramid levels are zero in the padded regions but for + /// the last feature, which is assumed to be one. + Patchwork(const JPEGPyramid & pyramid); + + /// Returns the amount of horizontal zero padding (in cells). + int padx() const; + + /// Returns the amount of vertical zero padding (in cells). + int pady() const; + + /// Returns the number of levels per octave in the pyramid. + int interval() const; + + /// Returns whether the patchwork is empty. An empty patchwork has no plane. + bool empty() const; + + /// Returns the convolutions of the patchwork with filters (useful to compute the SVM margins). + /// @param[in] filters The filters. + /// @param[out] convolutions The convolutions (filters x levels). + //void convolve(const std::vector & filters, + // std::vector > & convolutions) const; + + /// Initializes the data structures. + /// @param[in] maxRows Maximum number of rows of a pyramid level (including padding). + /// @param[in] maxCols Maximum number of columns of a pyramid level (including padding). + /// @returns Whether the initialization was successful. + /// @note Must be called before any other method (including constructors). + static bool Init(int maxRows, int maxCols); + + /// Returns the current maximum number of rows of a pyramid level (including padding). + static int MaxRows(); + + /// Returns the current maximum number of columns of a pyramid level (including padding). + static int MaxCols(); + + std::vector planes_; + int nbScales; + +private: + // Bottom-Left fill algorithm + static int BLF(std::vector > & rectangles); + + int padx_; + int pady_; + int interval_; + std::vector > rectangles_; + + static int MaxRows_; //TODO: make these public. + static int MaxCols_; + static int HalfCols_; +}; +} + +#if 0 +// Some compilers complain about the lack of a NumTraits for Eigen::Array +namespace Eigen +{ +template <> +struct NumTraits > : + GenericNumTraits > +{ + static inline FFLD::JPEGPyramid::Scalar dummy_precision() + { + return 0; // Never actually called + } +}; +} +#endif + +#endif diff --git a/python/caffe/stitch_pyramid/PyramidStitcher.cpp b/python/caffe/stitch_pyramid/PyramidStitcher.cpp new file mode 100644 index 00000000000..ff8e8504c3b --- /dev/null +++ b/python/caffe/stitch_pyramid/PyramidStitcher.cpp @@ -0,0 +1,54 @@ + +#include "SimpleOpt.h" +#include "JPEGPyramid.h" +#include "JPEGImage.h" +#include "Patchwork.h" + +#include +#include +#include +#include + +using namespace FFLD; +using namespace std; + +//TODO: have a pyramid stitch class? + +//int main(int argc, char * argv[]) +Patchwork stitch_pyramid(string file, int padding=8, int interval=10) +{ + JPEGImage image(file); + if (image.empty()) { + cerr << "\nInvalid image " << file << endl; + } + + //image = image.resize(image.width()*4, image.height()*4); //UPSAMPLE so that Caffe's 16x downsampling looks like 4x downsampling + image = image.resize(image.width()*2, image.height()*2); //UPSAMPLE so that Caffe's 16x downsampling looks like 8x downsampling + + // Compute the downsample+stitch + JPEGPyramid pyramid(image, padding, padding, interval); //DOWNSAMPLE with (padx == pady == padding) + if (pyramid.empty()) { + cerr << "\nInvalid image " << file << endl; + } + + int planeWidth = (pyramid.levels()[0].width() + 15) & ~15; //TODO: don't subtract padx, pady? + int planeHeight = (pyramid.levels()[0].height() + 15) & ~15; + planeWidth = max(planeWidth, planeHeight); //SQUARE planes for Caffe convnet + planeHeight = max(planeWidth, planeHeight); + + Patchwork::Init(planeHeight, planeWidth); + const Patchwork patchwork(pyramid); //STITCH + + return patchwork; +} + +//@param convnet_subsampling_ratio = difference between input image dim and convnet feature dim +// e.g. if input img is 200x200 and conv5 is 25x25 ... 200/25=8 -> 8x downsampling in convnet +JPEGPyramid unstitch_pyramid(Patchwork image_patchwork, float* convnet_planes, int convnet_subsampling_ratio){ + + JPEGPyramid pyra; //stub + + return pyra; +} + + diff --git a/python/caffe/stitch_pyramid/PyramidStitcher.h b/python/caffe/stitch_pyramid/PyramidStitcher.h new file mode 100644 index 00000000000..bfed141956f --- /dev/null +++ b/python/caffe/stitch_pyramid/PyramidStitcher.h @@ -0,0 +1,22 @@ +#ifndef PYRAMID_STITCHER_H +#define PYRAMID_STITCHER_H + +#include "SimpleOpt.h" +#include "JPEGPyramid.h" +#include "JPEGImage.h" +#include "Patchwork.h" + +#include +#include +#include +#include + +using namespace FFLD; +using namespace std; + +//image -> multiscale pyramid -> stitch to same-sized planes for Caffe convnet +//void stitch_pyramid(string file, Patchwork out_patchwork, int padding=8, int interval=10); +Patchwork stitch_pyramid(string file, int padding=8, int interval=10); + +#endif + diff --git a/python/caffe/stitch_pyramid/README.txt b/python/caffe/stitch_pyramid/README.txt new file mode 100644 index 00000000000..a5bd9bee703 --- /dev/null +++ b/python/caffe/stitch_pyramid/README.txt @@ -0,0 +1,29 @@ + + + +This is Forrest's hack to do the following... + +1. Input: image filename from PASCAL VOC detection challenge +2. sample multiscale +3. Output: stich multiscale onto same-sized planes. + (TODO: add a text file that explains where the images were placed in planes!) + + + saves something like this: + inputFilename_plane0.jpg + inputFilename_plane1.jpg + ... + +DONE: + find/replace NbFeatures for NbChannels. + set NbChannels=3 + + in Patchwork.{cpp, h}, change the definition of 'Plane' to JPEGImage + + in stitch_pyramid.cpp, call Patchwork(), with MaxRows_ and MaxCols_ as 'biggest pyra scale, rounded up to a factor of 16' + + add a JPEGImage::pad() function that creates a padded copy. + + in stitch_pyramid.cpp, replace {hog, HOG, Hog} to JPEG + + diff --git a/python/caffe/stitch_pyramid/Rectangle.cpp b/python/caffe/stitch_pyramid/Rectangle.cpp new file mode 100644 index 00000000000..ad2a3238fd1 --- /dev/null +++ b/python/caffe/stitch_pyramid/Rectangle.cpp @@ -0,0 +1,151 @@ +//-------------------------------------------------------------------------------------------------- +// Implementation of the paper "Exact Acceleration of Linear Object Detectors", 12th European +// Conference on Computer Vision, 2012. +// +// Copyright (c) 2012 Idiap Research Institute, +// Written by Charles Dubout +// +// This file is part of FFLD (the Fast Fourier Linear Detector) +// +// FFLD is free software: you can redistribute it and/or modify it under the terms of the GNU +// General Public License version 3 as published by the Free Software Foundation. +// +// FFLD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +// Public License for more details. +// +// You should have received a copy of the GNU General Public License along with FFLD. If not, see +// . +//-------------------------------------------------------------------------------------------------- + +#include "Rectangle.h" + +#include +#include + +using namespace FFLD; +using namespace std; + +Rectangle::Rectangle() : x_(0), y_(0), width_(0), height_(0) +{ +} + +Rectangle::Rectangle(int width, int height) : x_(0), y_(0), width_(width), height_(height) +{ +} + +Rectangle::Rectangle(int x, int y, int width, int height) : x_(x), y_(y), width_(width), +height_(height) +{ +} + +int Rectangle::x() const +{ + return x_; +} + +void Rectangle::setX(int x) +{ + x_ = x; +} + +int Rectangle::y() const +{ + return y_; +} + +void Rectangle::setY(int y) +{ + y_ = y; +} + +int Rectangle::width() const +{ + return width_; +} + +void Rectangle::setWidth(int width) +{ + width_ = width; +} + +int Rectangle::height() const +{ + return height_; +} + +void Rectangle::setHeight(int height) +{ + height_ = height; +} + +int Rectangle::left() const +{ + return x(); +} + +void Rectangle::setLeft(int left) +{ + setWidth(right() - left + 1); + setX(left); +} + +int Rectangle::top() const +{ + return y(); +} + +void Rectangle::setTop(int top) +{ + setHeight(bottom() - top + 1); + setY(top); +} + +int Rectangle::right() const +{ + return x() + width() - 1; +} + +void Rectangle::setRight(int right) +{ + setWidth(right - left() + 1); +} + +int Rectangle::bottom() const +{ + return y() + height() - 1; +} + +void Rectangle::setBottom(int bottom) +{ + setHeight(bottom - top() + 1); +} + +bool Rectangle::empty() const +{ + return (width() <= 0) || (height() <= 0); +} + +int Rectangle::area() const +{ + return max(width(), 0) * max(height(), 0); +} + +ostream & FFLD::operator<<(ostream & os, const Rectangle & rect) +{ + return os << rect.x() << ' ' << rect.y() << ' ' << rect.width() << ' ' << rect.height(); +} + +istream & FFLD::operator>>(istream & is, Rectangle & rect) +{ + int x, y, width, height; + + is >> x >> y >> width >> height; + + rect.setX(x); + rect.setY(y); + rect.setWidth(width); + rect.setHeight(height); + + return is; +} diff --git a/python/caffe/stitch_pyramid/Rectangle.h b/python/caffe/stitch_pyramid/Rectangle.h new file mode 100644 index 00000000000..404cac6d6c5 --- /dev/null +++ b/python/caffe/stitch_pyramid/Rectangle.h @@ -0,0 +1,121 @@ +//-------------------------------------------------------------------------------------------------- +// Implementation of the paper "Exact Acceleration of Linear Object Detectors", 12th European +// Conference on Computer Vision, 2012. +// +// Copyright (c) 2012 Idiap Research Institute, +// Written by Charles Dubout +// +// This file is part of FFLD (the Fast Fourier Linear Detector) +// +// FFLD is free software: you can redistribute it and/or modify it under the terms of the GNU +// General Public License version 3 as published by the Free Software Foundation. +// +// FFLD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +// Public License for more details. +// +// You should have received a copy of the GNU General Public License along with FFLD. If not, see +// . +//-------------------------------------------------------------------------------------------------- + +#ifndef FFLD_RECTANGLE_H +#define FFLD_RECTANGLE_H + +#include + +namespace FFLD +{ +/// The Rectangle class defines a rectangle in the plane using integer precision. If the coordinates +/// of the top left corner of the rectangle are (x, y), the coordinates of the bottom right corner +/// are (x + width - 1, y + height - 1), where width and height are the dimensions of the rectangle. +/// The corners are thus understood as the extremal points still inside the rectangle. +class Rectangle +{ +public: + /// Constructs an empty rectangle. An empty rectangle has no area. + Rectangle(); + + /// Constructs a rectangle with the given @p width and @p height. + Rectangle(int width, int height); + + /// Constructs a rectangle with coordinates (@p x, @p y) and the given @p width and @p height. + Rectangle(int x, int y, int width, int height); + + /// Returns the x-coordinate of the rectangle. + int x() const; + + /// Sets the x coordinate of the rectangle to @p x. + void setX(int x); + + /// Returns the y-coordinate of the rectangle. + int y() const; + + /// Sets the y coordinate of the rectangle to @p y. + void setY(int y); + + /// Returns the width of the rectangle. + int width() const; + + /// Sets the height of the rectangle to the given @p width. + void setWidth(int width); + + /// Returns the height of the rectangle. + int height() const; + + /// Sets the height of the rectangle to the given @p height. + void setHeight(int height); + + /// Returns the left side of the rectangle. + /// @note Equivalent to x(). + int left() const; + + /// Sets the left side of the rectangle to @p left. + /// @note The right side of the rectangle is not modified. + void setLeft(int left); + + /// Returns the top side of the rectangle. + /// @note Equivalent to y(). + int top() const; + + /// Sets the top side of the rectangle to @p top. + /// @note The bottom side of the rectangle is not modified. + void setTop(int top); + + /// Returns the right side of the rectangle. + /// @note Equivalent to x() + width() - 1. + int right() const; + + /// Sets the right side of the rectangle to @p right. + /// @note The left side of the rectangle is not modified. + void setRight(int right); + + /// Returns the bottom side of the rectangle. + /// @note Equivalent to y() + height() - 1. + int bottom() const; + + /// Sets the bottom side of the rectangle to @p bottom. + /// @note The top side of the rectangle is not modified. + void setBottom(int bottom); + + /// Returns whether the rectangle is empty. An empty rectangle has no area. + bool empty() const; + + /// Returns the area of the rectangle. + /// @note Equivalent to max(width(), 0) * max(height(), 0). + int area() const; + +private: + int x_; + int y_; + int width_; + int height_; +}; + +/// Serializes a rectangle to a stream. +std::ostream & operator<<(std::ostream & os, const Rectangle & rect); + +/// Unserializes a rectangle from a stream. +std::istream & operator>>(std::istream & is, Rectangle & rect); +} + +#endif diff --git a/python/caffe/stitch_pyramid/SimpleOpt.h b/python/caffe/stitch_pyramid/SimpleOpt.h new file mode 100644 index 00000000000..bc8d5525831 --- /dev/null +++ b/python/caffe/stitch_pyramid/SimpleOpt.h @@ -0,0 +1,1060 @@ +/*! @file SimpleOpt.h + + @version 3.5 + + @brief A cross-platform command line library which can parse almost any + of the standard command line formats in use today. It is designed + explicitly to be portable to any platform and has been tested on Windows + and Linux. See CSimpleOptTempl for the class definition. + + @section features FEATURES + + - MIT Licence allows free use in all software (including GPL + and commercial) + - multi-platform (Windows 95/98/ME/NT/2K/XP, Linux, Unix) + - supports all lengths of option names: + +
- + switch character only (e.g. use stdin for input) +
-o + short (single character) +
-long + long (multiple character, single switch character) +
--longer + long (multiple character, multiple switch characters) +
+ - supports all types of arguments for options: + +
--option + short/long option flag (no argument) +
--option ARG + short/long option with separate required argument +
--option=ARG + short/long option with combined required argument +
--option[=ARG] + short/long option with combined optional argument +
-oARG + short option with combined required argument +
-o[ARG] + short option with combined optional argument +
+ - supports options with multiple or variable numbers of arguments: + +
--multi ARG1 ARG2 + Multiple arguments +
--multi N ARG-1 ARG-2 ... ARG-N + Variable number of arguments +
+ - supports case-insensitive option matching on short, long and/or + word arguments. + - supports options which do not use a switch character. i.e. a special + word which is construed as an option. + e.g. "foo.exe open /directory/file.txt" + - supports clumping of multiple short options (no arguments) in a string + e.g. "foo.exe -abcdef file1" <==> "foo.exe -a -b -c -d -e -f file1" + - automatic recognition of a single slash as equivalent to a single + hyphen on Windows, e.g. "/f FILE" is equivalent to "-f FILE". + - file arguments can appear anywhere in the argument list: + "foo.exe file1.txt -a ARG file2.txt --flag file3.txt file4.txt" + files will be returned to the application in the same order they were + supplied on the command line + - short-circuit option matching: "--man" will match "--mandate" + invalid options can be handled while continuing to parse the command + line valid options list can be changed dynamically during command line + processing, i.e. accept different options depending on an option + supplied earlier in the command line. + - implemented with only a single C++ header file + - optionally use no C runtime or OS functions + - char, wchar_t and Windows TCHAR in the same program + - complete working examples included + - compiles cleanly at warning level 4 (Windows/VC.NET 2003), warning + level 3 (Windows/VC6) and -Wall (Linux/gcc) + + @section usage USAGE + + The SimpleOpt class is used by following these steps: + +
    +
  1. Include the SimpleOpt.h header file + +
    +        \#include "SimpleOpt.h"
    +        
    + +
  2. Define an array of valid options for your program. + +
    +@link CSimpleOptTempl::SOption CSimpleOpt::SOption @endlink g_rgOptions[] = {
    +    { OPT_FLAG, _T("-a"),     SO_NONE    }, // "-a"
    +    { OPT_FLAG, _T("-b"),     SO_NONE    }, // "-b"
    +    { OPT_ARG,  _T("-f"),     SO_REQ_SEP }, // "-f ARG"
    +    { OPT_HELP, _T("-?"),     SO_NONE    }, // "-?"
    +    { OPT_HELP, _T("--help"), SO_NONE    }, // "--help"
    +    SO_END_OF_OPTIONS                       // END
    +};
    +
    + + Note that all options must start with a hyphen even if the slash will + be accepted. This is because the slash character is automatically + converted into a hyphen to test against the list of options. + For example, the following line matches both "-?" and "/?" + (on Windows). + +
    +        { OPT_HELP, _T("-?"),     SO_NONE    }, // "-?"
    +        
    + +
  3. Instantiate a CSimpleOpt object supplying argc, argv and the option + table + +
    +@link CSimpleOptTempl CSimpleOpt @endlink args(argc, argv, g_rgOptions);
    +
    + +
  4. Process the arguments by calling Next() until it returns false. + On each call, first check for an error by calling LastError(), then + either handle the error or process the argument. + +
    +while (args.Next()) {
    +    if (args.LastError() == SO_SUCCESS) {
    +        handle option: use OptionId(), OptionText() and OptionArg()
    +    }
    +    else {
    +        handle error: see ESOError enums
    +    }
    +}
    +
    + +
  5. Process all non-option arguments with File(), Files() and FileCount() + +
    +ShowFiles(args.FileCount(), args.Files());
    +
    + +
+ + @section notes NOTES + + - In MBCS mode, this library is guaranteed to work correctly only when + all option names use only ASCII characters. + - Note that if case-insensitive matching is being used then the first + matching option in the argument list will be returned. + + @section licence MIT LICENCE + + The licence text below is the boilerplate "MIT Licence" used from: + http://www.opensource.org/licenses/mit-license.php + + Copyright (c) 2006-2007, Brodie Thiesfield + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +/*! @mainpage + + +
Library SimpleOpt +
Author Brodie Thiesfield [code at jellycan dot com] +
Source http://code.jellycan.com/simpleopt/ +
+ + @section SimpleOpt SimpleOpt + + A cross-platform library providing a simple method to parse almost any of + the standard command-line formats in use today. + + See the @link SimpleOpt.h SimpleOpt @endlink documentation for full + details. + + @section SimpleGlob SimpleGlob + + A cross-platform file globbing library providing the ability to + expand wildcards in command-line arguments to a list of all matching + files. + + See the @link SimpleGlob.h SimpleGlob @endlink documentation for full + details. +*/ + +#ifndef INCLUDED_SimpleOpt +#define INCLUDED_SimpleOpt + +// Default the max arguments to a fixed value. If you want to be able to +// handle any number of arguments, then predefine this to 0 and it will +// use an internal dynamically allocated buffer instead. +#ifdef SO_MAX_ARGS +# define SO_STATICBUF SO_MAX_ARGS +#else +# include // malloc, free +# include // memcpy +# define SO_STATICBUF 50 +#endif + +//! Error values +typedef enum _ESOError +{ + //! No error + SO_SUCCESS = 0, + + /*! It looks like an option (it starts with a switch character), but + it isn't registered in the option table. */ + SO_OPT_INVALID = -1, + + /*! Multiple options matched the supplied option text. + Only returned when NOT using SO_O_EXACT. */ + SO_OPT_MULTIPLE = -2, + + /*! Option doesn't take an argument, but a combined argument was + supplied. */ + SO_ARG_INVALID = -3, + + /*! SO_REQ_CMB style-argument was supplied to a SO_REQ_SEP option + Only returned when using SO_O_PEDANTIC. */ + SO_ARG_INVALID_TYPE = -4, + + //! Required argument was not supplied + SO_ARG_MISSING = -5, + + /*! Option argument looks like another option. + Only returned when NOT using SO_O_NOERR. */ + SO_ARG_INVALID_DATA = -6 +} ESOError; + +//! Option flags +enum _ESOFlags +{ + /*! Disallow partial matching of option names */ + SO_O_EXACT = 0x0001, + + /*! Disallow use of slash as an option marker on Windows. + Un*x only ever recognizes a hyphen. */ + SO_O_NOSLASH = 0x0002, + + /*! Permit arguments on single letter options with no equals sign. + e.g. -oARG or -o[ARG] */ + SO_O_SHORTARG = 0x0004, + + /*! Permit single character options to be clumped into a single + option string. e.g. "-a -b -c" <==> "-abc" */ + SO_O_CLUMP = 0x0008, + + /*! Process the entire argv array for options, including the + argv[0] entry. */ + SO_O_USEALL = 0x0010, + + /*! Do not generate an error for invalid options. errors for missing + arguments will still be generated. invalid options will be + treated as files. invalid options in clumps will be silently + ignored. */ + SO_O_NOERR = 0x0020, + + /*! Validate argument type pedantically. Return an error when a + separated argument "-opt arg" is supplied by the user as a + combined argument "-opt=arg". By default this is not considered + an error. */ + SO_O_PEDANTIC = 0x0040, + + /*! Case-insensitive comparisons for short arguments */ + SO_O_ICASE_SHORT = 0x0100, + + /*! Case-insensitive comparisons for long arguments */ + SO_O_ICASE_LONG = 0x0200, + + /*! Case-insensitive comparisons for word arguments + i.e. arguments without any hyphens at the start. */ + SO_O_ICASE_WORD = 0x0400, + + /*! Case-insensitive comparisons for all arg types */ + SO_O_ICASE = 0x0700 +}; + +/*! Types of arguments that options may have. Note that some of the _ESOFlags + are not compatible with all argument types. SO_O_SHORTARG requires that + relevant options use either SO_REQ_CMB or SO_OPT. SO_O_CLUMP requires + that relevant options use only SO_NONE. + */ +typedef enum _ESOArgType { + /*! No argument. Just the option flags. + e.g. -o --opt */ + SO_NONE, + + /*! Required separate argument. + e.g. -o ARG --opt ARG */ + SO_REQ_SEP, + + /*! Required combined argument. + e.g. -oARG -o=ARG --opt=ARG */ + SO_REQ_CMB, + + /*! Optional combined argument. + e.g. -o[ARG] -o[=ARG] --opt[=ARG] */ + SO_OPT, + + /*! Multiple separate arguments. The actual number of arguments is + determined programatically at the time the argument is processed. + e.g. -o N ARG1 ARG2 ... ARGN --opt N ARG1 ARG2 ... ARGN */ + SO_MULTI +} ESOArgType; + +//! this option definition must be the last entry in the table +#define SO_END_OF_OPTIONS { -1, NULL, SO_NONE } + +#ifdef _DEBUG +# ifdef _MSC_VER +# include +# define SO_ASSERT(b) _ASSERTE(b) +# else +# include +# define SO_ASSERT(b) assert(b) +# endif +#else +# define SO_ASSERT(b) //!< assertion used to test input data +#endif + +// --------------------------------------------------------------------------- +// MAIN TEMPLATE CLASS +// --------------------------------------------------------------------------- + +/*! @brief Implementation of the SimpleOpt class */ +template +class CSimpleOptTempl +{ +public: + /*! @brief Structure used to define all known options. */ + struct SOption { + /*! ID to return for this flag. Optional but must be >= 0 */ + int nId; + + /*! arg string to search for, e.g. "open", "-", "-f", "--file" + Note that on Windows the slash option marker will be converted + to a hyphen so that "-f" will also match "/f". */ + const SOCHAR * pszArg; + + /*! type of argument accepted by this option */ + ESOArgType nArgType; + }; + + /*! @brief Initialize the class. Init() must be called later. */ + CSimpleOptTempl() + : m_rgShuffleBuf(NULL) + { + Init(0, NULL, NULL, 0); + } + + /*! @brief Initialize the class in preparation for use. */ + CSimpleOptTempl( + int argc, + SOCHAR * argv[], + const SOption * a_rgOptions, + int a_nFlags = 0 + ) + : m_rgShuffleBuf(NULL) + { + Init(argc, argv, a_rgOptions, a_nFlags); + } + +#ifndef SO_MAX_ARGS + /*! @brief Deallocate any allocated memory. */ + ~CSimpleOptTempl() { if (m_rgShuffleBuf) free(m_rgShuffleBuf); } +#endif + + /*! @brief Initialize the class in preparation for calling Next. + + The table of options pointed to by a_rgOptions does not need to be + valid at the time that Init() is called. However on every call to + Next() the table pointed to must be a valid options table with the + last valid entry set to SO_END_OF_OPTIONS. + + NOTE: the array pointed to by a_argv will be modified by this + class and must not be used or modified outside of member calls to + this class. + + @param a_argc Argument array size + @param a_argv Argument array + @param a_rgOptions Valid option array + @param a_nFlags Optional flags to modify the processing of + the arguments + + @return true Successful + @return false if SO_MAX_ARGC > 0: Too many arguments + if SO_MAX_ARGC == 0: Memory allocation failure + */ + bool Init( + int a_argc, + SOCHAR * a_argv[], + const SOption * a_rgOptions, + int a_nFlags = 0 + ); + + /*! @brief Change the current options table during option parsing. + + @param a_rgOptions Valid option array + */ + inline void SetOptions(const SOption * a_rgOptions) { + m_rgOptions = a_rgOptions; + } + + /*! @brief Change the current flags during option parsing. + + Note that changing the SO_O_USEALL flag here will have no affect. + It must be set using Init() or the constructor. + + @param a_nFlags Flags to modify the processing of the arguments + */ + inline void SetFlags(int a_nFlags) { m_nFlags = a_nFlags; } + + /*! @brief Query if a particular flag is set */ + inline bool HasFlag(int a_nFlag) const { + return (m_nFlags & a_nFlag) == a_nFlag; + } + + /*! @brief Advance to the next option if available. + + When all options have been processed it will return false. When true + has been returned, you must check for an invalid or unrecognized + option using the LastError() method. This will be return an error + value other than SO_SUCCESS on an error. All standard data + (e.g. OptionText(), OptionArg(), OptionId(), etc) will be available + depending on the error. + + After all options have been processed, the remaining files from the + command line can be processed in same order as they were passed to + the program. + + @return true option or error available for processing + @return false all options have been processed + */ + bool Next(); + + /*! Stops processing of the command line and returns all remaining + arguments as files. The next call to Next() will return false. + */ + void Stop(); + + /*! @brief Return the last error that occurred. + + This function must always be called before processing the current + option. This function is available only when Next() has returned true. + */ + inline ESOError LastError() const { return m_nLastError; } + + /*! @brief Return the nId value from the options array for the current + option. + + This function is available only when Next() has returned true. + */ + inline int OptionId() const { return m_nOptionId; } + + /*! @brief Return the pszArg from the options array for the current + option. + + This function is available only when Next() has returned true. + */ + inline const SOCHAR * OptionText() const { return m_pszOptionText; } + + /*! @brief Return the argument for the current option where one exists. + + If there is no argument for the option, this will return NULL. + This function is available only when Next() has returned true. + */ + inline SOCHAR * OptionArg() const { return m_pszOptionArg; } + + /*! @brief Validate and return the desired number of arguments. + + This is only valid when OptionId() has return the ID of an option + that is registered as SO_MULTI. It may be called multiple times + each time returning the desired number of arguments. Previously + returned argument pointers are remain valid. + + If an error occurs during processing, NULL will be returned and + the error will be available via LastError(). + + @param n Number of arguments to return. + */ + SOCHAR ** MultiArg(int n); + + /*! @brief Returned the number of entries in the Files() array. + + After Next() has returned false, this will be the list of files (or + otherwise unprocessed arguments). + */ + inline int FileCount() const { return m_argc - m_nLastArg; } + + /*! @brief Return the specified file argument. + + @param n Index of the file to return. This must be between 0 + and FileCount() - 1; + */ + inline SOCHAR * File(int n) const { + SO_ASSERT(n >= 0 && n < FileCount()); + return m_argv[m_nLastArg + n]; + } + + /*! @brief Return the array of files. */ + inline SOCHAR ** Files() const { return &m_argv[m_nLastArg]; } + +private: + CSimpleOptTempl(const CSimpleOptTempl &); // disabled + CSimpleOptTempl & operator=(const CSimpleOptTempl &); // disabled + + SOCHAR PrepareArg(SOCHAR * a_pszString) const; + bool NextClumped(); + void ShuffleArg(int a_nStartIdx, int a_nCount); + int LookupOption(const SOCHAR * a_pszOption) const; + int CalcMatch(const SOCHAR *a_pszSource, const SOCHAR *a_pszTest) const; + + // Find the '=' character within a string. + inline SOCHAR * FindEquals(SOCHAR *s) const { + while (*s && *s != (SOCHAR)'=') ++s; + return *s ? s : NULL; + } + bool IsEqual(SOCHAR a_cLeft, SOCHAR a_cRight, int a_nArgType) const; + + inline void Copy(SOCHAR ** ppDst, SOCHAR ** ppSrc, int nCount) const { +#ifdef SO_MAX_ARGS + // keep our promise of no CLIB usage + while (nCount-- > 0) *ppDst++ = *ppSrc++; +#else + memcpy(ppDst, ppSrc, nCount * sizeof(SOCHAR*)); +#endif + } + +private: + const SOption * m_rgOptions; //!< pointer to options table + int m_nFlags; //!< flags + int m_nOptionIdx; //!< current argv option index + int m_nOptionId; //!< id of current option (-1 = invalid) + int m_nNextOption; //!< index of next option + int m_nLastArg; //!< last argument, after this are files + int m_argc; //!< argc to process + SOCHAR ** m_argv; //!< argv + const SOCHAR * m_pszOptionText; //!< curr option text, e.g. "-f" + SOCHAR * m_pszOptionArg; //!< curr option arg, e.g. "c:\file.txt" + SOCHAR * m_pszClump; //!< clumped single character options + SOCHAR m_szShort[3]; //!< temp for clump and combined args + ESOError m_nLastError; //!< error status from the last call + SOCHAR ** m_rgShuffleBuf; //!< shuffle buffer for large argc +}; + +// --------------------------------------------------------------------------- +// IMPLEMENTATION +// --------------------------------------------------------------------------- + +template +bool +CSimpleOptTempl::Init( + int a_argc, + SOCHAR * a_argv[], + const SOption * a_rgOptions, + int a_nFlags + ) +{ + m_argc = a_argc; + m_nLastArg = a_argc; + m_argv = a_argv; + m_rgOptions = a_rgOptions; + m_nLastError = SO_SUCCESS; + m_nOptionIdx = 0; + m_nOptionId = -1; + m_pszOptionText = NULL; + m_pszOptionArg = NULL; + m_nNextOption = (a_nFlags & SO_O_USEALL) ? 0 : 1; + m_szShort[0] = (SOCHAR)'-'; + m_szShort[2] = (SOCHAR)'\0'; + m_nFlags = a_nFlags; + m_pszClump = NULL; + +#ifdef SO_MAX_ARGS + if (m_argc > SO_MAX_ARGS) { + m_nLastError = SO_ARG_INVALID_DATA; + m_nLastArg = 0; + return false; + } +#else + if (m_rgShuffleBuf) { + free(m_rgShuffleBuf); + } + if (m_argc > SO_STATICBUF) { + m_rgShuffleBuf = (SOCHAR**) malloc(sizeof(SOCHAR*) * m_argc); + if (!m_rgShuffleBuf) { + return false; + } + } +#endif + + return true; +} + +template +bool +CSimpleOptTempl::Next() +{ +#ifdef SO_MAX_ARGS + if (m_argc > SO_MAX_ARGS) { + SO_ASSERT(!"Too many args! Check the return value of Init()!"); + return false; + } +#endif + + // process a clumped option string if appropriate + if (m_pszClump && *m_pszClump) { + // silently discard invalid clumped option + bool bIsValid = NextClumped(); + while (*m_pszClump && !bIsValid && HasFlag(SO_O_NOERR)) { + bIsValid = NextClumped(); + } + + // return this option if valid or we are returning errors + if (bIsValid || !HasFlag(SO_O_NOERR)) { + return true; + } + } + SO_ASSERT(!m_pszClump || !*m_pszClump); + m_pszClump = NULL; + + // init for the next option + m_nOptionIdx = m_nNextOption; + m_nOptionId = -1; + m_pszOptionText = NULL; + m_pszOptionArg = NULL; + m_nLastError = SO_SUCCESS; + + // find the next option + SOCHAR cFirst; + int nTableIdx = -1; + int nOptIdx = m_nOptionIdx; + while (nTableIdx < 0 && nOptIdx < m_nLastArg) { + SOCHAR * pszArg = m_argv[nOptIdx]; + m_pszOptionArg = NULL; + + // find this option in the options table + cFirst = PrepareArg(pszArg); + if (pszArg[0] == (SOCHAR)'-') { + // find any combined argument string and remove equals sign + m_pszOptionArg = FindEquals(pszArg); + if (m_pszOptionArg) { + *m_pszOptionArg++ = (SOCHAR)'\0'; + } + } + nTableIdx = LookupOption(pszArg); + + // if we didn't find this option but if it is a short form + // option then we try the alternative forms + if (nTableIdx < 0 + && !m_pszOptionArg + && pszArg[0] == (SOCHAR)'-' + && pszArg[1] + && pszArg[1] != (SOCHAR)'-' + && pszArg[2]) + { + // test for a short-form with argument if appropriate + if (HasFlag(SO_O_SHORTARG)) { + m_szShort[1] = pszArg[1]; + int nIdx = LookupOption(m_szShort); + if (nIdx >= 0 + && (m_rgOptions[nIdx].nArgType == SO_REQ_CMB + || m_rgOptions[nIdx].nArgType == SO_OPT)) + { + m_pszOptionArg = &pszArg[2]; + pszArg = m_szShort; + nTableIdx = nIdx; + } + } + + // test for a clumped short-form option string and we didn't + // match on the short-form argument above + if (nTableIdx < 0 && HasFlag(SO_O_CLUMP)) { + m_pszClump = &pszArg[1]; + ++m_nNextOption; + if (nOptIdx > m_nOptionIdx) { + ShuffleArg(m_nOptionIdx, nOptIdx - m_nOptionIdx); + } + return Next(); + } + } + + // The option wasn't found. If it starts with a switch character + // and we are not suppressing errors for invalid options then it + // is reported as an error, otherwise it is data. + if (nTableIdx < 0) { + if (!HasFlag(SO_O_NOERR) && pszArg[0] == (SOCHAR)'-') { + m_pszOptionText = pszArg; + break; + } + + pszArg[0] = cFirst; + ++nOptIdx; + if (m_pszOptionArg) { + *(--m_pszOptionArg) = (SOCHAR)'='; + } + } + } + + // end of options + if (nOptIdx >= m_nLastArg) { + if (nOptIdx > m_nOptionIdx) { + ShuffleArg(m_nOptionIdx, nOptIdx - m_nOptionIdx); + } + return false; + } + ++m_nNextOption; + + // get the option id + ESOArgType nArgType = SO_NONE; + if (nTableIdx < 0) { + m_nLastError = (ESOError) nTableIdx; // error code + } + else { + m_nOptionId = m_rgOptions[nTableIdx].nId; + m_pszOptionText = m_rgOptions[nTableIdx].pszArg; + + // ensure that the arg type is valid + nArgType = m_rgOptions[nTableIdx].nArgType; + switch (nArgType) { + case SO_NONE: + if (m_pszOptionArg) { + m_nLastError = SO_ARG_INVALID; + } + break; + + case SO_REQ_SEP: + if (m_pszOptionArg) { + // they wanted separate args, but we got a combined one, + // unless we are pedantic, just accept it. + if (HasFlag(SO_O_PEDANTIC)) { + m_nLastError = SO_ARG_INVALID_TYPE; + } + } + // more processing after we shuffle + break; + + case SO_REQ_CMB: + if (!m_pszOptionArg) { + m_nLastError = SO_ARG_MISSING; + } + break; + + case SO_OPT: + // nothing to do + break; + + case SO_MULTI: + // nothing to do. Caller must now check for valid arguments + // using GetMultiArg() + break; + } + } + + // shuffle the files out of the way + if (nOptIdx > m_nOptionIdx) { + ShuffleArg(m_nOptionIdx, nOptIdx - m_nOptionIdx); + } + + // we need to return the separate arg if required, just re-use the + // multi-arg code because it all does the same thing + if ( nArgType == SO_REQ_SEP + && !m_pszOptionArg + && m_nLastError == SO_SUCCESS) + { + SOCHAR ** ppArgs = MultiArg(1); + if (ppArgs) { + m_pszOptionArg = *ppArgs; + } + } + + return true; +} + +template +void +CSimpleOptTempl::Stop() +{ + if (m_nNextOption < m_nLastArg) { + ShuffleArg(m_nNextOption, m_nLastArg - m_nNextOption); + } +} + +template +SOCHAR +CSimpleOptTempl::PrepareArg( + SOCHAR * a_pszString + ) const +{ +#ifdef _WIN32 + // On Windows we can accept the forward slash as a single character + // option delimiter, but it cannot replace the '-' option used to + // denote stdin. On Un*x paths may start with slash so it may not + // be used to start an option. + if (!HasFlag(SO_O_NOSLASH) + && a_pszString[0] == (SOCHAR)'/' + && a_pszString[1] + && a_pszString[1] != (SOCHAR)'-') + { + a_pszString[0] = (SOCHAR)'-'; + return (SOCHAR)'/'; + } +#endif + return a_pszString[0]; +} + +template +bool +CSimpleOptTempl::NextClumped() +{ + // prepare for the next clumped option + m_szShort[1] = *m_pszClump++; + m_nOptionId = -1; + m_pszOptionText = NULL; + m_pszOptionArg = NULL; + m_nLastError = SO_SUCCESS; + + // lookup this option, ensure that we are using exact matching + int nSavedFlags = m_nFlags; + m_nFlags = SO_O_EXACT; + int nTableIdx = LookupOption(m_szShort); + m_nFlags = nSavedFlags; + + // unknown option + if (nTableIdx < 0) { + m_nLastError = (ESOError) nTableIdx; // error code + return false; + } + + // valid option + m_pszOptionText = m_rgOptions[nTableIdx].pszArg; + ESOArgType nArgType = m_rgOptions[nTableIdx].nArgType; + if (nArgType == SO_NONE) { + m_nOptionId = m_rgOptions[nTableIdx].nId; + return true; + } + + if (nArgType == SO_REQ_CMB && *m_pszClump) { + m_nOptionId = m_rgOptions[nTableIdx].nId; + m_pszOptionArg = m_pszClump; + while (*m_pszClump) ++m_pszClump; // must point to an empty string + return true; + } + + // invalid option as it requires an argument + m_nLastError = SO_ARG_MISSING; + return true; +} + +// Shuffle arguments to the end of the argv array. +// +// For example: +// argv[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8" }; +// +// ShuffleArg(1, 1) = { "0", "2", "3", "4", "5", "6", "7", "8", "1" }; +// ShuffleArg(5, 2) = { "0", "1", "2", "3", "4", "7", "8", "5", "6" }; +// ShuffleArg(2, 4) = { "0", "1", "6", "7", "8", "2", "3", "4", "5" }; +template +void +CSimpleOptTempl::ShuffleArg( + int a_nStartIdx, + int a_nCount + ) +{ + SOCHAR * staticBuf[SO_STATICBUF]; + SOCHAR ** buf = m_rgShuffleBuf ? m_rgShuffleBuf : staticBuf; + int nTail = m_argc - a_nStartIdx - a_nCount; + + // make a copy of the elements to be moved + Copy(buf, m_argv + a_nStartIdx, a_nCount); + + // move the tail down + Copy(m_argv + a_nStartIdx, m_argv + a_nStartIdx + a_nCount, nTail); + + // append the moved elements to the tail + Copy(m_argv + a_nStartIdx + nTail, buf, a_nCount); + + // update the index of the last unshuffled arg + m_nLastArg -= a_nCount; +} + +// match on the long format strings. partial matches will be +// accepted only if that feature is enabled. +template +int +CSimpleOptTempl::LookupOption( + const SOCHAR * a_pszOption + ) const +{ + int nBestMatch = -1; // index of best match so far + int nBestMatchLen = 0; // matching characters of best match + int nLastMatchLen = 0; // matching characters of last best match + + for (int n = 0; m_rgOptions[n].nId >= 0; ++n) { + // the option table must use hyphens as the option character, + // the slash character is converted to a hyphen for testing. + SO_ASSERT(m_rgOptions[n].pszArg[0] != (SOCHAR)'/'); + + int nMatchLen = CalcMatch(m_rgOptions[n].pszArg, a_pszOption); + if (nMatchLen == -1) { + return n; + } + if (nMatchLen > 0 && nMatchLen >= nBestMatchLen) { + nLastMatchLen = nBestMatchLen; + nBestMatchLen = nMatchLen; + nBestMatch = n; + } + } + + // only partial matches or no match gets to here, ensure that we + // don't return a partial match unless it is a clear winner + if (HasFlag(SO_O_EXACT) || nBestMatch == -1) { + return SO_OPT_INVALID; + } + return (nBestMatchLen > nLastMatchLen) ? nBestMatch : SO_OPT_MULTIPLE; +} + +// calculate the number of characters that match (case-sensitive) +// 0 = no match, > 0 == number of characters, -1 == perfect match +template +int +CSimpleOptTempl::CalcMatch( + const SOCHAR * a_pszSource, + const SOCHAR * a_pszTest + ) const +{ + if (!a_pszSource || !a_pszTest) { + return 0; + } + + // determine the argument type + int nArgType = SO_O_ICASE_LONG; + if (a_pszSource[0] != '-') { + nArgType = SO_O_ICASE_WORD; + } + else if (a_pszSource[1] != '-' && !a_pszSource[2]) { + nArgType = SO_O_ICASE_SHORT; + } + + // match and skip leading hyphens + while (*a_pszSource == (SOCHAR)'-' && *a_pszSource == *a_pszTest) { + ++a_pszSource; + ++a_pszTest; + } + if (*a_pszSource == (SOCHAR)'-' || *a_pszTest == (SOCHAR)'-') { + return 0; + } + + // find matching number of characters in the strings + int nLen = 0; + while (*a_pszSource && IsEqual(*a_pszSource, *a_pszTest, nArgType)) { + ++a_pszSource; + ++a_pszTest; + ++nLen; + } + + // if we have exhausted the source... + if (!*a_pszSource) { + // and the test strings, then it's a perfect match + if (!*a_pszTest) { + return -1; + } + + // otherwise the match failed as the test is longer than + // the source. i.e. "--mant" will not match the option "--man". + return 0; + } + + // if we haven't exhausted the test string then it is not a match + // i.e. "--mantle" will not best-fit match to "--mandate" at all. + if (*a_pszTest) { + return 0; + } + + // partial match to the current length of the test string + return nLen; +} + +template +bool +CSimpleOptTempl::IsEqual( + SOCHAR a_cLeft, + SOCHAR a_cRight, + int a_nArgType + ) const +{ + // if this matches then we are doing case-insensitive matching + if (m_nFlags & a_nArgType) { + if (a_cLeft >= 'A' && a_cLeft <= 'Z') a_cLeft += 'a' - 'A'; + if (a_cRight >= 'A' && a_cRight <= 'Z') a_cRight += 'a' - 'A'; + } + return a_cLeft == a_cRight; +} + +// calculate the number of characters that match (case-sensitive) +// 0 = no match, > 0 == number of characters, -1 == perfect match +template +SOCHAR ** +CSimpleOptTempl::MultiArg( + int a_nCount + ) +{ + // ensure we have enough arguments + if (m_nNextOption + a_nCount > m_nLastArg) { + m_nLastError = SO_ARG_MISSING; + return NULL; + } + + // our argument array + SOCHAR ** rgpszArg = &m_argv[m_nNextOption]; + + // Ensure that each of the following don't start with an switch character. + // Only make this check if we are returning errors for unknown arguments. + if (!HasFlag(SO_O_NOERR)) { + for (int n = 0; n < a_nCount; ++n) { + SOCHAR ch = PrepareArg(rgpszArg[n]); + if (rgpszArg[n][0] == (SOCHAR)'-') { + rgpszArg[n][0] = ch; + m_nLastError = SO_ARG_INVALID_DATA; + return NULL; + } + rgpszArg[n][0] = ch; + } + } + + // all good + m_nNextOption += a_nCount; + return rgpszArg; +} + + +// --------------------------------------------------------------------------- +// TYPE DEFINITIONS +// --------------------------------------------------------------------------- + +/*! @brief ASCII/MBCS version of CSimpleOpt */ +typedef CSimpleOptTempl CSimpleOptA; + +/*! @brief wchar_t version of CSimpleOpt */ +typedef CSimpleOptTempl CSimpleOptW; + +#if defined(_UNICODE) +/*! @brief TCHAR version dependent on if _UNICODE is defined */ +# define CSimpleOpt CSimpleOptW +#else +/*! @brief TCHAR version dependent on if _UNICODE is defined */ +# define CSimpleOpt CSimpleOptA +#endif + +#endif // INCLUDED_SimpleOpt diff --git a/python/caffe/stitch_pyramid/build/Makefile b/python/caffe/stitch_pyramid/build/Makefile new file mode 100644 index 00000000000..ba87dad3e55 --- /dev/null +++ b/python/caffe/stitch_pyramid/build/Makefile @@ -0,0 +1,50 @@ +CXX = g++ +CFLAGS = -g -fopenmp -O3 -fPIC -I/usr/local/include/ -I.. +LDLIBS = -g -lgomp -ljpeg +#OBJS = JPEGPyramid.o JPEGImage.o Patchwork.o Rectangle.o PyramidStitcher.o test_stitch_pyramid.o +OBJS = JPEGPyramid.o JPEGImage.o Patchwork.o Rectangle.o PyramidStitcher.o +all: libPyramidStitcher.so test_stitch_pyramid +#all: libPyramidStitcher.so libPyramidStitcher.a test_stitch_pyramid + +# *** test suite *** + +# dynamic link option +test_stitch_pyramid: test_stitch_pyramid.o libPyramidStitcher.so + $(CXX) -o test_stitch_pyramid test_stitch_pyramid.o -lPyramidStitcher $(LDLIBS) + +# static link option (doesn't like static build w/ openmp) +#test_stitch_pyramid: test_stitch_pyramid.o libPyramidStitcher.a +# $(CXX) -o test_stitch_pyramid test_stitch_pyramid.o -lPyramidStitcher $(LDLIBS) + +# OLD: link directly with .o files instead of linking with PyramidStitcher.so +#test_stitch_pyramid: $(OBJS) +# $(CXX) -o test_stitch_pyramid $(OBJS) $(LDLIBS) + +test_stitch_pyramid.o: ../test_stitch_pyramid.cpp ../PyramidStitcher.h ../JPEGPyramid.h ../JPEGImage.h ../Patchwork.h + $(CXX) $(CFLAGS) -c ../test_stitch_pyramid.cpp + +# *** build deployable shared object binary *** +libPyramidStitcher.so: $(OBJS) + $(CXX) $(OBJS) -shared -o libPyramidStitcher.so $(LDLIBS) + +libPyramidStitcher.a: $(OBJS) + $(CXX) $(OBJS) -static -o libPyramidStitcher.a $(LDLIBS) + +PyramidStitcher.o: ../PyramidStitcher.cpp ../PyramidStitcher.h ../JPEGPyramid.h ../JPEGImage.h ../Patchwork.h + $(CXX) $(CFLAGS) -c ../PyramidStitcher.cpp + +JPEGPyramid.o: ../JPEGPyramid.cpp ../JPEGPyramid.h ../JPEGImage.h + $(CXX) $(CFLAGS) -c ../JPEGPyramid.cpp + +JPEGImage.o: ../JPEGImage.cpp ../JPEGImage.h + $(CXX) $(CFLAGS) -c ../JPEGImage.cpp + +Patchwork.o: ../Patchwork.cpp ../Patchwork.h ../JPEGPyramid.h ../Rectangle.h + $(CXX) $(CFLAGS) -c ../Patchwork.cpp + +Rectangle.o: ../Rectangle.cpp ../Rectangle.h + $(CXX) $(CFLAGS) -c ../Rectangle.cpp + +clean: + rm -f *~ *.so *.o *.mex* *.obj + diff --git a/python/caffe/stitch_pyramid/build/demo.sh b/python/caffe/stitch_pyramid/build/demo.sh new file mode 100755 index 00000000000..73605577871 --- /dev/null +++ b/python/caffe/stitch_pyramid/build/demo.sh @@ -0,0 +1,5 @@ +#./stitch_pyramid ../../../images_640x480/carsgraz_001.image.jpg +#./stitch_pyramid --padding 8 ../../images_640x480/carsgraz_001.image.jpg + +./test_stitch_pyramid --padding 8 --output-stitched-dir ./stitched_results ../../imagenet/pascal_009959.jpg + diff --git a/python/caffe/stitch_pyramid/build/stitch_pyramid_pascal.sh b/python/caffe/stitch_pyramid/build/stitch_pyramid_pascal.sh new file mode 100755 index 00000000000..d4675d437da --- /dev/null +++ b/python/caffe/stitch_pyramid/build/stitch_pyramid_pascal.sh @@ -0,0 +1,21 @@ +#./stitch_pyramid ../../../images_640x480/carsgraz_001.image.jpg +#./stitch_pyramid --padding 8 ../../images_640x480/carsgraz_001.image.jpg + +VOC_DIR=/media/big_disk/VOC2007/VOCdevkit/VOC2007 +INPUT_DIR=$VOC_DIR/JPEGImages +OUTPUT_DIR=$VOC_DIR/JPEGImages_stitched_pyramid + +#example... +#./stitch_pyramid --padding 8 --output-stitched-dir $OUTPUT_DIR ../../images_640x480/carsgraz_001.image.jpg + +for input_img in $INPUT_DIR/*jpg +do + + #padding=8 + #output-stitched-dir=OUTPUT_DIR + #input=input_img + ./stitch_pyramid --padding 8 --output-stitched-dir $OUTPUT_DIR $input_img + +done + + diff --git a/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp b/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp new file mode 100644 index 00000000000..c5ce63c48f8 --- /dev/null +++ b/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp @@ -0,0 +1,198 @@ + +#include "SimpleOpt.h" +#include "JPEGPyramid.h" +#include "JPEGImage.h" +#include "Patchwork.h" +#include "PyramidStitcher.h" + +#include +#include +#include +#include +#include + +using namespace FFLD; +using namespace std; + +// SimpleOpt array of valid options +enum +{ + OPT_HELP, OPT_PADDING, OPT_INTERVAL, OPT_OUTPUT_STITCHED_DIR +}; + +CSimpleOpt::SOption SOptions[] = +{ + { OPT_HELP, "-h", SO_NONE }, + { OPT_HELP, "--help", SO_NONE }, + { OPT_PADDING, "-p", SO_REQ_SEP }, + { OPT_PADDING, "--padding", SO_REQ_SEP }, + { OPT_INTERVAL, "-e", SO_REQ_SEP }, + { OPT_INTERVAL, "--interval", SO_REQ_SEP }, + { OPT_OUTPUT_STITCHED_DIR, "--output-stitched-dir", SO_REQ_SEP }, + SO_END_OF_OPTIONS +}; + +void showUsage(){ + cout << "Usage: test [options] image.jpg, or\n test [options] image_set.txt\n\n" + "Options:\n" + " -h,--help Display this information\n" + " -p,--padding Amount of zero padding in JPEG images (default 8)\n" + " -e,--interval Number of levels per octave in the JPEG pyramid (default 10)\n" + " --output-stitched-dir Where to save stitched pyramids (default ../stitched_results)\n" + << endl; +} + +// Parse command line parameters +// put the appropriate values in (padding, interval, file) based on cmd-line args +void parseArgs(int &padding, int &interval, string &file, string &output_stitched_dir, int argc, char * argv[]){ + CSimpleOpt args(argc, argv, SOptions); + + while (args.Next()) { + if (args.LastError() == SO_SUCCESS) { + if (args.OptionId() == OPT_HELP) { + showUsage(); + exit(0); + } + else if (args.OptionId() == OPT_PADDING) { + padding = atoi(args.OptionArg()); + + // Error checking + if (padding <= 1) { + showUsage(); + cerr << "\nInvalid padding arg " << args.OptionArg() << endl; + exit(1); + } + } + else if (args.OptionId() == OPT_INTERVAL) { + interval = atoi(args.OptionArg()); + + // Error checking + if (interval <= 0) { + showUsage(); + cerr << "\nInvalid interval arg " << args.OptionArg() << endl; + exit(1); + } + } + else if (args.OptionId() == OPT_OUTPUT_STITCHED_DIR) { + output_stitched_dir = args.OptionArg(); + } + } + else { + showUsage(); + cerr << "\nUnknown option " << args.OptionText() << endl; + exit(1); + } + } + if (!args.FileCount()) { + showUsage(); + cerr << "\nNo image/dataset provided" << endl; + exit(1); + } + else if (args.FileCount() > 1) { + showUsage(); + cerr << "\nMore than one image/dataset provided" << endl; + exit(1); + } + + // The image/dataset + file = args.File(0); + const size_t lastDot = file.find_last_of('.'); + if ((lastDot == string::npos) || + ((file.substr(lastDot) != ".jpg") && (file.substr(lastDot) != ".txt"))) { + showUsage(); + cerr << "\nInvalid file " << file << ", should be .jpg or .txt" << endl; + exit(1); + } + + // Try to load the image + if (file.substr(lastDot) != ".jpg") { + cout << "need to input a JPG image" << endl; + exit(1); + } +} + +//e.g. file = ../../images_640x480/carsgraz_001.image.jpg +void TEST_file_parsing(string file){ + size_t lastSlash = file.find_last_of("/\\"); + size_t lastDot = file.find_last_of('.'); + cout << " file.substr(lastDot) = " << file.substr(lastDot) << endl; // .jpg + cout << " file.substr(lastSlash) = " << file.substr(lastSlash) << endl; // /carsgraz_001.image.jpg + cout << " file.substr(lastSlash, lastDot) = " << file.substr(lastSlash, lastDot-lastSlash) << endl; // /carsgraz_001.image +} + +//e.g. file = ../../images_640x480/carsgraz_001.image.jpg +string parse_base_filename(string file){ + size_t lastSlash = file.find_last_of("/\\"); + size_t lastDot = file.find_last_of('.'); + + string base_filename = file.substr(lastSlash, lastDot-lastSlash); // /carsgraz_001.image + return base_filename; +} + +void printScaleSizes(JPEGPyramid pyramid); +void writePyraToJPG(JPEGPyramid pyramid); +void writePatchworkToJPG(Patchwork patchwork, string output_stitched_dir, string base_filename); + +//TODO: split this test into its own function, e.g. test_stitch_pyramid() +int main(int argc, char * argv[]){ + + // Default parameters + string file; + string output_stitched_dir = "../stitched_results"; + int padding = 8; + int interval = 10; + + //parseArgs params are passed by reference, so they get updated here + parseArgs(padding, interval, file, output_stitched_dir, argc, argv); //update parameters with any command-line inputs + string base_filename = parse_base_filename(file); + + printf(" padding = %d \n", padding); + printf(" interval = %d \n", interval); + printf(" file = %s \n", file.c_str()); + printf(" base_filename = %s \n", base_filename.c_str()); + printf(" output_stitched_dir = %s \n", output_stitched_dir.c_str()); + + Patchwork patchwork = stitch_pyramid(file, padding, interval); + //printScaleSizes(pyramid); + //writePyraToJPG(pyramid); + writePatchworkToJPG(patchwork, output_stitched_dir, base_filename); //outputs to output_stitched_dir/base_filename_[planeID].jpg + + return EXIT_SUCCESS; +} + +void printScaleSizes(JPEGPyramid pyramid){ + int nlevels = pyramid.levels().size(); + + for(int level = 0; level < nlevels; level++){ + int width = pyramid.levels()[level].width(); + int height = pyramid.levels()[level].height(); + int depth = pyramid.NbChannels; + printf(" level %d: width=%d, height=%d, depth=%d \n", level, width, height, depth); + } +} + +//assumes NbChannels == 3 +void writePyraToJPG(JPEGPyramid pyramid){ + int nlevels = pyramid.levels().size(); + + for(int level = 0; level < nlevels; level++){ + ostringstream fname; + fname << "../pyra_results/level" << level << ".jpg"; //TODO: get orig img name into the JPEG name. + //cout << fname.str() << endl; + + pyramid.levels()[level].save(fname.str()); + } +} + +void writePatchworkToJPG(Patchwork patchwork, string output_stitched_dir, string base_filename){ + int nplanes = patchwork.planes_.size(); + + for(int planeID = 0; planeID < nplanes; planeID++){ + ostringstream fname; + fname << output_stitched_dir << "/" << base_filename << "_plane" << planeID << ".jpg"; + //cout << fname.str() << endl; + + patchwork.planes_[planeID].save(fname.str()); + } +} + From 176b0cc50a5d8b6c2f8fd70267c789f4b822baa5 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 13 Mar 2014 17:19:34 -0700 Subject: [PATCH 02/92] add DenseNet prototxt files (from the future, without padding layers) --- ...ch_1_input_1100x1100_output_conv5.prototxt | 208 ++++++++++++++++++ ...ch_1_input_2000x2000_output_conv5.prototxt | 208 ++++++++++++++++++ 2 files changed, 416 insertions(+) create mode 100644 python/caffe/imagenet/imagenet_rcnn_batch_1_input_1100x1100_output_conv5.prototxt create mode 100644 python/caffe/imagenet/imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt diff --git a/python/caffe/imagenet/imagenet_rcnn_batch_1_input_1100x1100_output_conv5.prototxt b/python/caffe/imagenet/imagenet_rcnn_batch_1_input_1100x1100_output_conv5.prototxt new file mode 100644 index 00000000000..064dd1cd3ab --- /dev/null +++ b/python/caffe/imagenet/imagenet_rcnn_batch_1_input_1100x1100_output_conv5.prototxt @@ -0,0 +1,208 @@ +name: "DenseNet_1100" +input: "data" +input_dim: 1 +input_dim: 3 +input_dim: 1100 +input_dim: 1100 +layers { + layer { + name: "conv1" + type: "conv" + num_output: 96 + kernelsize: 11 + stride: 4 + weight_filler { + type: "gaussian" + std: 0.01 + } + bias_filler { + type: "constant" + value: 0. + } + blobs_lr: 1. + blobs_lr: 2. + weight_decay: 1. + weight_decay: 0. + } + bottom: "data" + top: "conv1" +} +layers { + layer { + name: "relu1" + type: "relu" + } + bottom: "conv1" + top: "conv1" +} +layers { + layer { + name: "pool1" + type: "pool" + pool: MAX + kernelsize: 3 + stride: 2 + } + bottom: "conv1" + top: "pool1" +} +layers { + layer { + name: "norm1" + type: "lrn" + local_size: 5 + alpha: 0.0001 + beta: 0.75 + } + bottom: "pool1" + top: "norm1" +} +layers { + layer { + name: "conv2" + type: "conv" + num_output: 256 + group: 2 + kernelsize: 5 + pad: 2 + weight_filler { + type: "gaussian" + std: 0.01 + } + bias_filler { + type: "constant" + value: 1. + } + blobs_lr: 1. + blobs_lr: 2. + weight_decay: 1. + weight_decay: 0. + } + bottom: "norm1" + top: "conv2" +} +layers { + layer { + name: "relu2" + type: "relu" + } + bottom: "conv2" + top: "conv2" +} +layers { + layer { + name: "pool2" + type: "pool" + pool: MAX + kernelsize: 3 + stride: 2 + } + bottom: "conv2" + top: "pool2" +} +layers { + layer { + name: "norm2" + type: "lrn" + local_size: 5 + alpha: 0.0001 + beta: 0.75 + } + bottom: "pool2" + top: "norm2" +} +layers { + layer { + name: "conv3" + type: "conv" + num_output: 384 + kernelsize: 3 + pad: 1 + weight_filler { + type: "gaussian" + std: 0.01 + } + bias_filler { + type: "constant" + value: 0. + } + blobs_lr: 1. + blobs_lr: 2. + weight_decay: 1. + weight_decay: 0. + } + bottom: "norm2" + top: "conv3" +} +layers { + layer { + name: "relu3" + type: "relu" + } + bottom: "conv3" + top: "conv3" +} +layers { + layer { + name: "conv4" + type: "conv" + num_output: 384 + group: 2 + kernelsize: 3 + pad: 1 + weight_filler { + type: "gaussian" + std: 0.01 + } + bias_filler { + type: "constant" + value: 1. + } + blobs_lr: 1. + blobs_lr: 2. + weight_decay: 1. + weight_decay: 0. + } + bottom: "conv3" + top: "conv4" +} +layers { + layer { + name: "relu4" + type: "relu" + } + bottom: "conv4" + top: "conv4" +} +layers { + layer { + name: "conv5" + type: "conv" + num_output: 256 + group: 2 + kernelsize: 3 + pad: 1 + weight_filler { + type: "gaussian" + std: 0.01 + } + bias_filler { + type: "constant" + value: 1. + } + blobs_lr: 1. + blobs_lr: 2. + weight_decay: 1. + weight_decay: 0. + } + bottom: "conv4" + top: "conv5" +} +layers { + layer { + name: "relu5" + type: "relu" + } + bottom: "conv5" + top: "conv5" +} \ No newline at end of file diff --git a/python/caffe/imagenet/imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt b/python/caffe/imagenet/imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt new file mode 100644 index 00000000000..d78501d98ba --- /dev/null +++ b/python/caffe/imagenet/imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt @@ -0,0 +1,208 @@ +name: "DenseNet_2000" +input: "data" +input_dim: 1 +input_dim: 3 +input_dim: 2000 +input_dim: 2000 +layers { + layer { + name: "conv1" + type: "conv" + num_output: 96 + kernelsize: 11 + stride: 4 + weight_filler { + type: "gaussian" + std: 0.01 + } + bias_filler { + type: "constant" + value: 0. + } + blobs_lr: 1. + blobs_lr: 2. + weight_decay: 1. + weight_decay: 0. + } + bottom: "data" + top: "conv1" +} +layers { + layer { + name: "relu1" + type: "relu" + } + bottom: "conv1" + top: "conv1" +} +layers { + layer { + name: "pool1" + type: "pool" + pool: MAX + kernelsize: 3 + stride: 2 + } + bottom: "conv1" + top: "pool1" +} +layers { + layer { + name: "norm1" + type: "lrn" + local_size: 5 + alpha: 0.0001 + beta: 0.75 + } + bottom: "pool1" + top: "norm1" +} +layers { + layer { + name: "conv2" + type: "conv" + num_output: 256 + group: 2 + kernelsize: 5 + pad: 2 + weight_filler { + type: "gaussian" + std: 0.01 + } + bias_filler { + type: "constant" + value: 1. + } + blobs_lr: 1. + blobs_lr: 2. + weight_decay: 1. + weight_decay: 0. + } + bottom: "norm1" + top: "conv2" +} +layers { + layer { + name: "relu2" + type: "relu" + } + bottom: "conv2" + top: "conv2" +} +layers { + layer { + name: "pool2" + type: "pool" + pool: MAX + kernelsize: 3 + stride: 2 + } + bottom: "conv2" + top: "pool2" +} +layers { + layer { + name: "norm2" + type: "lrn" + local_size: 5 + alpha: 0.0001 + beta: 0.75 + } + bottom: "pool2" + top: "norm2" +} +layers { + layer { + name: "conv3" + type: "conv" + num_output: 384 + kernelsize: 3 + pad: 1 + weight_filler { + type: "gaussian" + std: 0.01 + } + bias_filler { + type: "constant" + value: 0. + } + blobs_lr: 1. + blobs_lr: 2. + weight_decay: 1. + weight_decay: 0. + } + bottom: "norm2" + top: "conv3" +} +layers { + layer { + name: "relu3" + type: "relu" + } + bottom: "conv3" + top: "conv3" +} +layers { + layer { + name: "conv4" + type: "conv" + num_output: 384 + group: 2 + kernelsize: 3 + pad: 1 + weight_filler { + type: "gaussian" + std: 0.01 + } + bias_filler { + type: "constant" + value: 1. + } + blobs_lr: 1. + blobs_lr: 2. + weight_decay: 1. + weight_decay: 0. + } + bottom: "conv3" + top: "conv4" +} +layers { + layer { + name: "relu4" + type: "relu" + } + bottom: "conv4" + top: "conv4" +} +layers { + layer { + name: "conv5" + type: "conv" + num_output: 256 + group: 2 + kernelsize: 3 + pad: 1 + weight_filler { + type: "gaussian" + std: 0.01 + } + bias_filler { + type: "constant" + value: 1. + } + blobs_lr: 1. + blobs_lr: 2. + weight_decay: 1. + weight_decay: 0. + } + bottom: "conv4" + top: "conv5" +} +layers { + layer { + name: "relu5" + type: "relu" + } + bottom: "conv5" + top: "conv5" +} \ No newline at end of file From 1821069ece9ba5dc117be4ba051923d379f72ebb Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 16 Jan 2014 22:04:42 -0800 Subject: [PATCH 03/92] stitching 2000x2000 planes from within pycaffe.cpp --- python/caffe/imagenet/featpyramid_tests.py | 15 +++++------ python/caffe/pycaffe.cpp | 8 +++++- .../caffe/stitch_pyramid/PyramidStitcher.cpp | 26 +++++++++++++------ python/caffe/stitch_pyramid/PyramidStitcher.h | 3 +-- .../stitch_pyramid/test_stitch_pyramid.cpp | 2 +- 5 files changed, 34 insertions(+), 20 deletions(-) diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py index fe6f0581457..f1ee4cf604d 100644 --- a/python/caffe/imagenet/featpyramid_tests.py +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -3,10 +3,6 @@ used power_wrapper.py as a starting point. - -example usage: -python featpyramid_tests.py --images_file=image_cat.txt --crop_mode=selective_search --model_def=../../../examples/imagenet_deploy.prototxt --pretrained_model=../../../alexnet_train_iter_470000 --output=selective_cat.h5 - ''' import numpy as np @@ -28,9 +24,6 @@ #hopefully caffenet is passed by ref... def test_pyramid_IO(caffenet, imgFname): - #TODO - - #caffenet.testIO() example_np_array = caffenet.testIO() #just return an array with 1 2 3 4... #example_np_arrays = caffenet.testIO_multiPlane() #return array of arrays @@ -48,12 +41,17 @@ def featpyramid(caffenet, imgFname, [params]): return pyra ''' +def test_featpyramid(caffenet, imgFname): + + caffenet.extract_featpyramid(imgFname) #test... TODO: return descriptors here + if __name__ == "__main__": #pretend that these flags came off the command line: imgFname = './pascal_009959.jpg' - model_def = '../../../examples/imagenet_deploy.prototxt' + #model_def = '../../../examples/imagenet_deploy.prototxt' + model_def = './imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt' pretrained_model = '../../../alexnet_train_iter_470000' use_gpu = True @@ -66,4 +64,5 @@ def featpyramid(caffenet, imgFname, [params]): #experiments... test_pyramid_IO(caffenet, imgFname) + test_featpyramid(caffenet, imgFname) diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index ab617cc9c24..f78f798fe1a 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -265,8 +265,14 @@ struct CaffeNet { int padding = 8; int interval = 10; - Patchwork patchwork = stitch_pyramid(file, padding, interval); + int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size + assert(net_->input_blobs()[0]->width() == net_->input_blobs()[0]->height()); //assume square planes in Caffe. (can relax this if necessary) + //TODO: verify that top-upsampled version of input img fits within planeDim + + Patchwork patchwork = stitch_pyramid(file, padding, interval, planeDim); + + printf("\n\n in pycaffe.cpp extract_featpyramid(). planeDim=%d\n", planeDim); } // The caffe::Caffe utility functions. diff --git a/python/caffe/stitch_pyramid/PyramidStitcher.cpp b/python/caffe/stitch_pyramid/PyramidStitcher.cpp index ff8e8504c3b..3a9b0d7d2e5 100644 --- a/python/caffe/stitch_pyramid/PyramidStitcher.cpp +++ b/python/caffe/stitch_pyramid/PyramidStitcher.cpp @@ -14,8 +14,9 @@ using namespace std; //TODO: have a pyramid stitch class? -//int main(int argc, char * argv[]) -Patchwork stitch_pyramid(string file, int padding=8, int interval=10) +// @param planeDim == width == height of planes to cover with images (optional) +// if planeDim <= 0, then ignore planeDim and compute plane size based on input image dims +Patchwork stitch_pyramid(string file, int padding=8, int interval=10, int planeDim=-1) { JPEGImage image(file); if (image.empty()) { @@ -26,15 +27,24 @@ Patchwork stitch_pyramid(string file, int padding=8, int interval=10) image = image.resize(image.width()*2, image.height()*2); //UPSAMPLE so that Caffe's 16x downsampling looks like 8x downsampling // Compute the downsample+stitch - JPEGPyramid pyramid(image, padding, padding, interval); //DOWNSAMPLE with (padx == pady == padding) + JPEGPyramid pyramid(image, padding, padding, interval); //multiscale DOWNSAMPLE with (padx == pady == padding) if (pyramid.empty()) { cerr << "\nInvalid image " << file << endl; } - - int planeWidth = (pyramid.levels()[0].width() + 15) & ~15; //TODO: don't subtract padx, pady? - int planeHeight = (pyramid.levels()[0].height() + 15) & ~15; - planeWidth = max(planeWidth, planeHeight); //SQUARE planes for Caffe convnet - planeHeight = max(planeWidth, planeHeight); + + int planeWidth; + int planeHeight; + + if(planeDim > 0){ + planeWidth = planeDim; + planeHeight = planeDim; + } + else{ + planeWidth = (pyramid.levels()[0].width() + 15) & ~15; //TODO: don't subtract padx, pady? + planeHeight = (pyramid.levels()[0].height() + 15) & ~15; + planeWidth = max(planeWidth, planeHeight); //SQUARE planes for Caffe convnet + planeHeight = max(planeWidth, planeHeight); + } Patchwork::Init(planeHeight, planeWidth); const Patchwork patchwork(pyramid); //STITCH diff --git a/python/caffe/stitch_pyramid/PyramidStitcher.h b/python/caffe/stitch_pyramid/PyramidStitcher.h index bfed141956f..04be28e480b 100644 --- a/python/caffe/stitch_pyramid/PyramidStitcher.h +++ b/python/caffe/stitch_pyramid/PyramidStitcher.h @@ -15,8 +15,7 @@ using namespace FFLD; using namespace std; //image -> multiscale pyramid -> stitch to same-sized planes for Caffe convnet -//void stitch_pyramid(string file, Patchwork out_patchwork, int padding=8, int interval=10); -Patchwork stitch_pyramid(string file, int padding=8, int interval=10); +Patchwork stitch_pyramid(string file, int padding=8, int interval=10, int planeDim=-1); #endif diff --git a/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp b/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp index c5ce63c48f8..28b61931538 100644 --- a/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp +++ b/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp @@ -152,7 +152,7 @@ int main(int argc, char * argv[]){ printf(" base_filename = %s \n", base_filename.c_str()); printf(" output_stitched_dir = %s \n", output_stitched_dir.c_str()); - Patchwork patchwork = stitch_pyramid(file, padding, interval); + Patchwork patchwork = stitch_pyramid(file, padding, interval, -1); //planeDim = -1 (use defaults) //printScaleSizes(pyramid); //writePyraToJPG(pyramid); writePatchworkToJPG(patchwork, output_stitched_dir, base_filename); //outputs to output_stitched_dir/base_filename_[planeID].jpg From f00eb3f1d3d052dad67ab5a36cf5cb03cd3db0c2 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 16 Jan 2014 22:27:22 -0800 Subject: [PATCH 04/92] designing jpeg pyramid -> caffe copying stuff --- python/caffe/pycaffe.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index f78f798fe1a..64661e0d698 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -221,10 +221,10 @@ struct CaffeNet { //float* -> numpy -> boost python (which can be returned to Python) boost::python::object array_to_boostPython_4d(float* pyramid_float, - int nbPlanes, int depth_, int MaxHeight_, int MaxWidth_) + int batchsize, int depth_, int MaxHeight_, int MaxWidth_) { - npy_intp dims[4] = {nbPlanes, depth_, MaxHeight_, MaxWidth_}; //in floats + npy_intp dims[4] = {batchsize, depth_, MaxHeight_, MaxWidth_}; //in floats PyArrayObject* pyramid_float_py = (PyArrayObject*)PyArray_New( &PyArray_Type, 4, dims, NPY_FLOAT, 0, pyramid_float, 0, 0, 0 ); //not specifying strides //thanks: stackoverflow.com/questions/19185574 @@ -235,17 +235,17 @@ struct CaffeNet { //return a list containing one 4D numpy/boost array. (toy example) boost::python::list testIO() { - int nbPlanes = 1; + int batchsize = 1; int depth_ = 1; int MaxHeight_ = 10; int MaxWidth_ = 10; //prepare data that we'll send to Python - float* pyramid_float = (float*)malloc(sizeof(float) * nbPlanes * depth_ * MaxHeight_ * MaxWidth_); - memset(pyramid_float, 0, sizeof(float) * nbPlanes * depth_ * MaxHeight_ * MaxWidth_); + float* pyramid_float = (float*)malloc(sizeof(float) * batchsize * depth_ * MaxHeight_ * MaxWidth_); + memset(pyramid_float, 0, sizeof(float) * batchsize * depth_ * MaxHeight_ * MaxWidth_); pyramid_float[10] = 123; //test -- see if it shows up in Python - boost::python::object pyramid_float_py_boost = array_to_boostPython_4d(pyramid_float, nbPlanes, depth_, MaxHeight_, MaxWidth_); + boost::python::object pyramid_float_py_boost = array_to_boostPython_4d(pyramid_float, batchsize, depth_, MaxHeight_, MaxWidth_); boost::python::list blobs_top_boost; //list to return blobs_top_boost.append(pyramid_float_py_boost); //put the output array in list @@ -268,10 +268,25 @@ struct CaffeNet { int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size assert(net_->input_blobs()[0]->width() == net_->input_blobs()[0]->height()); //assume square planes in Caffe. (can relax this if necessary) + assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) //TODO: verify that top-upsampled version of input img fits within planeDim Patchwork patchwork = stitch_pyramid(file, padding, interval, planeDim); + int planeID = 0; //TODO: iterate to patchwork.planes.size(), running one at a time in Caffe + JPEGImage* currPlane = &(patchwork.planes_[0]); +/* + //TODO: separate function... + // copy_JPEG_to_boostPythonFloat(JPEGImage image_src, boost::python::object float_dst) + // or just copy_JPEG_to_float_unpacked(JPEGImage image_src, float* float_dst) + // image_src is 8-bit packed image + // float_dst is 32-bit float unpacked (separate channels) image + for(int y=0; ... + for(int x=0; ... + for(int ch=0; ... + +*/ + printf("\n\n in pycaffe.cpp extract_featpyramid(). planeDim=%d\n", planeDim); } From ecbd74e2100bcf25b379b5dba9d8e3e4d41079df Mon Sep 17 00:00:00 2001 From: forresti Date: Fri, 17 Jan 2014 12:27:22 -0800 Subject: [PATCH 05/92] setting up input and output blobs for featpyramid --- python/caffe/pycaffe.cpp | 109 ++++++++++++++++++++++++++------------- 1 file changed, 73 insertions(+), 36 deletions(-) diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index 64661e0d698..70ecbd898c3 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -217,21 +217,87 @@ struct CaffeNet { } } - //void testIO(){ } //dummy example - //float* -> numpy -> boost python (which can be returned to Python) boost::python::object array_to_boostPython_4d(float* pyramid_float, int batchsize, int depth_, int MaxHeight_, int MaxWidth_) { npy_intp dims[4] = {batchsize, depth_, MaxHeight_, MaxWidth_}; //in floats - PyArrayObject* pyramid_float_py = (PyArrayObject*)PyArray_New( &PyArray_Type, 4, dims, NPY_FLOAT, 0, pyramid_float, 0, 0, 0 ); //not specifying strides + PyArrayObject* pyramid_float_npy = (PyArrayObject*)PyArray_New( &PyArray_Type, 4, dims, NPY_FLOAT, 0, pyramid_float, 0, 0, 0 ); //not specifying strides //thanks: stackoverflow.com/questions/19185574 - boost::python::object pyramid_float_py_boost(boost::python::handle<>((PyObject*)pyramid_float_py)); - return pyramid_float_py_boost; + boost::python::object pyramid_float_npy_boost(boost::python::handle<>((PyObject*)pyramid_float_npy)); + return pyramid_float_npy_boost; } + // for now, one batch at a time. (later, can modify this to allocate & fill a >1 batch 4d array) + // @param jpeg = typically a plane from Patchwork, in packed JPEG [RGB,RGB,RGB] format + // @return numpy float array of jpeg, in unpacked [RRRRR..,GGGGG..,BBBBB..] format + PyArrayObject* JPEGImage_to_numpy_float(JPEGImage &jpeg){ + + int depth = jpeg.depth(); + int height = jpeg.height(); + int width = jpeg.width(); + int batchsize = 1; + npy_intp dims[4] = {batchsize, depth, height, width}; + + PyArrayObject* jpeg_float_npy = (PyArrayObject*)PyArray_New( &PyArray_Type, 4, dims, NPY_FLOAT, 0, 0, 0, 0, 0 ); //numpy malloc + + //TODO: make sure of RGB vs BGR (just for documentation purposes) + + //copy jpeg into jpeg_float_npy + for(int y=0; yinput_blobs()[0]->width(); //assume that all preallocated blobs are same size + + assert(net_->input_blobs()[0]->width() == net_->input_blobs()[0]->height()); //assume square planes in Caffe. (can relax this if necessary) + assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) + //TODO: verify that top-upsampled version of input img fits within planeDim + + //TODO: think about how to use image_mean. + // ignoring image_mean for now, because the 'subtract image mean from whatever input region we get' + // thing in r-cnn feels kinda silly. + + Patchwork patchwork = stitch_pyramid(file, padding, interval, planeDim); + + int planeID = 0; //TODO: iterate to patchwork.planes.size(), running one at a time in Caffe + + //prep input data + JPEGImage* currPlane = &(patchwork.planes_[planeID]); + PyArrayObject* currPlane_npy = JPEGImage_to_numpy_float(*currPlane); //TODO: agree on dereference and/or pass-by-ref JPEGImage currPlane + boost::python::object currPlane_npy_boost(boost::python::handle<>((PyObject*)currPlane_npy)); //numpy -> wrap in boost + boost::python::list blobs_bottom; //input to Caffe::Forward + blobs_bottom.append(currPlane_npy_boost); //put the output array in list [list length = 1, because batchsize = 1] + + //prep output space + PyArrayObject* resultPlane_npy = (PyArrayObject*)PyArray_NewLikeArray(currPlane_npy, NPY_KEEPORDER, NULL, 1); //same size/shape as currPlane_npy + boost::python::object resultPlane_npy_boost(boost::python::handle<>((PyObject*)resultPlane_npy)); //numpy -> wrap in boost + boost::python::list blobs_top; //output buffer for Caffe::Forward + blobs_top.append(resultPlane_npy_boost); //put the output array in list [list length = 1, because batchsize = 1] + + //Forward(list bottom, list top) + Forward(blobs_bottom, blobs_top); + + printf("\n\n in pycaffe.cpp extract_featpyramid(). planeDim=%d\n", planeDim); + } + + //void testIO(){ } //dummy example + //return a list containing one 4D numpy/boost array. (toy example) boost::python::list testIO() { @@ -245,10 +311,10 @@ struct CaffeNet { memset(pyramid_float, 0, sizeof(float) * batchsize * depth_ * MaxHeight_ * MaxWidth_); pyramid_float[10] = 123; //test -- see if it shows up in Python - boost::python::object pyramid_float_py_boost = array_to_boostPython_4d(pyramid_float, batchsize, depth_, MaxHeight_, MaxWidth_); + boost::python::object pyramid_float_npy_boost = array_to_boostPython_4d(pyramid_float, batchsize, depth_, MaxHeight_, MaxWidth_); boost::python::list blobs_top_boost; //list to return - blobs_top_boost.append(pyramid_float_py_boost); //put the output array in list + blobs_top_boost.append(pyramid_float_npy_boost); //put the output array in list return blobs_top_boost; //compile error: return-statement with no value } @@ -261,35 +327,6 @@ struct CaffeNet { printf(" int from python: %d \n", i); } - void extract_featpyramid(string file){ - - int padding = 8; - int interval = 10; - int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size - - assert(net_->input_blobs()[0]->width() == net_->input_blobs()[0]->height()); //assume square planes in Caffe. (can relax this if necessary) - assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) - //TODO: verify that top-upsampled version of input img fits within planeDim - - Patchwork patchwork = stitch_pyramid(file, padding, interval, planeDim); - - int planeID = 0; //TODO: iterate to patchwork.planes.size(), running one at a time in Caffe - JPEGImage* currPlane = &(patchwork.planes_[0]); -/* - //TODO: separate function... - // copy_JPEG_to_boostPythonFloat(JPEGImage image_src, boost::python::object float_dst) - // or just copy_JPEG_to_float_unpacked(JPEGImage image_src, float* float_dst) - // image_src is 8-bit packed image - // float_dst is 32-bit float unpacked (separate channels) image - for(int y=0; ... - for(int x=0; ... - for(int ch=0; ... - -*/ - - printf("\n\n in pycaffe.cpp extract_featpyramid(). planeDim=%d\n", planeDim); - } - // The caffe::Caffe utility functions. void set_mode_cpu() { Caffe::set_mode(Caffe::CPU); } void set_mode_gpu() { Caffe::set_mode(Caffe::GPU); } From f72387979e7cec8534e57a4750ad59b78128b149 Mon Sep 17 00:00:00 2001 From: forresti Date: Fri, 17 Jan 2014 16:17:49 -0800 Subject: [PATCH 06/92] getting stitched planes and visualizing them --- python/caffe/imagenet/featpyramid_tests.py | 37 ++++++++++++++-------- python/caffe/pycaffe.cpp | 30 +++++++++++++++--- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py index f1ee4cf604d..bfb751445a2 100644 --- a/python/caffe/imagenet/featpyramid_tests.py +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -2,20 +2,23 @@ test cases for multiscale pyramids of Convnet features. used power_wrapper.py as a starting point. - ''' import numpy as np import os import sys import gflags -import pandas as pd +#import pandas as pd import time -import skimage.io -import skimage.transform -import selective_search_ijcv_with_python as selective_search +#import skimage.io +#import skimage.transform +#import selective_search_ijcv_with_python as selective_search import caffe +#for visualization, can be removed easily: +from matplotlib import cm, pyplot +import pylab + #parameters to consider passing to C++ Caffe::featpyramid... # image filename # num scales (or something to control this) @@ -32,18 +35,26 @@ def test_pyramid_IO(caffenet, imgFname): caffenet.testString('hi') caffenet.testInt(1337) -''' -def featpyramid(caffenet, imgFname, [params]): - stitched_pyra = caffenet.extract_featpyramid(imgFname, [params]) - pyra = unstitch_pyra(stitched_pyra) #alternatively, do this in C++ inside extract_featpyramid() +def test_featpyramid(caffenet, imgFname): - return pyra -''' + #blobs_bottom = features computed on PLANES. + blobs_bottom = caffenet.extract_featpyramid(imgFname) # THE CRUX + print blobs_bottom[0] + print 'blobs shape: ' + print blobs_bottom[0].shape -def test_featpyramid(caffenet, imgFname): + #TODO: tweak extract_featpyramid to unstitch planes -> descriptor pyramid + + #prep for visualization (sum over depth of descriptors) + flat_descriptor = np.sum(blobs_bottom[0], axis=1) #e.g. (1, depth=256, height=124, width=124) -> (1, 124, 124) + flat_descriptor = flat_descriptor[0] #(1, 124, 124) -> (124, 124) ... first image (in a batch size of 1) - caffenet.extract_featpyramid(imgFname) #test... TODO: return descriptors here + #visualization + pyplot.figure() + pyplot.title('Welcome to deep learning land. You have arrived.') + pyplot.imshow(flat_descriptor, cmap = cm.gray) + pylab.savefig('flat_descriptor.jpg') if __name__ == "__main__": diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index 70ecbd898c3..dc2c260c95a 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -259,7 +259,23 @@ struct CaffeNet { return jpeg_float_npy; } - void extract_featpyramid(string file){ + //obtains resultPlane dims with shared ptr to net_ + PyArrayObject* allocate_resultPlane(){ + + int batchsize = net_->output_blobs()[0]->num(); + int depth = net_->output_blobs()[0]->channels(); + int width = net_->output_blobs()[0]->width(); + int height = net_->output_blobs()[0]->height(); + npy_intp dims[4] = {batchsize, depth, height, width}; + printf(" in allocate_resultPlane(). OUTPUT_BLOBS... batchsize=%d, depth=%d, width=%d, height=%d \n", batchsize, depth, width, height); + + //PyArrayObject* resultPlane = NULL; //stub + PyArrayObject* resultPlane = (PyArrayObject*)PyArray_New( &PyArray_Type, 4, dims, NPY_FLOAT, 0, 0, 0, 0, 0 ); //numpy malloc + return resultPlane; + } + + //void extract_featpyramid(string file){ + boost::python::list extract_featpyramid(string file){ int padding = 8; int interval = 10; @@ -275,7 +291,8 @@ struct CaffeNet { Patchwork patchwork = stitch_pyramid(file, padding, interval, planeDim); - int planeID = 0; //TODO: iterate to patchwork.planes.size(), running one at a time in Caffe + int planeID = 0; //TODO: append multiple blobs to blobs_{top,bottom}, iterating to planes_.size() + // then, run Forward() on the list of blobs. //prep input data JPEGImage* currPlane = &(patchwork.planes_[planeID]); @@ -285,15 +302,18 @@ struct CaffeNet { blobs_bottom.append(currPlane_npy_boost); //put the output array in list [list length = 1, because batchsize = 1] //prep output space - PyArrayObject* resultPlane_npy = (PyArrayObject*)PyArray_NewLikeArray(currPlane_npy, NPY_KEEPORDER, NULL, 1); //same size/shape as currPlane_npy + //PyArrayObject* resultPlane_npy = (PyArrayObject*)PyArray_NewLikeArray(currPlane_npy, NPY_KEEPORDER, NULL, 1); //same size/shape as currPlane_npy + PyArrayObject* resultPlane_npy = allocate_resultPlane(); //gets resultPlane dims from shared ptr to net_->output_blobs() boost::python::object resultPlane_npy_boost(boost::python::handle<>((PyObject*)resultPlane_npy)); //numpy -> wrap in boost boost::python::list blobs_top; //output buffer for Caffe::Forward blobs_top.append(resultPlane_npy_boost); //put the output array in list [list length = 1, because batchsize = 1] - //Forward(list bottom, list top) - Forward(blobs_bottom, blobs_top); + Forward(blobs_bottom, blobs_top); //lists of blobs... bottom=input planes, top=output descriptors printf("\n\n in pycaffe.cpp extract_featpyramid(). planeDim=%d\n", planeDim); + + return blobs_bottom; //for debugging only (stitched pyramid in RGB) + //return blobs_top; //output plane(s) } //void testIO(){ } //dummy example From c005e6b8328334d2c00491e1807915ba9b55657a Mon Sep 17 00:00:00 2001 From: forresti Date: Fri, 17 Jan 2014 18:16:34 -0800 Subject: [PATCH 07/92] creating multiple scales / planes and returning them to python --- python/caffe/imagenet/featpyramid_tests.py | 43 +++-- python/caffe/imagenet/pascal_009959.jpg | Bin 0 -> 48970 bytes python/caffe/pycaffe.cpp | 151 +++++++++++++++--- python/caffe/stitch_pyramid/Patchwork.h | 11 +- .../caffe/stitch_pyramid/PyramidStitcher.cpp | 28 +++- python/caffe/stitch_pyramid/PyramidStitcher.h | 23 +++ .../stitch_pyramid/test_stitch_pyramid.cpp | 15 ++ 7 files changed, 222 insertions(+), 49 deletions(-) create mode 100644 python/caffe/imagenet/pascal_009959.jpg diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py index bfb751445a2..2c5c13a8020 100644 --- a/python/caffe/imagenet/featpyramid_tests.py +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -8,11 +8,7 @@ import os import sys import gflags -#import pandas as pd import time -#import skimage.io -#import skimage.transform -#import selective_search_ijcv_with_python as selective_search import caffe #for visualization, can be removed easily: @@ -27,8 +23,8 @@ #hopefully caffenet is passed by ref... def test_pyramid_IO(caffenet, imgFname): - example_np_array = caffenet.testIO() #just return an array with 1 2 3 4... - #example_np_arrays = caffenet.testIO_multiPlane() #return array of arrays + #example_np_array = caffenet.testIO() #just return an array with 1 2 3 4... + example_np_array = caffenet.test_NumpyView() print example_np_array print example_np_array[0].shape @@ -37,17 +33,15 @@ def test_pyramid_IO(caffenet, imgFname): caffenet.testInt(1337) def test_featpyramid(caffenet, imgFname): + #blobs_top = features computed on PLANES. + blobs_top = caffenet.extract_featpyramid(imgFname) # THE CRUX - #blobs_bottom = features computed on PLANES. - blobs_bottom = caffenet.extract_featpyramid(imgFname) # THE CRUX - print blobs_bottom[0] + #print blobs_top[0] print 'blobs shape: ' - print blobs_bottom[0].shape - - #TODO: tweak extract_featpyramid to unstitch planes -> descriptor pyramid + print blobs_top[0].shape #prep for visualization (sum over depth of descriptors) - flat_descriptor = np.sum(blobs_bottom[0], axis=1) #e.g. (1, depth=256, height=124, width=124) -> (1, 124, 124) + flat_descriptor = np.sum(blobs_top[0], axis=1) #e.g. (1, depth=256, height=124, width=124) -> (1, 124, 124) flat_descriptor = flat_descriptor[0] #(1, 124, 124) -> (124, 124) ... first image (in a batch size of 1) #visualization @@ -57,6 +51,24 @@ def test_featpyramid(caffenet, imgFname): pylab.savefig('flat_descriptor.jpg') +def test_featpyramid_allScales(caffenet, imgFname): + #blobs_top = list of feature arrays... one array per scale. + blobs_top = caffenet.extract_featpyramid(imgFname) # THE CRUX + + for i in xrange(0, len(blobs_top)): + print 'blobs[%d] shape: '%i + print blobs_top[i].shape + + #prep for visualization (sum over depth of descriptors) + flat_descriptor = np.sum(blobs_top[i], axis=1) #e.g. (1, depth=256, height=124, width=124) -> (1, 124, 124) + flat_descriptor = flat_descriptor[0] #(1, 124, 124) -> (124, 124) ... first image (in a batch size of 1) + + #visualization + pyplot.figure() + pyplot.title('Welcome to deep learning land. You have arrived.') + pyplot.imshow(flat_descriptor, cmap = cm.gray) + pylab.savefig('output_pyra/flat_descriptor_scale%d.jpg' %i) + if __name__ == "__main__": #pretend that these flags came off the command line: @@ -74,6 +86,5 @@ def test_featpyramid(caffenet, imgFname): #experiments... test_pyramid_IO(caffenet, imgFname) - - test_featpyramid(caffenet, imgFname) - + #test_featpyramid(caffenet, imgFname) + test_featpyramid_allScales(caffenet, imgFname) diff --git a/python/caffe/imagenet/pascal_009959.jpg b/python/caffe/imagenet/pascal_009959.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e3317750b854a2baa499380889efa90e122af198 GIT binary patch literal 48970 zcmce+bx<79(>A)eyE_C6?(RwO;DN;<0fM_Nu(;b|!7T*$5Zv8^6PDmC7Mw*F3Ay~< zx9Wc1t@^J1anDqD&D5NkdY20EB8vs!9MPBme;E(*e8hO=PAV9hQiRF;rlFrqckY5k z=#xhn7B)ErB^5O*8~bYxPGJ#IF>wjWx9=2{lvPyK^giet01b_dt*mW6+uGSXczSvJ z_=5cW!y_W2qGMv?Qq#VqXJlq&=X@(JDJ?6nsI20Xe1@|eRWXA$0Jh5v`ze=+-iMl9_A z6SM!F*#F?Q0>DKc9vgs#We?M0fpC=fllecw!cn>weA-(`rESePO zlBkL2NtqFZi||n$)6@FZY>bSk>c?dxO~dd}+%&Odl9=1-X10OD@ztliW^x8Rq<=6b zlGAk%{{Uoqe``;>t$8(I!`F&vck~Y1C4yxlCkd^%9 zHRfE)Q@fS3oNCNEs4@i+4DgKmiy=DnmLc;^lYYrkZ|GH)ze~c3ZMPBV8_d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)M4jc`AsQ0m47P7Bep6zE&@w6K{>@sZP&MykoT`KqP)w&iKBG}+&Y)mLZvd2>|*xcOlzovr^s z)mIbc{9(=+xA2{C|oqV1gh|K^9dOd09D6k^8W+c=5&t8tm6 z%RrGr@bUI&YY;XK8X{6+CWYLOc9A8ege@eq0Ioy>VvT{|4 zZoR4RsU^f$cq^-3*EbUd_g!oqRnpPnj9ttdIUI&IXP4P7cn>dM&gMjhH@^~lKr&}` zKjC2?{Y@+i7~!W#3VSlwkPSxlY;*7oxX638P24 zkfN@P1W!8K>mDR3QUK&0Qs*k5Z?Hr;iqlb|dM_KX!stYqR!WobFmx$WP=uuaTpZx} Naw0)|z~{f&{{yo#1H}LU literal 0 HcmV?d00001 diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index dc2c260c95a..f923c620094 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -274,50 +274,98 @@ struct CaffeNet { return resultPlane; } - //void extract_featpyramid(string file){ + // @param scaleLocs = location of each scale on planes (see unstitch_pyramid_locations in PyramidStitcher.cpp) + // @param descriptor_planes -- each element of the list is a plane of Caffe descriptors + // typically, descriptor_planes = blobs_top. + // @param depth = #channels (typically 256 for conv5) + // @return a list of numpy 'views', one list element per scale. + boost::python::list unstitch_planes(vector scaleLocs, boost::python::list descriptor_planes, int depth){ + + boost::python::list unstitched_features; + int nbScales = scaleLocs.size(); + int batchsize = 1; //TODO: assert that batchsize really is 1. + + for(int i=0; i((PyObject*)view_npy)); + unstitched_features.append(view_npy_boost); + } + + return unstitched_features; + } + + //void extract_featpyramid(string file){ boost::python::list extract_featpyramid(string file){ - int padding = 8; + int padding = 16; int interval = 10; + int convnet_subsampling_ratio = 16; //for conv5 layer features int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size + int resultDepth = net_->output_blobs()[0]->channels(); assert(net_->input_blobs()[0]->width() == net_->input_blobs()[0]->height()); //assume square planes in Caffe. (can relax this if necessary) assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) - //TODO: verify that top-upsampled version of input img fits within planeDim + //TODO: verify/assert that top-upsampled version of input img fits within planeDim //TODO: think about how to use image_mean. // ignoring image_mean for now, because the 'subtract image mean from whatever input region we get' // thing in r-cnn feels kinda silly. Patchwork patchwork = stitch_pyramid(file, padding, interval, planeDim); - - int planeID = 0; //TODO: append multiple blobs to blobs_{top,bottom}, iterating to planes_.size() + int nbPlanes = patchwork.planes_.size(); + //int planeID = 0; //TODO: append multiple blobs to blobs_{top,bottom}, iterating to planes_.size() // then, run Forward() on the list of blobs. - //prep input data - JPEGImage* currPlane = &(patchwork.planes_[planeID]); - PyArrayObject* currPlane_npy = JPEGImage_to_numpy_float(*currPlane); //TODO: agree on dereference and/or pass-by-ref JPEGImage currPlane - boost::python::object currPlane_npy_boost(boost::python::handle<>((PyObject*)currPlane_npy)); //numpy -> wrap in boost - boost::python::list blobs_bottom; //input to Caffe::Forward - blobs_bottom.append(currPlane_npy_boost); //put the output array in list [list length = 1, because batchsize = 1] - - //prep output space - //PyArrayObject* resultPlane_npy = (PyArrayObject*)PyArray_NewLikeArray(currPlane_npy, NPY_KEEPORDER, NULL, 1); //same size/shape as currPlane_npy - PyArrayObject* resultPlane_npy = allocate_resultPlane(); //gets resultPlane dims from shared ptr to net_->output_blobs() - boost::python::object resultPlane_npy_boost(boost::python::handle<>((PyObject*)resultPlane_npy)); //numpy -> wrap in boost - boost::python::list blobs_top; //output buffer for Caffe::Forward - blobs_top.append(resultPlane_npy_boost); //put the output array in list [list length = 1, because batchsize = 1] - - Forward(blobs_bottom, blobs_top); //lists of blobs... bottom=input planes, top=output descriptors + boost::python::list blobs_bottom; //input buffer(s) for Caffe::Forward + boost::python::list blobs_top; //output buffer(s) for Caffe::Forward + + //prep input data for Caffe feature extraction + for(int planeID=0; planeID((PyObject*)currPlane_npy)); //numpy -> wrap in boost + boost::python::list blobs_bottom_tmp; //input to Caffe::Forward + blobs_bottom_tmp.append(currPlane_npy_boost); //put the output array in list [list length = 1, because batchsize = 1] + blobs_bottom.append(currPlane_npy_boost); //for long-term keeping (return a list that might be longer than 1) + + //TODO: make an option (or separate function) to pull out blobs_bottom to python here. + // (for debugging -- make sure the planes are stitched properly. have done a reasonable job verifying this so far.) + + //prep output space + PyArrayObject* resultPlane_npy = allocate_resultPlane(); //gets resultPlane dims from shared ptr to net_->output_blobs() + boost::python::object resultPlane_npy_boost(boost::python::handle<>((PyObject*)resultPlane_npy)); //numpy -> wrap in boost + boost::python::list blobs_top_tmp; //output buffer for Caffe::Forward + blobs_top_tmp.append(resultPlane_npy_boost); //put the output array in list [list length = 1, because batchsize = 1] + blobs_top.append(resultPlane_npy_boost); //for long-term keeping (return a list that might be longer than 1) + + Forward(blobs_bottom_tmp, blobs_top_tmp); //lists of blobs... bottom[0]=curr input planes, top_tmp[0]=curr output descriptors + } printf("\n\n in pycaffe.cpp extract_featpyramid(). planeDim=%d\n", planeDim); - return blobs_bottom; //for debugging only (stitched pyramid in RGB) + vector scaleLocations = unstitch_pyramid_locations(patchwork, convnet_subsampling_ratio); + boost::python::list unstitched_features = unstitch_planes(scaleLocations, blobs_top, resultDepth); + + //return blobs_bottom; //for debugging only (stitched pyramid in RGB) //return blobs_top; //output plane(s) + return unstitched_features; //unstitched pyramid from output plane(s) } - //void testIO(){ } //dummy example - //return a list containing one 4D numpy/boost array. (toy example) boost::python::list testIO() { @@ -339,6 +387,62 @@ struct CaffeNet { return blobs_top_boost; //compile error: return-statement with no value } + //return a slice ("view") of a numpy array + boost::python::list test_NumpyView() + { + int batchsize = 1; + int depth_ = 3; + int MaxHeight_ = 10; + int MaxWidth_ = 10; + + //setup numpy array + float* pyramid_float = (float*)malloc(sizeof(float) * batchsize * depth_ * MaxHeight_ * MaxWidth_); + memset(pyramid_float, 0, sizeof(float) * batchsize * depth_ * MaxHeight_ * MaxWidth_); + + for(int i=0; i((PyObject*)view_npy)); + blobs_top_boost_view.append(view_npy_boost); + + return blobs_top_boost_view; //compile error: return-statement with no value + //return blobs_top_boost; + } + + void testString(string st){ printf(" string from python: %s \n", st.c_str()); } @@ -393,6 +497,7 @@ BOOST_PYTHON_MODULE(pycaffe) { .def("set_phase_test", &CaffeNet::set_phase_test) .def("set_device", &CaffeNet::set_device) .def("testIO", &CaffeNet::testIO) //Forrest's test (return a numpy array) + .def("test_NumpyView", &CaffeNet::test_NumpyView) //Forrest's test (return view of a numpy array) .def("testString", &CaffeNet::testString) .def("testInt", &CaffeNet::testInt) .def("extract_featpyramid", &CaffeNet::extract_featpyramid) //NEW diff --git a/python/caffe/stitch_pyramid/Patchwork.h b/python/caffe/stitch_pyramid/Patchwork.h index be875c29669..1000d39946d 100644 --- a/python/caffe/stitch_pyramid/Patchwork.h +++ b/python/caffe/stitch_pyramid/Patchwork.h @@ -95,11 +95,7 @@ class Patchwork std::vector planes_; int nbScales; -private: - // Bottom-Left fill algorithm - static int BLF(std::vector > & rectangles); - - int padx_; + int padx_; int pady_; int interval_; std::vector > rectangles_; @@ -107,6 +103,11 @@ class Patchwork static int MaxRows_; //TODO: make these public. static int MaxCols_; static int HalfCols_; + +private: + // Bottom-Left fill algorithm + static int BLF(std::vector > & rectangles); + }; } diff --git a/python/caffe/stitch_pyramid/PyramidStitcher.cpp b/python/caffe/stitch_pyramid/PyramidStitcher.cpp index 3a9b0d7d2e5..10b9f76521c 100644 --- a/python/caffe/stitch_pyramid/PyramidStitcher.cpp +++ b/python/caffe/stitch_pyramid/PyramidStitcher.cpp @@ -3,11 +3,13 @@ #include "JPEGPyramid.h" #include "JPEGImage.h" #include "Patchwork.h" +#include "PyramidStitcher.h" #include #include #include #include +#include using namespace FFLD; using namespace std; @@ -16,7 +18,7 @@ using namespace std; // @param planeDim == width == height of planes to cover with images (optional) // if planeDim <= 0, then ignore planeDim and compute plane size based on input image dims -Patchwork stitch_pyramid(string file, int padding=8, int interval=10, int planeDim=-1) +Patchwork stitch_pyramid(string file, int padding, int interval, int planeDim) { JPEGImage image(file); if (image.empty()) { @@ -54,11 +56,27 @@ Patchwork stitch_pyramid(string file, int padding=8, int interval=10, int planeD //@param convnet_subsampling_ratio = difference between input image dim and convnet feature dim // e.g. if input img is 200x200 and conv5 is 25x25 ... 200/25=8 -> 8x downsampling in convnet -JPEGPyramid unstitch_pyramid(Patchwork image_patchwork, float* convnet_planes, int convnet_subsampling_ratio){ +//JPEGPyramid unstitch_pyramid(Patchwork image_patchwork, float* convnet_planes, int convnet_subsampling_ratio){ +vector unstitch_pyramid_locations(Patchwork &patchwork, + int convnet_subsampling_ratio) +{ + int nbScales = patchwork.nbScales; + vector scaleLocations(nbScales); - JPEGPyramid pyra; //stub + for(int i=0; i multiscale pyramid -> stitch to same-sized planes for Caffe convnet Patchwork stitch_pyramid(string file, int padding=8, int interval=10, int planeDim=-1); +// coordinates for unstitching the feature descriptors from planes. +// sorted in descending order of size. +// (well, Patchwork sorts in descending order of size, and that survives here.) +vector unstitch_pyramid_locations(Patchwork &patchwork, + int convnet_subsampling_ratio); + + #endif diff --git a/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp b/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp index 28b61931538..b49a89f4a7d 100644 --- a/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp +++ b/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp @@ -132,6 +132,7 @@ string parse_base_filename(string file){ void printScaleSizes(JPEGPyramid pyramid); void writePyraToJPG(JPEGPyramid pyramid); void writePatchworkToJPG(Patchwork patchwork, string output_stitched_dir, string base_filename); +void print_scaleLocations(vector scaleLocations); //TODO: split this test into its own function, e.g. test_stitch_pyramid() int main(int argc, char * argv[]){ @@ -157,6 +158,11 @@ int main(int argc, char * argv[]){ //writePyraToJPG(pyramid); writePatchworkToJPG(patchwork, output_stitched_dir, base_filename); //outputs to output_stitched_dir/base_filename_[planeID].jpg + int convnet_subsampling_ratio = 1; // we're not actually computing convnet features in this test, + // so there's no feature downsampling. + vector scaleLocations = unstitch_pyramid_locations(patchwork, convnet_subsampling_ratio); + print_scaleLocations(scaleLocations); + return EXIT_SUCCESS; } @@ -171,6 +177,15 @@ void printScaleSizes(JPEGPyramid pyramid){ } } +void print_scaleLocations(vector scaleLocations){ + printf("scaleLocations: \n"); + for(int i=0; i Date: Sat, 18 Jan 2014 21:58:55 -0800 Subject: [PATCH 08/92] add disabled code for rand padding scales inside planes --- python/caffe/stitch_pyramid/JPEGImage.cpp | 36 ++++++++++++++++++- python/caffe/stitch_pyramid/JPEGImage.h | 6 +++- python/caffe/stitch_pyramid/JPEGPyramid.cpp | 3 +- python/caffe/stitch_pyramid/Patchwork.cpp | 5 +-- .../stitch_pyramid/test_stitch_pyramid.cpp | 2 +- 5 files changed, 46 insertions(+), 6 deletions(-) diff --git a/python/caffe/stitch_pyramid/JPEGImage.cpp b/python/caffe/stitch_pyramid/JPEGImage.cpp index 78a09322507..70ebbdee70f 100644 --- a/python/caffe/stitch_pyramid/JPEGImage.cpp +++ b/python/caffe/stitch_pyramid/JPEGImage.cpp @@ -29,6 +29,36 @@ using namespace FFLD; using namespace std; +//thanks: http://stackoverflow.com/questions/11641629/generating-a-uniform-distribution-of-integers-in-c +//uniform_distribution returns an INTEGER in [rangeLow, rangeHigh], inclusive. +inline int uniform_distribution(int rangeLow, int rangeHigh) +{ + int myRand = (int)rand(); + int range = rangeHigh - rangeLow + 1; //+1 makes it [rangeLow, rangeHigh], inclusive. + int myRand_scaled = (myRand % range) + rangeLow; + return myRand_scaled; +} + +// THIS IS VERY SLOWWWW: +//to avoid hard borders on images in plane (which look like edges to the convnet) +void JPEGImage::fill_with_rand(){ + //int height = img.height(); + //int width = img.width(); + //int depth = img.depth(); + int height = this->height(); + int width = this->width(); + int depth = this->depth(); + + for (int y = 0; y < height; y++){ + for (int x = 0; x < width; x++){ + for (int ch = 0; ch < depth; ch++){ + + this->bits()[y*width*depth + x*depth + ch] = (uint8_t)uniform_distribution(0, 255); + } + } + } +} + JPEGImage::JPEGImage() : width_(0), height_(0), depth_(0) { } @@ -249,7 +279,7 @@ JPEGImage JPEGImage::crop(int x, int y, int width, int height) const } //TODO: remove const? -JPEGImage JPEGImage::pad(int padx, int pady) const +JPEGImage JPEGImage::pad(int padx, int pady, bool randPad) const { // empty image if( (padx < 0) || (pady < 0) ) @@ -268,6 +298,10 @@ JPEGImage JPEGImage::pad(int padx, int pady) const result.depth_ = depth_; result.bits_.resize(dstWidth * dstHeight * depth_); + if(randPad == true) + result.fill_with_rand(); + //fill_with_rand(result); + //rectangle packing offsets: int x_off = padx; int y_off = pady; diff --git a/python/caffe/stitch_pyramid/JPEGImage.h b/python/caffe/stitch_pyramid/JPEGImage.h index f5a87a2e21a..c008293873d 100644 --- a/python/caffe/stitch_pyramid/JPEGImage.h +++ b/python/caffe/stitch_pyramid/JPEGImage.h @@ -33,6 +33,9 @@ namespace FFLD class JPEGImage { public: + + void fill_with_rand(); //fill self with random numbers (e.g. before filling w/ data so we get rand-padding) + /// Constructs an empty image. An empty image has zero size. JPEGImage(); @@ -85,7 +88,8 @@ class JPEGImage /// @note The returned image might be smaller if some of the coordinates are outside the image. JPEGImage crop(int x, int y, int width, int height) const; - JPEGImage pad(int x, int y) const; + // @param randPad = whether to use random numbers in padding (or, if false, use zero padding) + JPEGImage pad(int x, int y, bool randPad) const; private: // Blur and downscale an image by a factor 2 diff --git a/python/caffe/stitch_pyramid/JPEGPyramid.cpp b/python/caffe/stitch_pyramid/JPEGPyramid.cpp index ba44b5b3d35..28873a0af00 100644 --- a/python/caffe/stitch_pyramid/JPEGPyramid.cpp +++ b/python/caffe/stitch_pyramid/JPEGPyramid.cpp @@ -77,7 +77,8 @@ pady_(0), interval_(0) double scale = pow(2.0, static_cast(-i) / interval); JPEGImage scaled = image.resize(image.width() * scale + 0.5, image.height() * scale + 0.5); - scaled = scaled.pad(padx, pady); //an additional deepcopy. (for efficiency, could have 'resize()' accept padding too + bool use_randPad = false; + scaled = scaled.pad(padx, pady, use_randPad); //an additional deepcopy. (for efficiency, could have 'resize()' accept padding too levels_[i] = scaled; } diff --git a/python/caffe/stitch_pyramid/Patchwork.cpp b/python/caffe/stitch_pyramid/Patchwork.cpp index f0a53e8ece4..1c9296f332a 100644 --- a/python/caffe/stitch_pyramid/Patchwork.cpp +++ b/python/caffe/stitch_pyramid/Patchwork.cpp @@ -62,9 +62,10 @@ interval_(pyramid.interval()) return; planes_.resize(nbPlanes); + #pragma omp parallel for for (int i = 0; i < nbPlanes; ++i) { - //planes_[i] = Plane::Constant(MaxRows_, HalfCols_, Cell::Zero()); planes_[i] = JPEGImage(MaxCols_, MaxRows_, JPEGPyramid::NbChannels); //JPEGImage(width, height, depth) + //planes_[i].fill_with_rand(); //random noise that will go between images on plane. (TODO: allow user to enable/disable) } int depth = JPEGPyramid::NbChannels; @@ -92,7 +93,7 @@ interval_(pyramid.interval()) for (int y = 0; y < srcHeight; y++){ for (int x = 0; x < srcWidth; x++){ - for (int ch = 0; ch < JPEGPyramid::NbChannels; ch++){ + for (int ch = 0; ch < depth; ch++){ //currPlane.bits[...] = pyramid.levels()[i].data[...]; currPlane->bits()[((y + y_off)*dstWidth*depth) + ((x + x_off)*depth) + ch] = currLevel->bits()[y*srcWidth*depth + x*depth + ch]; diff --git a/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp b/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp index b49a89f4a7d..b51fb0f44c2 100644 --- a/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp +++ b/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp @@ -161,7 +161,7 @@ int main(int argc, char * argv[]){ int convnet_subsampling_ratio = 1; // we're not actually computing convnet features in this test, // so there's no feature downsampling. vector scaleLocations = unstitch_pyramid_locations(patchwork, convnet_subsampling_ratio); - print_scaleLocations(scaleLocations); + //print_scaleLocations(scaleLocations); return EXIT_SUCCESS; } From 4f25c7c82949d505cb7f7ef14b092858418b1ad6 Mon Sep 17 00:00:00 2001 From: forresti Date: Mon, 20 Jan 2014 19:02:15 -0800 Subject: [PATCH 09/92] remove old featpyramid test; keeping the multiscale test --- python/caffe/imagenet/featpyramid_tests.py | 26 +++++----------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py index 2c5c13a8020..3e4fb8a097b 100644 --- a/python/caffe/imagenet/featpyramid_tests.py +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -32,29 +32,14 @@ def test_pyramid_IO(caffenet, imgFname): caffenet.testString('hi') caffenet.testInt(1337) -def test_featpyramid(caffenet, imgFname): - #blobs_top = features computed on PLANES. - blobs_top = caffenet.extract_featpyramid(imgFname) # THE CRUX - - #print blobs_top[0] - print 'blobs shape: ' - print blobs_top[0].shape - - #prep for visualization (sum over depth of descriptors) - flat_descriptor = np.sum(blobs_top[0], axis=1) #e.g. (1, depth=256, height=124, width=124) -> (1, 124, 124) - flat_descriptor = flat_descriptor[0] #(1, 124, 124) -> (124, 124) ... first image (in a batch size of 1) - - #visualization - pyplot.figure() - pyplot.title('Welcome to deep learning land. You have arrived.') - pyplot.imshow(flat_descriptor, cmap = cm.gray) - pylab.savefig('flat_descriptor.jpg') - - def test_featpyramid_allScales(caffenet, imgFname): #blobs_top = list of feature arrays... one array per scale. blobs_top = caffenet.extract_featpyramid(imgFname) # THE CRUX + # optional breakpoint... + #from IPython import embed + #embed() + for i in xrange(0, len(blobs_top)): print 'blobs[%d] shape: '%i print blobs_top[i].shape @@ -85,6 +70,5 @@ def test_featpyramid_allScales(caffenet, imgFname): #experiments... - test_pyramid_IO(caffenet, imgFname) - #test_featpyramid(caffenet, imgFname) + #test_pyramid_IO(caffenet, imgFname) test_featpyramid_allScales(caffenet, imgFname) From a99c574228d76ca9acfe1867fac5281f939b1d6e Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 13 Mar 2014 15:52:47 -0700 Subject: [PATCH 10/92] add STITCHPYRAMID_{SRC,HDRS} to Makefile (but no usage yet) --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 2eccdc40e0e..b3ad65d6e6d 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,9 @@ NONGEN_CXX_SRCS := $(shell find \ -name "*.cpp" -or -name "*.hpp" -or -name "*.cu" -or -name "*.cuh") LINT_REPORT := $(BUILD_DIR)/cpp_lint.log FAILED_LINT_REPORT := $(BUILD_DIR)/cpp_lint.error_log +# STITCHPYRAMID is for stitching multiresolution feature pyramids. (exclude test files) +STITCHPYRAMID_SRC := $(shell find python/caffe/stitch_pyramid/build ! -name "test_*.cpp" -name "*.cpp") +STITCHPYRAMID_HDRS := $(shell find python/caffe/stitch_pyramid/build -name "*.h") # PY$(PROJECT)_SRC is the python wrapper for $(PROJECT) PY$(PROJECT)_SRC := python/$(PROJECT)/py$(PROJECT).cpp PY$(PROJECT)_SO := python/$(PROJECT)/py$(PROJECT).so From 5944af5dc5348089ca033a07ab138e1ffb371ab7 Mon Sep 17 00:00:00 2001 From: forresti Date: Tue, 21 Jan 2014 12:28:59 -0800 Subject: [PATCH 11/92] convinced the make system to also build PyramidStitcher when we do 'make pycaffe' --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b3ad65d6e6d..74d81c094ee 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,7 @@ FAILED_LINT_REPORT := $(BUILD_DIR)/cpp_lint.error_log # STITCHPYRAMID is for stitching multiresolution feature pyramids. (exclude test files) STITCHPYRAMID_SRC := $(shell find python/caffe/stitch_pyramid/build ! -name "test_*.cpp" -name "*.cpp") STITCHPYRAMID_HDRS := $(shell find python/caffe/stitch_pyramid/build -name "*.h") +STITCHPYRAMID_SO := python/caffe/stitch_pyramid/libPyramidStitcher.so # PY$(PROJECT)_SRC is the python wrapper for $(PROJECT) PY$(PROJECT)_SRC := python/$(PROJECT)/py$(PROJECT).cpp PY$(PROJECT)_SO := python/$(PROJECT)/py$(PROJECT).so @@ -142,9 +143,12 @@ tools: init $(TOOL_BINS) examples: init $(EXAMPLE_BINS) +$(STITCHPYRAMID_SO): $(STITCHPYRAMID_HDRS) $(STITCHPYRAMID_SRC) + $(CXX) -shared -o $(STITCHPYRAMID_SO) $(STITCHPYRAMID_SRC) $(CXXFLAGS) + py$(PROJECT): py -py: init $(STATIC_NAME) $(PY$(PROJECT)_SRC) $(PROTO_GEN_PY) +py: init $(STATIC_NAME) $(PY$(PROJECT)_SRC) $(PROTO_GEN_PY) $(STITCHPYRAMID_SO) $(CXX) -shared -o $(PY$(PROJECT)_SO) $(PY$(PROJECT)_SRC) -L./python/caffe/stitch_pyramid/build -lPyramidStitcher -I./python/caffe/stitch_pyramid \ $(STATIC_NAME) $(CXXFLAGS) $(PYTHON_LDFLAGS) @echo From f76ca85835263bb03afb8e5cc727ac3ae18d34ab Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Tue, 18 Mar 2014 15:07:43 -0700 Subject: [PATCH 12/92] use single imagenet mean pixel for data centering in feature pyramid --- include/caffe/imagenet_mean.hpp | 15 ++++++ python/caffe/imagenet/featpyramid_tests.py | 2 +- python/caffe/pycaffe.cpp | 54 +++++++++++++++++----- 3 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 include/caffe/imagenet_mean.hpp diff --git a/include/caffe/imagenet_mean.hpp b/include/caffe/imagenet_mean.hpp new file mode 100644 index 00000000000..5b240348167 --- /dev/null +++ b/include/caffe/imagenet_mean.hpp @@ -0,0 +1,15 @@ +#ifndef IMAGENET_MEAN_H +#define IMAGENET_MEAN_H + +//mean of all imagenet classification images +// calculation: +// 1. mean of all imagenet images, per pixel location +// 2. take the mean image, and get the mean pixel for R,G,B +// (did it this way because we already had the 'mean of all images, per pixel location') + + +#define IMAGENET_MEAN_R 122.67f +#define IMAGENET_MEAN_G 116.66f +#define IMAGENET_MEAN_B 104.00f + +#endif diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py index 3e4fb8a097b..6dd46218298 100644 --- a/python/caffe/imagenet/featpyramid_tests.py +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -51,7 +51,7 @@ def test_featpyramid_allScales(caffenet, imgFname): #visualization pyplot.figure() pyplot.title('Welcome to deep learning land. You have arrived.') - pyplot.imshow(flat_descriptor, cmap = cm.gray) + pyplot.imshow(flat_descriptor, cmap = cm.gray, interpolation='nearest') pylab.savefig('output_pyra/flat_descriptor_scale%d.jpg' %i) if __name__ == "__main__": diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index f923c620094..01447320e39 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -13,6 +13,7 @@ #include // NOLINT(build/include_order) #include "caffe/caffe.hpp" +#include "caffe/imagenet_mean.hpp" #include "stitch_pyramid/PyramidStitcher.h" //also includes JPEGImage, Patchwork, etc // Temporary solution for numpy < 1.7 versions: old macro, no promises. @@ -230,9 +231,43 @@ struct CaffeNet { return pyramid_float_npy_boost; } + //switch RGB to BGR indexing (for Caffe convention) + int get_BGR(int channel_RGB){ + int channel_BGR; //output + + if(channel_RGB == 0) + channel_BGR = 2; + + if(channel_RGB == 1) + channel_BGR = 1; + + if(channel_RGB == 2) + channel_BGR = 0; + + return channel_BGR; + } + + // get avg value for imagenet pixels on particular channel + // these are defined in caffe/include/caffe/imagenet_mean.hpp + float get_mean_RGB(int channel_RGB){ + float channel_mean; //output + + if(channel_RGB==0) + channel_mean = IMAGENET_MEAN_R; + + else if (channel_RGB==1) + channel_mean = IMAGENET_MEAN_G; + + else if (channel_RGB==2) + channel_mean = IMAGENET_MEAN_B; + + return channel_mean; + } + + // for now, one batch at a time. (later, can modify this to allocate & fill a >1 batch 4d array) // @param jpeg = typically a plane from Patchwork, in packed JPEG [RGB,RGB,RGB] format - // @return numpy float array of jpeg, in unpacked [RRRRR..,GGGGG..,BBBBB..] format + // @return numpy float array of jpeg, in unpacked [BBBBB..,GGGGG..,RRRRR..] format with channel mean subtracted PyArrayObject* JPEGImage_to_numpy_float(JPEGImage &jpeg){ int depth = jpeg.depth(); @@ -243,15 +278,15 @@ struct CaffeNet { PyArrayObject* jpeg_float_npy = (PyArrayObject*)PyArray_New( &PyArray_Type, 4, dims, NPY_FLOAT, 0, 0, 0, 0, 0 ); //numpy malloc - //TODO: make sure of RGB vs BGR (just for documentation purposes) - //copy jpeg into jpeg_float_npy - for(int y=0; y Date: Wed, 22 Jan 2014 15:10:54 -0800 Subject: [PATCH 13/92] streamlining upsampling/downsampling code. going to return scale factors (as Sergey suggested) --- python/caffe/stitch_pyramid/JPEGPyramid.cpp | 13 +++++++------ python/caffe/stitch_pyramid/JPEGPyramid.h | 8 +++++++- python/caffe/stitch_pyramid/Patchwork.cpp | 2 ++ python/caffe/stitch_pyramid/Patchwork.h | 8 +++++--- python/caffe/stitch_pyramid/PyramidStitcher.cpp | 6 ++++-- python/caffe/stitch_pyramid/test_stitch_pyramid.cpp | 8 ++++++++ 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/python/caffe/stitch_pyramid/JPEGPyramid.cpp b/python/caffe/stitch_pyramid/JPEGPyramid.cpp index 28873a0af00..1733599363b 100644 --- a/python/caffe/stitch_pyramid/JPEGPyramid.cpp +++ b/python/caffe/stitch_pyramid/JPEGPyramid.cpp @@ -52,27 +52,27 @@ pady_(0), interval_(0) levels_ = levels; } -JPEGPyramid::JPEGPyramid(const JPEGImage & image, int padx, int pady, int interval) : padx_(0), +JPEGPyramid::JPEGPyramid(const JPEGImage & image, int padx, int pady, int interval, int upsampleFactor) : padx_(0), pady_(0), interval_(0) { if (image.empty() || (padx < 1) || (pady < 1) || (interval < 1)) return; // Copmute the number of scales such that the smallest size of the last level is 5 - const int maxScale = ceil(log(min(image.width(), image.height()) / 40.0) / log(2.0)) * interval; + const int numScales = ceil(log(min(image.width(), image.height()) / 40.0) / log(2.0)) * interval; //'max_scale' in voc5 featpyramid.m // Cannot compute the pyramid on images too small - if (maxScale < interval) + if (numScales < interval) return; padx_ = padx; pady_ = pady; interval_ = interval; - levels_.resize(maxScale + 1); - vector scales(maxScale+1); + levels_.resize(numScales+1); + scales_.resize(numScales+1); #pragma omp parallel for - for (int i = 0; i <= maxScale; ++i){ + for (int i = 0; i <= numScales; ++i){ //generic pyramid... not stitched. double scale = pow(2.0, static_cast(-i) / interval); @@ -80,6 +80,7 @@ pady_(0), interval_(0) bool use_randPad = false; scaled = scaled.pad(padx, pady, use_randPad); //an additional deepcopy. (for efficiency, could have 'resize()' accept padding too + scales_[i] = scale; levels_[i] = scaled; } } diff --git a/python/caffe/stitch_pyramid/JPEGPyramid.h b/python/caffe/stitch_pyramid/JPEGPyramid.h index 97c0a8cfa5d..bfbab965a78 100644 --- a/python/caffe/stitch_pyramid/JPEGPyramid.h +++ b/python/caffe/stitch_pyramid/JPEGPyramid.h @@ -26,6 +26,8 @@ //#include //#include +using namespace std; + namespace FFLD { /// The JPEGPyramid class computes and stores the HOG features extracted from a jpeg image at @@ -81,8 +83,9 @@ class JPEGPyramid /// @param[in] padx Amount of horizontal zero padding (in cells). /// @param[in] pady Amount of vertical zero padding (in cells). /// @param[in] interval Number of levels per octave in the pyramid. + /// @param[in] upsampleFactor = how big should top scale be? (compared to input img) /// @note The amount of padding and the interval should be at least 1. - JPEGPyramid(const JPEGImage & image, int padx, int pady, int interval = 10); + JPEGPyramid(const JPEGImage & image, int padx, int pady, int interval = 10, int upsampleFactor = 2); /// Returns whether the pyramid is empty. An empty pyramid has no level. bool empty() const; @@ -100,6 +103,9 @@ class JPEGPyramid /// @note Scales are given by the following formula: 2^(1 - @c index / @c interval). const std::vector & levels() const; + //upsampling/downsampling multipliers. (scales_[i] corresponds to levels_[i]) + vector scales_; + private: int padx_; int pady_; diff --git a/python/caffe/stitch_pyramid/Patchwork.cpp b/python/caffe/stitch_pyramid/Patchwork.cpp index 1c9296f332a..98cf27f0a77 100644 --- a/python/caffe/stitch_pyramid/Patchwork.cpp +++ b/python/caffe/stitch_pyramid/Patchwork.cpp @@ -42,6 +42,8 @@ Patchwork::Patchwork() : padx_(0), pady_(0), interval_(0) Patchwork::Patchwork(const JPEGPyramid & pyramid) : padx_(pyramid.padx()), pady_(pyramid.pady()), interval_(pyramid.interval()) { + scales_ = pyramid.scales_; //keep track of pyra scales + nbScales = pyramid.levels().size(); //Patchwork class variable //cout << " nbScales = " << nbScales << endl; //printf(" MaxRows_ = %d, MaxCols_=%d \n", MaxRows_, MaxCols_); diff --git a/python/caffe/stitch_pyramid/Patchwork.h b/python/caffe/stitch_pyramid/Patchwork.h index 1000d39946d..1a7baf98116 100644 --- a/python/caffe/stitch_pyramid/Patchwork.h +++ b/python/caffe/stitch_pyramid/Patchwork.h @@ -25,6 +25,7 @@ #include "Rectangle.h" #include +using namespace std; namespace FFLD { @@ -92,13 +93,14 @@ class Patchwork /// Returns the current maximum number of columns of a pyramid level (including padding). static int MaxCols(); - std::vector planes_; + vector planes_; int nbScales; int padx_; int pady_; int interval_; - std::vector > rectangles_; + vector > rectangles_; + vector scales_; static int MaxRows_; //TODO: make these public. static int MaxCols_; @@ -106,7 +108,7 @@ class Patchwork private: // Bottom-Left fill algorithm - static int BLF(std::vector > & rectangles); + static int BLF(vector > & rectangles); }; } diff --git a/python/caffe/stitch_pyramid/PyramidStitcher.cpp b/python/caffe/stitch_pyramid/PyramidStitcher.cpp index 10b9f76521c..461031f9507 100644 --- a/python/caffe/stitch_pyramid/PyramidStitcher.cpp +++ b/python/caffe/stitch_pyramid/PyramidStitcher.cpp @@ -26,10 +26,12 @@ Patchwork stitch_pyramid(string file, int padding, int interval, int planeDim) } //image = image.resize(image.width()*4, image.height()*4); //UPSAMPLE so that Caffe's 16x downsampling looks like 4x downsampling - image = image.resize(image.width()*2, image.height()*2); //UPSAMPLE so that Caffe's 16x downsampling looks like 8x downsampling + //image = image.resize(image.width()*2, image.height()*2); //UPSAMPLE so that Caffe's 16x downsampling looks like 8x downsampling + + int upsampleFactor = 2; // Compute the downsample+stitch - JPEGPyramid pyramid(image, padding, padding, interval); //multiscale DOWNSAMPLE with (padx == pady == padding) + JPEGPyramid pyramid(image, padding, padding, interval, upsampleFactor); //multiscale DOWNSAMPLE with (padx == pady == padding) if (pyramid.empty()) { cerr << "\nInvalid image " << file << endl; } diff --git a/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp b/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp index b51fb0f44c2..ebe5da97149 100644 --- a/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp +++ b/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp @@ -133,6 +133,7 @@ void printScaleSizes(JPEGPyramid pyramid); void writePyraToJPG(JPEGPyramid pyramid); void writePatchworkToJPG(Patchwork patchwork, string output_stitched_dir, string base_filename); void print_scaleLocations(vector scaleLocations); +void print_scales(Patchwork patchwork); //TODO: split this test into its own function, e.g. test_stitch_pyramid() int main(int argc, char * argv[]){ @@ -162,6 +163,7 @@ int main(int argc, char * argv[]){ // so there's no feature downsampling. vector scaleLocations = unstitch_pyramid_locations(patchwork, convnet_subsampling_ratio); //print_scaleLocations(scaleLocations); + print_scales(patchwork); return EXIT_SUCCESS; } @@ -211,3 +213,9 @@ void writePatchworkToJPG(Patchwork patchwork, string output_stitched_dir, string } } +void print_scales(Patchwork patchwork){ + for(int i=0; i Date: Wed, 22 Jan 2014 15:13:23 -0800 Subject: [PATCH 14/92] new downsampling param passing looks good. --- python/caffe/stitch_pyramid/JPEGPyramid.cpp | 2 +- python/caffe/stitch_pyramid/PyramidStitcher.cpp | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/python/caffe/stitch_pyramid/JPEGPyramid.cpp b/python/caffe/stitch_pyramid/JPEGPyramid.cpp index 1733599363b..fd278ebcb15 100644 --- a/python/caffe/stitch_pyramid/JPEGPyramid.cpp +++ b/python/caffe/stitch_pyramid/JPEGPyramid.cpp @@ -75,7 +75,7 @@ pady_(0), interval_(0) for (int i = 0; i <= numScales; ++i){ //generic pyramid... not stitched. - double scale = pow(2.0, static_cast(-i) / interval); + double scale = pow(2.0, static_cast(-i) / interval) * upsampleFactor; JPEGImage scaled = image.resize(image.width() * scale + 0.5, image.height() * scale + 0.5); bool use_randPad = false; scaled = scaled.pad(padx, pady, use_randPad); //an additional deepcopy. (for efficiency, could have 'resize()' accept padding too diff --git a/python/caffe/stitch_pyramid/PyramidStitcher.cpp b/python/caffe/stitch_pyramid/PyramidStitcher.cpp index 461031f9507..da3f9f14ad5 100644 --- a/python/caffe/stitch_pyramid/PyramidStitcher.cpp +++ b/python/caffe/stitch_pyramid/PyramidStitcher.cpp @@ -25,10 +25,7 @@ Patchwork stitch_pyramid(string file, int padding, int interval, int planeDim) cerr << "\nInvalid image " << file << endl; } - //image = image.resize(image.width()*4, image.height()*4); //UPSAMPLE so that Caffe's 16x downsampling looks like 4x downsampling - //image = image.resize(image.width()*2, image.height()*2); //UPSAMPLE so that Caffe's 16x downsampling looks like 8x downsampling - - int upsampleFactor = 2; + int upsampleFactor = 2; //TODO: make this an input param? // Compute the downsample+stitch JPEGPyramid pyramid(image, padding, padding, interval, upsampleFactor); //multiscale DOWNSAMPLE with (padx == pady == padding) @@ -44,7 +41,7 @@ Patchwork stitch_pyramid(string file, int padding, int interval, int planeDim) planeHeight = planeDim; } else{ - planeWidth = (pyramid.levels()[0].width() + 15) & ~15; //TODO: don't subtract padx, pady? + planeWidth = (pyramid.levels()[0].width() + 15) & ~15; planeHeight = (pyramid.levels()[0].height() + 15) & ~15; planeWidth = max(planeWidth, planeHeight); //SQUARE planes for Caffe convnet planeHeight = max(planeWidth, planeHeight); From d506d66bed2c88c105864d4c752a0d35eda7bbb3 Mon Sep 17 00:00:00 2001 From: forresti Date: Wed, 22 Jan 2014 15:16:40 -0800 Subject: [PATCH 15/92] remove Eigen debris --- python/caffe/stitch_pyramid/JPEGPyramid.cpp | 3 -- python/caffe/stitch_pyramid/JPEGPyramid.h | 35 --------------------- python/caffe/stitch_pyramid/Patchwork.cpp | 3 +- python/caffe/stitch_pyramid/Patchwork.h | 29 +---------------- 4 files changed, 2 insertions(+), 68 deletions(-) diff --git a/python/caffe/stitch_pyramid/JPEGPyramid.cpp b/python/caffe/stitch_pyramid/JPEGPyramid.cpp index fd278ebcb15..75c711a9242 100644 --- a/python/caffe/stitch_pyramid/JPEGPyramid.cpp +++ b/python/caffe/stitch_pyramid/JPEGPyramid.cpp @@ -26,13 +26,10 @@ #include #include -//#define DISABLE_HOG_BLOCKS //if defined: just compute hog cells; don't normalize into hog blocks - #ifndef M_PI #define M_PI 3.14159265358979323846 #endif -//using namespace Eigen; using namespace FFLD; using namespace std; diff --git a/python/caffe/stitch_pyramid/JPEGPyramid.h b/python/caffe/stitch_pyramid/JPEGPyramid.h index bfbab965a78..28a5349b535 100644 --- a/python/caffe/stitch_pyramid/JPEGPyramid.h +++ b/python/caffe/stitch_pyramid/JPEGPyramid.h @@ -23,9 +23,6 @@ #include "JPEGImage.h" -//#include -//#include - using namespace std; namespace FFLD @@ -46,25 +43,9 @@ class JPEGPyramid static const int NbChannels = 3; //RGB /// Type of a scalar value. -#ifndef FFLD_JPEGPYRAMID_DOUBLE typedef float Scalar; -#else - typedef double Scalar; -#endif - - /// Type of a matrix. - //typedef Eigen::Matrix Matrix; - -#if 0 - /// Type of a sparse matrix. - typedef Eigen::SparseMatrix SparseMatrix; - - /// Type of a pyramid level cell (fixed-size vector of length NbChannels). - typedef Eigen::Array Cell; -#endif /// Type of a pyramid level (matrix of cells). - //typedef Eigen::Matrix Level; typedef JPEGImage Level; /// Constructs an empty pyramid. An empty pyramid has no level. @@ -114,20 +95,4 @@ class JPEGPyramid }; } -#if 0 -// Some compilers complain about the lack of a NumTraits for Eigen::Array -namespace Eigen -{ -template <> -struct NumTraits > : - GenericNumTraits > -{ - static inline FFLD::JPEGPyramid::Scalar dummy_precision() - { - return 0; // Never actually called - } -}; -} -#endif - #endif diff --git a/python/caffe/stitch_pyramid/Patchwork.cpp b/python/caffe/stitch_pyramid/Patchwork.cpp index 98cf27f0a77..b1eaa1707c1 100644 --- a/python/caffe/stitch_pyramid/Patchwork.cpp +++ b/python/caffe/stitch_pyramid/Patchwork.cpp @@ -27,7 +27,6 @@ #include #include -//using namespace Eigen; using namespace FFLD; using namespace std; @@ -74,7 +73,7 @@ interval_(pyramid.interval()) // [Forrest implemented... ] //COPY scaled images -> fixed-size planes -#pragma omp parallel for + #pragma omp parallel for for (int i = 0; i < nbScales; ++i) { //currPlane is destination diff --git a/python/caffe/stitch_pyramid/Patchwork.h b/python/caffe/stitch_pyramid/Patchwork.h index 1a7baf98116..a31d21dc2d2 100644 --- a/python/caffe/stitch_pyramid/Patchwork.h +++ b/python/caffe/stitch_pyramid/Patchwork.h @@ -33,19 +33,8 @@ namespace FFLD class Patchwork { public: - /// Type of a scalar value. - //typedef std::complex Scalar; -#if 0 - /// Type of a matrix. - typedef Eigen::Matrix Matrix; - - /// Type of a patchwork plane cell (fixed-size complex vector of size NbChannels). - typedef Eigen::Array Cell; -#endif - - /// Type of a patchwork plane (matrix of cells). - //typedef Eigen::Matrix Plane; + /// Type of a patchwork plane . typedef JPEGImage Plane; /// Type of a patchwork filter (plane + original filter size). @@ -113,20 +102,4 @@ class Patchwork }; } -#if 0 -// Some compilers complain about the lack of a NumTraits for Eigen::Array -namespace Eigen -{ -template <> -struct NumTraits > : - GenericNumTraits > -{ - static inline FFLD::JPEGPyramid::Scalar dummy_precision() - { - return 0; // Never actually called - } -}; -} -#endif - #endif From b1c06e0a8d28676a94f3635b6f2b9961219986c4 Mon Sep 17 00:00:00 2001 From: forresti Date: Wed, 22 Jan 2014 15:30:55 -0800 Subject: [PATCH 16/92] testing boost::python functonality of returning dictionaries from C++. works. --- python/caffe/imagenet/featpyramid_tests.py | 8 ++++-- python/caffe/pycaffe.cpp | 32 ++++++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py index 6dd46218298..ba0a9ef5d6b 100644 --- a/python/caffe/imagenet/featpyramid_tests.py +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -32,6 +32,10 @@ def test_pyramid_IO(caffenet, imgFname): caffenet.testString('hi') caffenet.testInt(1337) + print "\n example dict from C++:" + example_dict = caffenet.test_return_dict() + print example_dict + def test_featpyramid_allScales(caffenet, imgFname): #blobs_top = list of feature arrays... one array per scale. blobs_top = caffenet.extract_featpyramid(imgFname) # THE CRUX @@ -70,5 +74,5 @@ def test_featpyramid_allScales(caffenet, imgFname): #experiments... - #test_pyramid_IO(caffenet, imgFname) - test_featpyramid_allScales(caffenet, imgFname) + test_pyramid_IO(caffenet, imgFname) + #test_featpyramid_allScales(caffenet, imgFname) diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index 01447320e39..91ecedd2dba 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -264,7 +264,6 @@ struct CaffeNet { return channel_mean; } - // for now, one batch at a time. (later, can modify this to allocate & fill a >1 batch 4d array) // @param jpeg = typically a plane from Patchwork, in packed JPEG [RGB,RGB,RGB] format // @return numpy float array of jpeg, in unpacked [BBBBB..,GGGGG..,RRRRR..] format with channel mean subtracted @@ -416,7 +415,33 @@ struct CaffeNet { boost::python::list blobs_top_boost; //list to return blobs_top_boost.append(pyramid_float_npy_boost); //put the output array in list - return blobs_top_boost; //compile error: return-statement with no value + return blobs_top_boost; + } + + boost::python::dict test_return_dict() + { + int batchsize = 1; + int depth_ = 1; + int MaxHeight_ = 3; + int MaxWidth_ = 3; + + //prepare data that we'll send to Python + float* pyramid_float = (float*)malloc(sizeof(float) * batchsize * depth_ * MaxHeight_ * MaxWidth_); + memset(pyramid_float, 0, sizeof(float) * batchsize * depth_ * MaxHeight_ * MaxWidth_); + pyramid_float[4] = 123; //test -- see if it shows up in Python + + boost::python::object pyramid_float_npy_boost = array_to_boostPython_4d(pyramid_float, batchsize, depth_, MaxHeight_, MaxWidth_); + boost::python::list blobs_top_boost; //list to return + blobs_top_boost.append(pyramid_float_npy_boost); //put the output array in list + + string myStr = "ohai"; + + boost::python::dict d; + d["pyramid"] = blobs_top_boost; + d["note"] = myStr; + + //return blobs_top_boost; + return d; } //return a slice ("view") of a numpy array @@ -530,7 +555,8 @@ BOOST_PYTHON_MODULE(pycaffe) { .def("set_device", &CaffeNet::set_device) .def("testIO", &CaffeNet::testIO) //Forrest's test (return a numpy array) .def("test_NumpyView", &CaffeNet::test_NumpyView) //Forrest's test (return view of a numpy array) - .def("testString", &CaffeNet::testString) + .def("testString", &CaffeNet::testString) + .def("test_return_dict", &CaffeNet::test_return_dict) .def("testInt", &CaffeNet::testInt) .def("extract_featpyramid", &CaffeNet::extract_featpyramid) //NEW .def("blobs", &CaffeNet::blobs) From 7c1ea808971c89dc273b4bca3e78ac940198dd21 Mon Sep 17 00:00:00 2001 From: forresti Date: Wed, 22 Jan 2014 15:40:19 -0800 Subject: [PATCH 17/92] now returning a DICT instead of a LIST from extract_features(). the new data type is dict['feat'] = list of feature scales --- python/caffe/imagenet/featpyramid_tests.py | 17 +++++++++-------- python/caffe/pycaffe.cpp | 18 ++++++++++-------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py index ba0a9ef5d6b..c6c9012c3e1 100644 --- a/python/caffe/imagenet/featpyramid_tests.py +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -37,19 +37,20 @@ def test_pyramid_IO(caffenet, imgFname): print example_dict def test_featpyramid_allScales(caffenet, imgFname): - #blobs_top = list of feature arrays... one array per scale. - blobs_top = caffenet.extract_featpyramid(imgFname) # THE CRUX + + pyra = caffenet.extract_featpyramid(imgFname) # THE CRUX + feat = pyra["feat"] # optional breakpoint... #from IPython import embed #embed() - for i in xrange(0, len(blobs_top)): - print 'blobs[%d] shape: '%i - print blobs_top[i].shape + for i in xrange(0, len(feat)): + print 'feat[%d] shape: '%i + print feat[i].shape #prep for visualization (sum over depth of descriptors) - flat_descriptor = np.sum(blobs_top[i], axis=1) #e.g. (1, depth=256, height=124, width=124) -> (1, 124, 124) + flat_descriptor = np.sum(feat[i], axis=1) #e.g. (1, depth=256, height=124, width=124) -> (1, 124, 124) flat_descriptor = flat_descriptor[0] #(1, 124, 124) -> (124, 124) ... first image (in a batch size of 1) #visualization @@ -74,5 +75,5 @@ def test_featpyramid_allScales(caffenet, imgFname): #experiments... - test_pyramid_IO(caffenet, imgFname) - #test_featpyramid_allScales(caffenet, imgFname) + #test_pyramid_IO(caffenet, imgFname) + test_featpyramid_allScales(caffenet, imgFname) diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index 91ecedd2dba..07189986577 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -343,7 +343,7 @@ struct CaffeNet { } //void extract_featpyramid(string file){ - boost::python::list extract_featpyramid(string file){ + boost::python::dict extract_featpyramid(string file){ int padding = 16; int interval = 10; @@ -374,9 +374,6 @@ struct CaffeNet { blobs_bottom_tmp.append(currPlane_npy_boost); //put the output array in list [list length = 1, because batchsize = 1] blobs_bottom.append(currPlane_npy_boost); //for long-term keeping (return a list that might be longer than 1) - //TODO: make an option (or separate function) to pull out blobs_bottom to python here. - // (for debugging -- make sure the planes are stitched properly. have done a reasonable job verifying this so far.) - //prep output space PyArrayObject* resultPlane_npy = allocate_resultPlane(); //gets resultPlane dims from shared ptr to net_->output_blobs() boost::python::object resultPlane_npy_boost(boost::python::handle<>((PyObject*)resultPlane_npy)); //numpy -> wrap in boost @@ -387,14 +384,19 @@ struct CaffeNet { Forward(blobs_bottom_tmp, blobs_top_tmp); //lists of blobs... bottom[0]=curr input planes, top_tmp[0]=curr output descriptors } - printf("\n\n in pycaffe.cpp extract_featpyramid(). planeDim=%d\n", planeDim); + //printf("\n\n in pycaffe.cpp extract_featpyramid(). planeDim=%d\n", planeDim); vector scaleLocations = unstitch_pyramid_locations(patchwork, convnet_subsampling_ratio); boost::python::list unstitched_features = unstitch_planes(scaleLocations, blobs_top, resultDepth); - //return blobs_bottom; //for debugging only (stitched pyramid in RGB) - //return blobs_top; //output plane(s) - return unstitched_features; //unstitched pyramid from output plane(s) + boost::python::dict d; + //d["blobs_top"] = blobs_top; //for debugging -- stitched pyra in RGB + //d["blobs_bottom"] = blobs_bottom; //for debugging -- stitched descriptors + d["feat"] = unstitched_features; + + //TODO: d["scales"] = patchwork.scales_; + + return d; } //return a list containing one 4D numpy/boost array. (toy example) From 0af3167eceab3f9311792a5344d19979733e01fd Mon Sep 17 00:00:00 2001 From: forresti Date: Wed, 22 Jan 2014 15:58:16 -0800 Subject: [PATCH 18/92] avoid having 'scales' go out of scope... --- python/caffe/imagenet/featpyramid_tests.py | 3 +++ python/caffe/pycaffe.cpp | 27 ++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py index c6c9012c3e1..0b59f6fb53f 100644 --- a/python/caffe/imagenet/featpyramid_tests.py +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -59,6 +59,9 @@ def test_featpyramid_allScales(caffenet, imgFname): pyplot.imshow(flat_descriptor, cmap = cm.gray, interpolation='nearest') pylab.savefig('output_pyra/flat_descriptor_scale%d.jpg' %i) + print "\n pyra scales:" + print pyra["scales"] + if __name__ == "__main__": #pretend that these flags came off the command line: diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index 07189986577..872c26f4aee 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -307,6 +307,25 @@ struct CaffeNet { return resultPlane; } + //pull list of scales out of patchwork; pack it into boost::python array + boost::python::object get_scales_boost(Patchwork patchwork){ + vector scales = patchwork.scales_; + int dim = scales.size(); + npy_intp dims[1] = {dim}; + + //PyArrayObject* scales_npy = (PyArrayObject*)PyArray_New( &PyArray_Type, 1, dims, NPY_FLOAT, 0, &scales[0], 0, 0, 0 ); //not specifying strides + PyArrayObject* scales_npy = (PyArrayObject*)PyArray_New( &PyArray_Type, 1, dims, NPY_FLOAT, 0, 0, 0, 0, 0 ); + for(int i=0; i((PyObject*)scales_npy)); + + return scales_npy_boost; + } + // @param scaleLocs = location of each scale on planes (see unstitch_pyramid_locations in PyramidStitcher.cpp) // @param descriptor_planes -- each element of the list is a plane of Caffe descriptors // typically, descriptor_planes = blobs_top. @@ -384,17 +403,17 @@ struct CaffeNet { Forward(blobs_bottom_tmp, blobs_top_tmp); //lists of blobs... bottom[0]=curr input planes, top_tmp[0]=curr output descriptors } - //printf("\n\n in pycaffe.cpp extract_featpyramid(). planeDim=%d\n", planeDim); + printf("\n\n in pycaffe.cpp extract_featpyramid(). planeDim=%d\n", planeDim); vector scaleLocations = unstitch_pyramid_locations(patchwork, convnet_subsampling_ratio); boost::python::list unstitched_features = unstitch_planes(scaleLocations, blobs_top, resultDepth); + boost::python::object scales_npy_boost = get_scales_boost(patchwork); - boost::python::dict d; + boost::python::dict d; //d["blobs_top"] = blobs_top; //for debugging -- stitched pyra in RGB //d["blobs_bottom"] = blobs_bottom; //for debugging -- stitched descriptors d["feat"] = unstitched_features; - - //TODO: d["scales"] = patchwork.scales_; + d["scales"] = scales_npy_boost; return d; } From 45a327fb74da772ed4be471fcb83cb6df8e6ffb6 Mon Sep 17 00:00:00 2001 From: forresti Date: Wed, 22 Jan 2014 15:59:42 -0800 Subject: [PATCH 19/92] returning scales that make sense --- python/caffe/pycaffe.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index 872c26f4aee..4c97bbe8025 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -313,12 +313,9 @@ struct CaffeNet { int dim = scales.size(); npy_intp dims[1] = {dim}; - //PyArrayObject* scales_npy = (PyArrayObject*)PyArray_New( &PyArray_Type, 1, dims, NPY_FLOAT, 0, &scales[0], 0, 0, 0 ); //not specifying strides - PyArrayObject* scales_npy = (PyArrayObject*)PyArray_New( &PyArray_Type, 1, dims, NPY_FLOAT, 0, 0, 0, 0, 0 ); + PyArrayObject* scales_npy = (PyArrayObject*)PyArray_New( &PyArray_Type, 1, dims, NPY_FLOAT, 0, 0, 0, 0, 0 ); //malloc new memory for(int i=0; i((PyObject*)scales_npy)); From e904f256e2e0b7b95a8adb0579355d9e6a815762 Mon Sep 17 00:00:00 2001 From: forresti Date: Wed, 22 Jan 2014 19:33:36 -0800 Subject: [PATCH 20/92] cleanup. not officially supporting 'return unstitched features' to python user --- python/caffe/pycaffe.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index 4c97bbe8025..83d4da50700 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -371,10 +371,6 @@ struct CaffeNet { assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) //TODO: verify/assert that top-upsampled version of input img fits within planeDim - //TODO: think about how to use image_mean. - // ignoring image_mean for now, because the 'subtract image mean from whatever input region we get' - // thing in r-cnn feels kinda silly. - Patchwork patchwork = stitch_pyramid(file, padding, interval, planeDim); int nbPlanes = patchwork.planes_.size(); @@ -407,8 +403,8 @@ struct CaffeNet { boost::python::object scales_npy_boost = get_scales_boost(patchwork); boost::python::dict d; - //d["blobs_top"] = blobs_top; //for debugging -- stitched pyra in RGB - //d["blobs_bottom"] = blobs_bottom; //for debugging -- stitched descriptors + //d["blobs_bottom"] = blobs_bottom; //for debugging -- stitched pyra in RGB + //d["blobs_top"] = blobs_top; //for debugging -- stitched descriptors d["feat"] = unstitched_features; d["scales"] = scales_npy_boost; From 178c693b7aa5ae45deb4b5580c1889c46c181d64 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 23 Jan 2014 18:39:21 -0800 Subject: [PATCH 21/92] -- initial work on matlab exports for feature pyramid extraction. -- note: this commit almost certainly breaks compilation of matcaffe. mwm --- matlab/caffe/featpyra_common.hpp | 23 ++ matlab/caffe/featpyramid_matcaffe_demo.m | 47 ++++ matlab/caffe/matcaffe.cpp | 275 +++++++++++++++++++++++ 3 files changed, 345 insertions(+) create mode 100644 matlab/caffe/featpyra_common.hpp create mode 100644 matlab/caffe/featpyramid_matcaffe_demo.m diff --git a/matlab/caffe/featpyra_common.hpp b/matlab/caffe/featpyra_common.hpp new file mode 100644 index 00000000000..9b9fb1b3169 --- /dev/null +++ b/matlab/caffe/featpyra_common.hpp @@ -0,0 +1,23 @@ +#include "caffe/imagenet_mean.hpp" + +//switch RGB to BGR indexing (for Caffe convention) +inline int get_BGR(int channel_RGB) { assert( channel_RGB < 3 ); return 2 - channel_RGB; } + + +// get avg value for imagenet pixels on particular channel +// these are defined in caffe/include/caffe/imagenet_mean.hpp +inline float get_mean_RGB(int channel_RGB){ + if(channel_RGB==0) { return float(IMAGENET_MEAN_R); } + if(channel_RGB==1) { return float(IMAGENET_MEAN_G); } + if(channel_RGB==2) { return float(IMAGENET_MEAN_B); } + else { assert(0); } + return 0; +} + +template< typename T > +inline std::string str(T const & i) // convert T i to string +{ + std::stringstream s; + s << i; + return s.str(); +} diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m new file mode 100644 index 00000000000..ca6b827a356 --- /dev/null +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -0,0 +1,47 @@ +function pyra = featpyramid_matcaffe_demo(imfn, use_gpu) +% scores = matcaffe_demo(im, use_gpu) +% +% Demo of the matlab wrapper using the ILSVRC network to produce a feature pyramid. +% +% input +% imfn image filename +% use_gpu 1 to use the GPU, 0 to use the CPU +% +% output +% N row structure array with two fields: scale, feats +% scale: scalar +% feats: 2D numeric array +% +% You may need to do the following before you start matlab: +% $ export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64:/usr/local/cuda/lib64 +% $ export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 +% Or the equivalent based on where things are installed on your system +% +% Usage: +% imfn = '../../examples/cat.jpg'; +% pyra = featpyramid_matcaffe_demo(imfn, 1); + +if ! exist('imfn', 'var') + imfn = '/home/moskewcz/svn_work/boda/test/pascal/000001.jpg' +end + +%model_def_file = '../../examples/imagenet_deploy.prototxt'; +model_def_file = '../../python/caffe/imagenet/imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt' +% NOTE: you'll have to get the pre-trained ILSVRC network +model_file = '../../examples/alexnet_train_iter_470000'; + +% init caffe network (spews logging info) +caffe('init', model_def_file, model_file); + +% set to use GPU or CPU +if exist('use_gpu', 'var') && use_gpu + caffe('set_mode_gpu'); +else + caffe('set_mode_cpu'); +end + +% put into test mode +caffe('set_phase_test'); + +pyra = caffe('extract_featpyramid', imfn ); + diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index ddbacca1579..7db2c585963 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -9,6 +9,10 @@ #include "mex.h" #include "caffe/caffe.hpp" +#include "python/caffe/stitch_pyramid/PyramidStitcher.h" //also includes JPEGImage, Patchwork, etc +#include "boost/shared_ptr.hpp" +#include "featpyra_common.hpp" +#include #define MEX_ARGS int nlhs, mxArray **plhs, int nrhs, const mxArray **prhs @@ -87,6 +91,59 @@ static mxArray* do_forward(const mxArray* const bottom) { return mx_out; } +typedef vector< mxArray * > vect_rp_mxArray; +typedef vector< float > vect_float; +typedef shared_ptr< vect_float > p_vect_float; +typedef vector< p_vect_float > vect_p_vect_float; + +p_vect_float make_p_vect_float( size_t const num ) { + p_vect_float ret( new vect_float ); + ret->resize( num, 0.0f ); + return ret; +}; + + +static void raw_do_forward( vect_p_vect_float const & bottom ) { + vector*>& input_blobs = net_->input_blobs(); + CHECK_EQ(bottom.size(), input_blobs.size()); + for (unsigned int i = 0; i < input_blobs.size(); ++i) { + assert( bottom[i]->size() == uint32_t(input_blobs[i]->count()) ); + const float* const data_ptr = &bottom[i]->front(); + switch (Caffe::mode()) { + case Caffe::CPU: + memcpy(input_blobs[i]->mutable_cpu_data(), data_ptr, + sizeof(float) * input_blobs[i]->count()); + break; + case Caffe::GPU: + cudaMemcpy(input_blobs[i]->mutable_gpu_data(), data_ptr, + sizeof(float) * input_blobs[i]->count(), cudaMemcpyHostToDevice); + break; + default: + LOG(FATAL) << "Unknown Caffe mode."; + } // switch (Caffe::mode()) + } + //const vector*>& output_blobs = net_->ForwardPrefilled(); + net_->ForwardPrefilled(); +} + +static void copy_output_blob_data( uint32_t const output_blob_ix, float * const dest, uint32_t const dest_sz_floats ) +{ + const vector*>& output_blobs = net_->output_blobs(); + if( ! (output_blob_ix < output_blobs.size() ) ) { + LOG(FATAL) << "!(output_blobs_ix < output_blobs.size())"; + } + Blob * const output_blob = output_blobs[output_blob_ix]; + if( dest_sz_floats != (uint32_t)output_blob->count() ) { + LOG(FATAL) << "dest_sz_floats != output_blob->count()"; + } + switch (Caffe::mode()) { + case Caffe::CPU: memcpy(dest, output_blob->cpu_data(), sizeof(float) * dest_sz_floats ); break; + case Caffe::GPU: cudaMemcpy(dest, output_blob->gpu_data(), sizeof(float) * dest_sz_floats, cudaMemcpyDeviceToHost); break; + default: LOG(FATAL) << "Unknown Caffe mode."; + } // switch (Caffe::mode()) +} + + // The caffe::Caffe utility functions. static void set_mode_cpu(MEX_ARGS) { Caffe::set_mode(Caffe::CPU); @@ -139,6 +196,216 @@ static void forward(MEX_ARGS) { plhs[0] = do_forward(prhs[0]); } + +char const * fnames[] = { "scale", "feats" }; +static void test_io(MEX_ARGS) { + if (nrhs != 0) { + LOG(ERROR) << "Given " << nrhs << " arguments, expected 0."; + mexErrMsgTxt("Wrong number of arguments"); + } + if (nlhs != 1) { + LOG(ERROR) << "Caller wanted " << nlhs << " outputs, but this function always produces 1."; + mexErrMsgTxt("Wrong number of outputs"); + } + uint32_t const ret_rows = 5; + mxArray * ret = mxCreateStructMatrix( ret_rows, 1, 2, fnames ); + for( uint32_t r = 0; r < ret_rows; ++r ) { + mxArray * const scale = mxCreateNumericMatrix( 1, 1, mxSINGLE_CLASS, mxREAL ); + float * const scale_ptr = (float*)(mxGetData(scale)); + *scale_ptr = 0.5f + float(r); + mxSetFieldByNumber( ret, r, 0, scale ); + mxArray * const feats = mxCreateNumericMatrix( 3, 3, mxSINGLE_CLASS, mxREAL ); + mxSetFieldByNumber( ret, r, 1, feats ); + } + plhs[0] = ret; +} + +template< typename T > +T sz_from_dims( uint32_t const num_dims, T const * const dims ) { + T ret = 1; + for( uint32_t dim = 0; dim < num_dims; ++dim ) { ret *= dims[dim]; } + return ret; +} + + +void check_dims_equal( uint32_t const num_dims, uint32_t const * const dims_a, uint32_t const * const dims_b ) { + bool dims_eq = 1; + for( uint32_t dim = 0; dim < num_dims; ++dim ) { if( dims_a[dim] != dims_b[dim] ) { dims_eq = 0; } } + if( !dims_eq ) { throw( std::runtime_error( "dims unequal" ) ); } +} + +void check_input_blobs_dims( uint32_t const num_dims, uint32_t const * const dims_b ) +{ + if( num_dims != 4 ) { throw( std::runtime_error( "wrong # dims" ) ); } + int batchsize = net_->input_blobs()[0]->num(); + int depth = net_->input_blobs()[0]->channels(); + int width = net_->input_blobs()[0]->width(); + int height = net_->input_blobs()[0]->height(); + uint32_t dims[4] = {batchsize, depth, height, width}; + check_dims_equal( 4, dims, dims_b ); +} + + +mxArray * numeric_array_from_output_blob( void ) +{ + if( net_->num_outputs() != 1 ) { + LOG(FATAL) << "expecting 1 output blob, but got " << net_->num_outputs(); + } + int batchsize = net_->output_blobs()[0]->num(); + if( batchsize != 1 ) { + LOG(FATAL) << "expecting batchsize=1, but got batchsize=" << batchsize; + } + + int depth = net_->output_blobs()[0]->channels(); + int width = net_->output_blobs()[0]->width(); + int height = net_->output_blobs()[0]->height(); + mwSize dims[3] = {width, height, depth}; + + mxArray * const ret = mxCreateNumericArray( 3, dims, mxSINGLE_CLASS, mxREAL ); + copy_output_blob_data( 0, (float *)mxGetData(ret), sz_from_dims( 3, dims ) ); + + return ret; +} + +p_vect_float JPEGImage_to_p_float( JPEGImage &jpeg ){ + int depth = jpeg.depth(); + int height = jpeg.height(); + int width = jpeg.width(); + int batchsize = 1; + uint32_t dims[4] = {batchsize, depth, height, width}; + check_input_blobs_dims( 4, dims ); + + uint32_t const ret_sz = sz_from_dims( 4U, dims ); + p_vect_float ret = make_p_vect_float( ret_sz ); + + //copy jpeg into jpeg_float_npy + for(int ch_src=0; ch_srcat(rix) = jpeg.bits()[y*width*depth + x*depth + ch_src] - ch_mean; + } + } + } + return ret; +} + +// @param out output a list of mxArray *'s, one list element per scale, each holding a 3D numeric array of the features +// @param scaleLocs = location of each scale on planes (see unstitch_pyramid_locations in PyramidStitcher.cpp) +// @param descriptor_planes -- each element of the list is a plane of Caffe descriptors +// typically, descriptor_planes = blobs_top. +// @param depth = #channels (typically 256 for conv5) +static void unstitch_planes(vect_rp_mxArray & out, vector const & scaleLocs, vect_rp_mxArray const & descriptor_planes, int depth) { + assert( out.empty() ); + + int nbScales = scaleLocs.size(); + + for(int i=0; ioutput_blobs()[0]->channels(); + int width = net_->output_blobs()[0]->width(); + int height = net_->output_blobs()[0]->height(); + + int planeID = scaleLocs[i].planeID; + assert( uint32_t(planeID) < descriptor_planes.size() ); + mxArray * dp = descriptor_planes[planeID]; + mwSize dp_num_dims = mxGetNumberOfDimensions( dp ); + assert( dp_num_dims == 3 ); + mwSize * dp_dims = mxGetDimensions( dp ); + assert( dp_dims[0] == width ); + assert( dp_dims[1] == height ); + assert( dp_dims[2] == depth ); + float * const dp_data = ( float * )mxGetData( dp ); + + // row-major / C / numpy / caffe dims (note: the matlab dims of descriptor_planes are (correctly) the reverse of this) + // dims[3] = {depth, height, width}; + + mwSize ret_dims[3] = {depth, scaleLocs[i].height, scaleLocs[i].width }; // desired column-major / F / matlab dims + mxArray * const ret = mxCreateNumericArray( 3, ret_dims, mxSINGLE_CLASS, mxREAL ); + float * const ret_data = (float * )mxGetData( ret ); + mwSize ret_sz = sz_from_dims( 3, ret_dims ); + for( uint32_t x = 0; x < uint32_t(ret_dims[2]); ++x ) { + for( uint32_t y = 0; y < uint32_t(ret_dims[1]); ++y ) { + for( uint32_t d = 0; d < uint32_t(ret_dims[0]); ++d ) { + uint32_t const rix = d + y*ret_dims[0] + x*ret_dims[0]*ret_dims[1]; + assert( rix < uint32_t(ret_sz) ); + uint32_t const dp_x = x + scaleLocs[i].xMin; + uint32_t const dp_y = y + scaleLocs[i].yMin; + assert( dp_x < uint32_t(dp_dims[0]) ); + assert( dp_y < uint32_t(dp_dims[1]) ); + assert( d < uint32_t(dp_dims[2]) ); + //ret_data[rix] = float(d) + 1000.0*y + 1000000.0*x; + ret_data[rix] = dp_data[ dp_x + dp_y*dp_dims[0] + d*dp_dims[0]*dp_dims[1] ]; + } + } + } + out.push_back(ret); + } + +} + +static void extract_featpyramid(MEX_ARGS) { + if (nrhs != 1) { + LOG(ERROR) << "Given " << nrhs << " arguments, expected 1."; + mexErrMsgTxt("Wrong number of arguments"); + } + if (nlhs != 1) { + LOG(ERROR) << "Caller wanted " << nlhs << " outputs, but this function always produces 1."; + mexErrMsgTxt("Wrong number of outputs"); + } + char *fn_cs = mxArrayToString(prhs[0]); + string const file( fn_cs ); + mxFree(fn_cs); + + int padding = 16; + int interval = 10; + int convnet_subsampling_ratio = 16; //for conv5 layer features + int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size + int resultDepth = net_->output_blobs()[0]->channels(); + + assert(net_->input_blobs()[0]->width() == net_->input_blobs()[0]->height()); //assume square planes in Caffe. (can relax this if necessary) + assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) + //TODO: verify/assert that top-upsampled version of input img fits within planeDim + + Patchwork patchwork = stitch_pyramid(file, padding, interval, planeDim); + int nbPlanes = patchwork.planes_.size(); + + vect_rp_mxArray mx_outs; + //prep input data for Caffe feature extraction + for(int planeID=0; planeID scaleLocations = unstitch_pyramid_locations(patchwork, convnet_subsampling_ratio); + uint32_t const ret_rows = patchwork.scales_.size(); + assert( scaleLocations.size() == ret_rows ); + + vect_rp_mxArray feats; + unstitch_planes( feats, scaleLocations, mx_outs, resultDepth ); + assert( feats.size() == ret_rows ); + + for( vect_rp_mxArray::const_iterator i = mx_outs.begin(); i != mx_outs.end(); ++i ) { mxDestroyArray(*i); } + + mxArray * ret = mxCreateStructMatrix( ret_rows, 1, 2, fnames ); + for( uint32_t r = 0; r < ret_rows; ++r ) { + mxArray * const scale = mxCreateNumericMatrix( 1, 1, mxSINGLE_CLASS, mxREAL ); + float * const scale_ptr = (float*)(mxGetData(scale)); + *scale_ptr = patchwork.scales_[r]; + mxSetFieldByNumber( ret, r, 0, scale ); + mxSetFieldByNumber( ret, r, 1, feats[r] ); + } + + plhs[0] = ret; +} + + /** ----------------------------------------------------------------- ** Available commands. **/ @@ -156,11 +423,19 @@ static handler_registry handlers[] = { { "set_phase_train", set_phase_train }, { "set_phase_test", set_phase_test }, { "set_device", set_device }, + // featpyramid functions + { "test_io", test_io }, + { "extract_featpyramid",extract_featpyramid }, + // The end. { "END", NULL }, }; +// building with mkoctfile +// CXXFLAGS="-fpic -DNDEBUG -O2" mkoctfile --mex matlab/caffe/matcaffe.cpp libcaffe.a -pthread -I/usr/local/include -I/usr/include/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I./src -I./include -I/usr/local/cuda/include -I/opt/intel/mkl/include -Wall -L/usr/lib -L/usr/local/lib -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib -L/opt/intel/mkl/lib -L/opt/intel/mkl/lib/intel64 -lcudart -lcublas -lcurand -lprotobuf -lopencv_core -lopencv_highgui -lglog -lmkl_rt -lmkl_intel_thread -lleveldb -lsnappy -lpthread -lboost_system -lopencv_imgproc -o matlab/caffe/caffe + + /** ----------------------------------------------------------------- ** matlab entry point: caffe(api_command, arg1, arg2, ...) **/ From 3decf2f9f7e8a4250a8dec96ef4b4473638d2c24 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 23 Jan 2014 13:13:40 -0800 Subject: [PATCH 22/92] add disabled code for writing pyramid to image files --- python/caffe/stitch_pyramid/build/demo.sh | 4 ++++ python/caffe/stitch_pyramid/test_stitch_pyramid.cpp | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/python/caffe/stitch_pyramid/build/demo.sh b/python/caffe/stitch_pyramid/build/demo.sh index 73605577871..4c1f79dd014 100755 --- a/python/caffe/stitch_pyramid/build/demo.sh +++ b/python/caffe/stitch_pyramid/build/demo.sh @@ -3,3 +3,7 @@ ./test_stitch_pyramid --padding 8 --output-stitched-dir ./stitched_results ../../imagenet/pascal_009959.jpg +#for paper figs: +#./test_stitch_pyramid --padding 16 --output-stitched-dir ~/paper-writing/ICML14_dense_convnet/figures/featpyramid_figs/stitched_img ~/paper-writing/ICML14_dense_convnet/figures/bicycle.jpg + + diff --git a/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp b/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp index ebe5da97149..0a87b2f95fa 100644 --- a/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp +++ b/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp @@ -154,9 +154,16 @@ int main(int argc, char * argv[]){ printf(" base_filename = %s \n", base_filename.c_str()); printf(" output_stitched_dir = %s \n", output_stitched_dir.c_str()); +#if 0 //just for generating paper figs... the call to JPEGPyramid is now contained in stitch_pyramid. + JPEGImage image(file); + int upsampleFactor = 2; + JPEGPyramid pyramid(image, padding, padding, interval, upsampleFactor); + writePyraToJPG(pyramid); +#endif + + //Patchwork patchwork = stitch_pyramid(file, padding, interval, 2000); Patchwork patchwork = stitch_pyramid(file, padding, interval, -1); //planeDim = -1 (use defaults) //printScaleSizes(pyramid); - //writePyraToJPG(pyramid); writePatchworkToJPG(patchwork, output_stitched_dir, base_filename); //outputs to output_stitched_dir/base_filename_[planeID].jpg int convnet_subsampling_ratio = 1; // we're not actually computing convnet features in this test, @@ -194,8 +201,9 @@ void writePyraToJPG(JPEGPyramid pyramid){ for(int level = 0; level < nlevels; level++){ ostringstream fname; + //fname << "/home/forrest/paper-writing/ICML14_dense_convnet/figures/featpyramid_figs/multiscale_unstitched_img/scale_" << level << ".jpg"; fname << "../pyra_results/level" << level << ".jpg"; //TODO: get orig img name into the JPEG name. - //cout << fname.str() << endl; + cout << fname.str() << endl; pyramid.levels()[level].save(fname.str()); } From a2f336164d19db732369d11015bbebdb7d902908 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 23 Jan 2014 19:22:12 -0800 Subject: [PATCH 23/92] -- use p_vect_float instead of mxArray for buffering feature pyramid caffe output in matlab wrapper. mwm fix matlab vs octave compile stuff for matlab pyramid API --- Makefile | 4 +- matlab/caffe/featpyramid_matcaffe_demo.m | 2 +- matlab/caffe/matcaffe.cpp | 86 +++++++++++------------- 3 files changed, 41 insertions(+), 51 deletions(-) diff --git a/Makefile b/Makefile index 74d81c094ee..e86b849ec4f 100644 --- a/Makefile +++ b/Makefile @@ -157,8 +157,8 @@ mat$(PROJECT): mat mat: init $(STATIC_NAME) $(MAT$(PROJECT)_SRC) $(MATLAB_DIR)/bin/mex $(MAT$(PROJECT)_SRC) $(STATIC_NAME) \ - CXXFLAGS="\$$CXXFLAGS $(CXXFLAGS) $(WARNINGS)" \ - CXXLIBS="\$$CXXLIBS $(LDFLAGS)" \ + CXXFLAGS="\$$CXXFLAGS $(CXXFLAGS) $(WARNINGS)" -I./python/caffe \ + CXXLIBS="\$$CXXLIBS $(LDFLAGS)" -L./python/caffe/stitch_pyramid -lPyramidStitcher \ -o $(MAT$(PROJECT)_SO) @echo diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index ca6b827a356..9823a6f70d5 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -21,7 +21,7 @@ % imfn = '../../examples/cat.jpg'; % pyra = featpyramid_matcaffe_demo(imfn, 1); -if ! exist('imfn', 'var') +if ~exist('imfn', 'var') imfn = '/home/moskewcz/svn_work/boda/test/pascal/000001.jpg' end diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 7db2c585963..f5ddc1c5fa7 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -9,7 +9,7 @@ #include "mex.h" #include "caffe/caffe.hpp" -#include "python/caffe/stitch_pyramid/PyramidStitcher.h" //also includes JPEGImage, Patchwork, etc +#include "stitch_pyramid/PyramidStitcher.h" //also includes JPEGImage, Patchwork, etc #include "boost/shared_ptr.hpp" #include "featpyra_common.hpp" #include @@ -91,6 +91,13 @@ static mxArray* do_forward(const mxArray* const bottom) { return mx_out; } +template< typename T > +T sz_from_dims( uint32_t const num_dims, T const * const dims ) { + T ret = 1; + for( uint32_t dim = 0; dim < num_dims; ++dim ) { ret *= dims[dim]; } + return ret; +} + typedef vector< mxArray * > vect_rp_mxArray; typedef vector< float > vect_float; typedef shared_ptr< vect_float > p_vect_float; @@ -126,21 +133,32 @@ static void raw_do_forward( vect_p_vect_float const & bottom ) { net_->ForwardPrefilled(); } -static void copy_output_blob_data( uint32_t const output_blob_ix, float * const dest, uint32_t const dest_sz_floats ) +static p_vect_float copy_output_blob_data( uint32_t const output_blob_ix ) { + const vector*>& output_blobs = net_->output_blobs(); if( ! (output_blob_ix < output_blobs.size() ) ) { LOG(FATAL) << "!(output_blobs_ix < output_blobs.size())"; } Blob * const output_blob = output_blobs[output_blob_ix]; - if( dest_sz_floats != (uint32_t)output_blob->count() ) { - LOG(FATAL) << "dest_sz_floats != output_blob->count()"; + + int batchsize = net_->output_blobs()[0]->num(); + int depth = net_->output_blobs()[0]->channels(); + int width = net_->output_blobs()[0]->width(); + int height = net_->output_blobs()[0]->height(); + mwSize dims[4] = {batchsize, width, height, depth}; + + if( sz_from_dims( 4, dims ) != (uint32_t)output_blob->count() ) { + LOG(FATAL) << "sz_from_dims( 4, dims ) != output_blob->count()"; } + p_vect_float ret = make_p_vect_float( (uint32_t)output_blob->count() ); + float * const dest = &ret->front(); switch (Caffe::mode()) { - case Caffe::CPU: memcpy(dest, output_blob->cpu_data(), sizeof(float) * dest_sz_floats ); break; - case Caffe::GPU: cudaMemcpy(dest, output_blob->gpu_data(), sizeof(float) * dest_sz_floats, cudaMemcpyDeviceToHost); break; + case Caffe::CPU: memcpy(dest, output_blob->cpu_data(), sizeof(float) * ret->size() ); break; + case Caffe::GPU: cudaMemcpy(dest, output_blob->gpu_data(), sizeof(float) * ret->size(), cudaMemcpyDeviceToHost); break; default: LOG(FATAL) << "Unknown Caffe mode."; } // switch (Caffe::mode()) + return ret; } @@ -220,14 +238,6 @@ static void test_io(MEX_ARGS) { plhs[0] = ret; } -template< typename T > -T sz_from_dims( uint32_t const num_dims, T const * const dims ) { - T ret = 1; - for( uint32_t dim = 0; dim < num_dims; ++dim ) { ret *= dims[dim]; } - return ret; -} - - void check_dims_equal( uint32_t const num_dims, uint32_t const * const dims_a, uint32_t const * const dims_b ) { bool dims_eq = 1; for( uint32_t dim = 0; dim < num_dims; ++dim ) { if( dims_a[dim] != dims_b[dim] ) { dims_eq = 0; } } @@ -245,9 +255,7 @@ void check_input_blobs_dims( uint32_t const num_dims, uint32_t const * const dim check_dims_equal( 4, dims, dims_b ); } - -mxArray * numeric_array_from_output_blob( void ) -{ +p_vect_float p_vect_float_from_output_blob_0( void ) { if( net_->num_outputs() != 1 ) { LOG(FATAL) << "expecting 1 output blob, but got " << net_->num_outputs(); } @@ -255,16 +263,7 @@ mxArray * numeric_array_from_output_blob( void ) if( batchsize != 1 ) { LOG(FATAL) << "expecting batchsize=1, but got batchsize=" << batchsize; } - - int depth = net_->output_blobs()[0]->channels(); - int width = net_->output_blobs()[0]->width(); - int height = net_->output_blobs()[0]->height(); - mwSize dims[3] = {width, height, depth}; - - mxArray * const ret = mxCreateNumericArray( 3, dims, mxSINGLE_CLASS, mxREAL ); - copy_output_blob_data( 0, (float *)mxGetData(ret), sz_from_dims( 3, dims ) ); - - return ret; + return copy_output_blob_data( 0 ); } p_vect_float JPEGImage_to_p_float( JPEGImage &jpeg ){ @@ -299,27 +298,22 @@ p_vect_float JPEGImage_to_p_float( JPEGImage &jpeg ){ // @param descriptor_planes -- each element of the list is a plane of Caffe descriptors // typically, descriptor_planes = blobs_top. // @param depth = #channels (typically 256 for conv5) -static void unstitch_planes(vect_rp_mxArray & out, vector const & scaleLocs, vect_rp_mxArray const & descriptor_planes, int depth) { +static void unstitch_planes(vect_rp_mxArray & out, vector const & scaleLocs, vect_p_vect_float const & descriptor_planes, int depth) { assert( out.empty() ); int nbScales = scaleLocs.size(); for(int i=0; ioutput_blobs()[0]->channels(); - int width = net_->output_blobs()[0]->width(); - int height = net_->output_blobs()[0]->height(); + uint32_t depth = net_->output_blobs()[0]->channels(); + uint32_t width = net_->output_blobs()[0]->width(); + uint32_t height = net_->output_blobs()[0]->height(); int planeID = scaleLocs[i].planeID; assert( uint32_t(planeID) < descriptor_planes.size() ); - mxArray * dp = descriptor_planes[planeID]; - mwSize dp_num_dims = mxGetNumberOfDimensions( dp ); - assert( dp_num_dims == 3 ); - mwSize * dp_dims = mxGetDimensions( dp ); - assert( dp_dims[0] == width ); - assert( dp_dims[1] == height ); - assert( dp_dims[2] == depth ); - float * const dp_data = ( float * )mxGetData( dp ); + p_vect_float dp = descriptor_planes[planeID]; + + uint32_t const dp_dims[3] = {width,height,depth}; // row-major / C / numpy / caffe dims (note: the matlab dims of descriptor_planes are (correctly) the reverse of this) // dims[3] = {depth, height, width}; @@ -335,11 +329,9 @@ static void unstitch_planes(vect_rp_mxArray & out, vector const & assert( rix < uint32_t(ret_sz) ); uint32_t const dp_x = x + scaleLocs[i].xMin; uint32_t const dp_y = y + scaleLocs[i].yMin; - assert( dp_x < uint32_t(dp_dims[0]) ); - assert( dp_y < uint32_t(dp_dims[1]) ); - assert( d < uint32_t(dp_dims[2]) ); + uint32_t const dp_ix = dp_x + dp_y*dp_dims[0] + d*dp_dims[0]*dp_dims[1]; //ret_data[rix] = float(d) + 1000.0*y + 1000000.0*x; - ret_data[rix] = dp_data[ dp_x + dp_y*dp_dims[0] + d*dp_dims[0]*dp_dims[1] ]; + ret_data[rix] = dp->at(dp_ix); } } } @@ -374,13 +366,13 @@ static void extract_featpyramid(MEX_ARGS) { Patchwork patchwork = stitch_pyramid(file, padding, interval, planeDim); int nbPlanes = patchwork.planes_.size(); - vect_rp_mxArray mx_outs; + vect_p_vect_float blobs_top; //prep input data for Caffe feature extraction for(int planeID=0; planeID scaleLocations = unstitch_pyramid_locations(patchwork, convnet_subsampling_ratio); @@ -388,11 +380,9 @@ static void extract_featpyramid(MEX_ARGS) { assert( scaleLocations.size() == ret_rows ); vect_rp_mxArray feats; - unstitch_planes( feats, scaleLocations, mx_outs, resultDepth ); + unstitch_planes( feats, scaleLocations, blobs_top, resultDepth ); assert( feats.size() == ret_rows ); - for( vect_rp_mxArray::const_iterator i = mx_outs.begin(); i != mx_outs.end(); ++i ) { mxDestroyArray(*i); } - mxArray * ret = mxCreateStructMatrix( ret_rows, 1, 2, fnames ); for( uint32_t r = 0; r < ret_rows; ++r ) { mxArray * const scale = mxCreateNumericMatrix( 1, 1, mxSINGLE_CLASS, mxREAL ); From 30b8049eb6608ab976f4514f95a5bbb77170ab50 Mon Sep 17 00:00:00 2001 From: forresti Date: Mon, 27 Jan 2014 14:18:47 -0800 Subject: [PATCH 24/92] moved stitch_pyramid from caffe/python/caffe/imagenet/stitch_pyramid -> caffe/src/stitch_pyramid --- Makefile | 10 +++++----- {python/caffe => src}/stitch_pyramid/COPYING.txt | 0 {python/caffe => src}/stitch_pyramid/JPEGImage.cpp | 0 {python/caffe => src}/stitch_pyramid/JPEGImage.h | 0 {python/caffe => src}/stitch_pyramid/JPEGPyramid.cpp | 0 {python/caffe => src}/stitch_pyramid/JPEGPyramid.h | 0 {python/caffe => src}/stitch_pyramid/Patchwork.cpp | 0 {python/caffe => src}/stitch_pyramid/Patchwork.h | 0 .../caffe => src}/stitch_pyramid/PyramidStitcher.cpp | 0 {python/caffe => src}/stitch_pyramid/PyramidStitcher.h | 0 {python/caffe => src}/stitch_pyramid/README.txt | 0 {python/caffe => src}/stitch_pyramid/Rectangle.cpp | 0 {python/caffe => src}/stitch_pyramid/Rectangle.h | 0 {python/caffe => src}/stitch_pyramid/SimpleOpt.h | 0 {python/caffe => src}/stitch_pyramid/build/Makefile | 0 {python/caffe => src}/stitch_pyramid/build/demo.sh | 0 .../stitch_pyramid/build/stitch_pyramid_pascal.sh | 0 .../stitch_pyramid/test_stitch_pyramid.cpp | 0 18 files changed, 5 insertions(+), 5 deletions(-) rename {python/caffe => src}/stitch_pyramid/COPYING.txt (100%) rename {python/caffe => src}/stitch_pyramid/JPEGImage.cpp (100%) rename {python/caffe => src}/stitch_pyramid/JPEGImage.h (100%) rename {python/caffe => src}/stitch_pyramid/JPEGPyramid.cpp (100%) rename {python/caffe => src}/stitch_pyramid/JPEGPyramid.h (100%) rename {python/caffe => src}/stitch_pyramid/Patchwork.cpp (100%) rename {python/caffe => src}/stitch_pyramid/Patchwork.h (100%) rename {python/caffe => src}/stitch_pyramid/PyramidStitcher.cpp (100%) rename {python/caffe => src}/stitch_pyramid/PyramidStitcher.h (100%) rename {python/caffe => src}/stitch_pyramid/README.txt (100%) rename {python/caffe => src}/stitch_pyramid/Rectangle.cpp (100%) rename {python/caffe => src}/stitch_pyramid/Rectangle.h (100%) rename {python/caffe => src}/stitch_pyramid/SimpleOpt.h (100%) rename {python/caffe => src}/stitch_pyramid/build/Makefile (100%) rename {python/caffe => src}/stitch_pyramid/build/demo.sh (100%) rename {python/caffe => src}/stitch_pyramid/build/stitch_pyramid_pascal.sh (100%) rename {python/caffe => src}/stitch_pyramid/test_stitch_pyramid.cpp (100%) diff --git a/Makefile b/Makefile index e86b849ec4f..4835f4c0af1 100644 --- a/Makefile +++ b/Makefile @@ -45,9 +45,9 @@ NONGEN_CXX_SRCS := $(shell find \ LINT_REPORT := $(BUILD_DIR)/cpp_lint.log FAILED_LINT_REPORT := $(BUILD_DIR)/cpp_lint.error_log # STITCHPYRAMID is for stitching multiresolution feature pyramids. (exclude test files) -STITCHPYRAMID_SRC := $(shell find python/caffe/stitch_pyramid/build ! -name "test_*.cpp" -name "*.cpp") -STITCHPYRAMID_HDRS := $(shell find python/caffe/stitch_pyramid/build -name "*.h") -STITCHPYRAMID_SO := python/caffe/stitch_pyramid/libPyramidStitcher.so +STITCHPYRAMID_SRC := $(shell find src/stitch_pyramid ! -name "test_*.cpp" -name "*.cpp") +STITCHPYRAMID_HDRS := $(shell find src/stitch_pyramid -name "*.h") +STITCHPYRAMID_SO := src/stitch_pyramid/libPyramidStitcher.so # PY$(PROJECT)_SRC is the python wrapper for $(PROJECT) PY$(PROJECT)_SRC := python/$(PROJECT)/py$(PROJECT).cpp PY$(PROJECT)_SO := python/$(PROJECT)/py$(PROJECT).so @@ -149,7 +149,7 @@ $(STITCHPYRAMID_SO): $(STITCHPYRAMID_HDRS) $(STITCHPYRAMID_SRC) py$(PROJECT): py py: init $(STATIC_NAME) $(PY$(PROJECT)_SRC) $(PROTO_GEN_PY) $(STITCHPYRAMID_SO) - $(CXX) -shared -o $(PY$(PROJECT)_SO) $(PY$(PROJECT)_SRC) -L./python/caffe/stitch_pyramid/build -lPyramidStitcher -I./python/caffe/stitch_pyramid \ + $(CXX) -shared -o $(PY$(PROJECT)_SO) $(PY$(PROJECT)_SRC) -L./src/stitch_pyramid -lPyramidStitcher -I./src/stitch_pyramid \ $(STATIC_NAME) $(CXXFLAGS) $(PYTHON_LDFLAGS) @echo @@ -158,7 +158,7 @@ mat$(PROJECT): mat mat: init $(STATIC_NAME) $(MAT$(PROJECT)_SRC) $(MATLAB_DIR)/bin/mex $(MAT$(PROJECT)_SRC) $(STATIC_NAME) \ CXXFLAGS="\$$CXXFLAGS $(CXXFLAGS) $(WARNINGS)" -I./python/caffe \ - CXXLIBS="\$$CXXLIBS $(LDFLAGS)" -L./python/caffe/stitch_pyramid -lPyramidStitcher \ + CXXLIBS="\$$CXXLIBS $(LDFLAGS)" -L./src/stitch_pyramid -lPyramidStitcher \ -o $(MAT$(PROJECT)_SO) @echo diff --git a/python/caffe/stitch_pyramid/COPYING.txt b/src/stitch_pyramid/COPYING.txt similarity index 100% rename from python/caffe/stitch_pyramid/COPYING.txt rename to src/stitch_pyramid/COPYING.txt diff --git a/python/caffe/stitch_pyramid/JPEGImage.cpp b/src/stitch_pyramid/JPEGImage.cpp similarity index 100% rename from python/caffe/stitch_pyramid/JPEGImage.cpp rename to src/stitch_pyramid/JPEGImage.cpp diff --git a/python/caffe/stitch_pyramid/JPEGImage.h b/src/stitch_pyramid/JPEGImage.h similarity index 100% rename from python/caffe/stitch_pyramid/JPEGImage.h rename to src/stitch_pyramid/JPEGImage.h diff --git a/python/caffe/stitch_pyramid/JPEGPyramid.cpp b/src/stitch_pyramid/JPEGPyramid.cpp similarity index 100% rename from python/caffe/stitch_pyramid/JPEGPyramid.cpp rename to src/stitch_pyramid/JPEGPyramid.cpp diff --git a/python/caffe/stitch_pyramid/JPEGPyramid.h b/src/stitch_pyramid/JPEGPyramid.h similarity index 100% rename from python/caffe/stitch_pyramid/JPEGPyramid.h rename to src/stitch_pyramid/JPEGPyramid.h diff --git a/python/caffe/stitch_pyramid/Patchwork.cpp b/src/stitch_pyramid/Patchwork.cpp similarity index 100% rename from python/caffe/stitch_pyramid/Patchwork.cpp rename to src/stitch_pyramid/Patchwork.cpp diff --git a/python/caffe/stitch_pyramid/Patchwork.h b/src/stitch_pyramid/Patchwork.h similarity index 100% rename from python/caffe/stitch_pyramid/Patchwork.h rename to src/stitch_pyramid/Patchwork.h diff --git a/python/caffe/stitch_pyramid/PyramidStitcher.cpp b/src/stitch_pyramid/PyramidStitcher.cpp similarity index 100% rename from python/caffe/stitch_pyramid/PyramidStitcher.cpp rename to src/stitch_pyramid/PyramidStitcher.cpp diff --git a/python/caffe/stitch_pyramid/PyramidStitcher.h b/src/stitch_pyramid/PyramidStitcher.h similarity index 100% rename from python/caffe/stitch_pyramid/PyramidStitcher.h rename to src/stitch_pyramid/PyramidStitcher.h diff --git a/python/caffe/stitch_pyramid/README.txt b/src/stitch_pyramid/README.txt similarity index 100% rename from python/caffe/stitch_pyramid/README.txt rename to src/stitch_pyramid/README.txt diff --git a/python/caffe/stitch_pyramid/Rectangle.cpp b/src/stitch_pyramid/Rectangle.cpp similarity index 100% rename from python/caffe/stitch_pyramid/Rectangle.cpp rename to src/stitch_pyramid/Rectangle.cpp diff --git a/python/caffe/stitch_pyramid/Rectangle.h b/src/stitch_pyramid/Rectangle.h similarity index 100% rename from python/caffe/stitch_pyramid/Rectangle.h rename to src/stitch_pyramid/Rectangle.h diff --git a/python/caffe/stitch_pyramid/SimpleOpt.h b/src/stitch_pyramid/SimpleOpt.h similarity index 100% rename from python/caffe/stitch_pyramid/SimpleOpt.h rename to src/stitch_pyramid/SimpleOpt.h diff --git a/python/caffe/stitch_pyramid/build/Makefile b/src/stitch_pyramid/build/Makefile similarity index 100% rename from python/caffe/stitch_pyramid/build/Makefile rename to src/stitch_pyramid/build/Makefile diff --git a/python/caffe/stitch_pyramid/build/demo.sh b/src/stitch_pyramid/build/demo.sh similarity index 100% rename from python/caffe/stitch_pyramid/build/demo.sh rename to src/stitch_pyramid/build/demo.sh diff --git a/python/caffe/stitch_pyramid/build/stitch_pyramid_pascal.sh b/src/stitch_pyramid/build/stitch_pyramid_pascal.sh similarity index 100% rename from python/caffe/stitch_pyramid/build/stitch_pyramid_pascal.sh rename to src/stitch_pyramid/build/stitch_pyramid_pascal.sh diff --git a/python/caffe/stitch_pyramid/test_stitch_pyramid.cpp b/src/stitch_pyramid/test_stitch_pyramid.cpp similarity index 100% rename from python/caffe/stitch_pyramid/test_stitch_pyramid.cpp rename to src/stitch_pyramid/test_stitch_pyramid.cpp From 0cbbe390f9c5bea47f15ac67f3916ca5ddffb682 Mon Sep 17 00:00:00 2001 From: forresti Date: Mon, 27 Jan 2014 14:20:08 -0800 Subject: [PATCH 25/92] fixed demo --- src/stitch_pyramid/build/demo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stitch_pyramid/build/demo.sh b/src/stitch_pyramid/build/demo.sh index 4c1f79dd014..fb66ff63071 100755 --- a/src/stitch_pyramid/build/demo.sh +++ b/src/stitch_pyramid/build/demo.sh @@ -1,7 +1,7 @@ #./stitch_pyramid ../../../images_640x480/carsgraz_001.image.jpg #./stitch_pyramid --padding 8 ../../images_640x480/carsgraz_001.image.jpg -./test_stitch_pyramid --padding 8 --output-stitched-dir ./stitched_results ../../imagenet/pascal_009959.jpg +./test_stitch_pyramid --padding 8 --output-stitched-dir ./stitched_results ../../../python/caffe/imagenet/pascal_009959.jpg #for paper figs: #./test_stitch_pyramid --padding 16 --output-stitched-dir ~/paper-writing/ICML14_dense_convnet/figures/featpyramid_figs/stitched_img ~/paper-writing/ICML14_dense_convnet/figures/bicycle.jpg From 12e2fcd3af3a3d8a3f16c07304ecb92b5a41b6f4 Mon Sep 17 00:00:00 2001 From: forresti Date: Mon, 27 Jan 2014 14:30:19 -0800 Subject: [PATCH 26/92] rename extract_featpyramid -> convnet_featpyramid in matlab API --- matlab/caffe/featpyramid_matcaffe_demo.m | 2 +- matlab/caffe/matcaffe.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index 9823a6f70d5..af4f2e16d6c 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -43,5 +43,5 @@ % put into test mode caffe('set_phase_test'); -pyra = caffe('extract_featpyramid', imfn ); +pyra = caffe('convnet_featpyramid', imfn ); diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index f5ddc1c5fa7..7bfddabcc2b 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -340,7 +340,7 @@ static void unstitch_planes(vect_rp_mxArray & out, vector const & } -static void extract_featpyramid(MEX_ARGS) { +static void convnet_featpyramid(MEX_ARGS) { if (nrhs != 1) { LOG(ERROR) << "Given " << nrhs << " arguments, expected 1."; mexErrMsgTxt("Wrong number of arguments"); @@ -415,7 +415,7 @@ static handler_registry handlers[] = { { "set_device", set_device }, // featpyramid functions { "test_io", test_io }, - { "extract_featpyramid",extract_featpyramid }, + { "convnet_featpyramid",convnet_featpyramid }, // The end. { "END", NULL }, From 0e17940712576830ccd7bb575a78a176b8fbec5c Mon Sep 17 00:00:00 2001 From: forresti Date: Mon, 27 Jan 2014 14:58:52 -0800 Subject: [PATCH 27/92] partially implimented padding: background->mean; edges linear interp to mean; corner regions still TODO --- include/caffe/imagenet_mean.hpp | 3 + matlab/caffe/featpyra_common.hpp | 2 + matlab/caffe/matcaffe.cpp | 3 +- python/caffe/pycaffe.cpp | 21 +----- src/stitch_pyramid/JPEGImage.cpp | 21 +++++- src/stitch_pyramid/JPEGImage.h | 3 + src/stitch_pyramid/JPEGPyramid.cpp | 74 ++++++++++++++++++++++ src/stitch_pyramid/JPEGPyramid.h | 6 ++ src/stitch_pyramid/Patchwork.cpp | 1 + src/stitch_pyramid/imagenet_mean.hpp | 1 + src/stitch_pyramid/test_stitch_pyramid.cpp | 20 ++++++ 11 files changed, 133 insertions(+), 22 deletions(-) create mode 120000 src/stitch_pyramid/imagenet_mean.hpp diff --git a/include/caffe/imagenet_mean.hpp b/include/caffe/imagenet_mean.hpp index 5b240348167..8f329bd0ddc 100644 --- a/include/caffe/imagenet_mean.hpp +++ b/include/caffe/imagenet_mean.hpp @@ -12,4 +12,7 @@ #define IMAGENET_MEAN_G 116.66f #define IMAGENET_MEAN_B 104.00f +static float IMAGENET_MEAN_RGB[3] = {IMAGENET_MEAN_R, IMAGENET_MEAN_G, IMAGENET_MEAN_B}; +static float IMAGENET_MEAN_BGR[3] = {IMAGENET_MEAN_B, IMAGENET_MEAN_G, IMAGENET_MEAN_R}; + #endif diff --git a/matlab/caffe/featpyra_common.hpp b/matlab/caffe/featpyra_common.hpp index 9b9fb1b3169..a90d2a2c5c3 100644 --- a/matlab/caffe/featpyra_common.hpp +++ b/matlab/caffe/featpyra_common.hpp @@ -6,6 +6,7 @@ inline int get_BGR(int channel_RGB) { assert( channel_RGB < 3 ); return 2 - chan // get avg value for imagenet pixels on particular channel // these are defined in caffe/include/caffe/imagenet_mean.hpp +/* inline float get_mean_RGB(int channel_RGB){ if(channel_RGB==0) { return float(IMAGENET_MEAN_R); } if(channel_RGB==1) { return float(IMAGENET_MEAN_G); } @@ -13,6 +14,7 @@ inline float get_mean_RGB(int channel_RGB){ else { assert(0); } return 0; } +*/ template< typename T > inline std::string str(T const & i) // convert T i to string diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 7bfddabcc2b..c6e1b61bd2b 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -280,7 +280,8 @@ p_vect_float JPEGImage_to_p_float( JPEGImage &jpeg ){ //copy jpeg into jpeg_float_npy for(int ch_src=0; ch_src1 batch 4d array) // @param jpeg = typically a plane from Patchwork, in packed JPEG [RGB,RGB,RGB] format // @return numpy float array of jpeg, in unpacked [BBBBB..,GGGGG..,RRRRR..] format with channel mean subtracted @@ -280,7 +263,9 @@ struct CaffeNet { //copy jpeg into jpeg_float_npy for(int ch_src=0; ch_src #include @@ -42,9 +43,6 @@ inline int uniform_distribution(int rangeLow, int rangeHigh) // THIS IS VERY SLOWWWW: //to avoid hard borders on images in plane (which look like edges to the convnet) void JPEGImage::fill_with_rand(){ - //int height = img.height(); - //int width = img.width(); - //int depth = img.depth(); int height = this->height(); int width = this->width(); int depth = this->depth(); @@ -59,6 +57,23 @@ void JPEGImage::fill_with_rand(){ } } +//prefill plane with the average imagenet pixel value +void JPEGImage::fill_with_imagenet_mean(){ + int height = this->height(); + int width = this->width(); + int depth = this->depth(); + + for (int ch = 0; ch < depth; ch++){ + uint8_t ch_mean = (uint8_t)IMAGENET_MEAN_RGB[ch]; + for (int y = 0; y < height; y++){ + for (int x = 0; x < width; x++){ + this->bits()[y*width*depth + x*depth + ch] = ch_mean; + //this->bits()[y*width*depth + x*depth + ch] = (uint8_t)uniform_distribution(0, 255); + } + } + } +} + JPEGImage::JPEGImage() : width_(0), height_(0), depth_(0) { } diff --git a/src/stitch_pyramid/JPEGImage.h b/src/stitch_pyramid/JPEGImage.h index c008293873d..c827cd3915d 100644 --- a/src/stitch_pyramid/JPEGImage.h +++ b/src/stitch_pyramid/JPEGImage.h @@ -36,6 +36,8 @@ class JPEGImage void fill_with_rand(); //fill self with random numbers (e.g. before filling w/ data so we get rand-padding) + void fill_with_imagenet_mean(); + /// Constructs an empty image. An empty image has zero size. JPEGImage(); @@ -90,6 +92,7 @@ class JPEGImage // @param randPad = whether to use random numbers in padding (or, if false, use zero padding) JPEGImage pad(int x, int y, bool randPad) const; + private: // Blur and downscale an image by a factor 2 diff --git a/src/stitch_pyramid/JPEGPyramid.cpp b/src/stitch_pyramid/JPEGPyramid.cpp index 75c711a9242..0c716a2dfdb 100644 --- a/src/stitch_pyramid/JPEGPyramid.cpp +++ b/src/stitch_pyramid/JPEGPyramid.cpp @@ -19,6 +19,7 @@ //-------------------------------------------------------------------------------------------------- #include "JPEGPyramid.h" +#include "imagenet_mean.hpp" //contains hard-coded imagenet RGB mean. from Caffe. #include #include @@ -33,6 +34,78 @@ using namespace FFLD; using namespace std; +//TODO: make this uchar? +//linear interpolation, "lerp" +void JPEGPyramid::linear_interp(float val0, float val1, int n_elements, float* inout_lerp){ + + float n_elements_inv = 1 / (float)n_elements; + inout_lerp[0] = val0; + inout_lerp[n_elements-1] = val1; + + for(int i=1; i < (n_elements-1); i++){ + float frac_offset = (n_elements-i) * n_elements_inv; + + inout_lerp[i] = val0 * frac_offset + + val1 * (1 - frac_offset); + } +} + +// call this on each scaled image +// fills the image's padding with linear interpolated values from 'edge of img pixel' to 'imagenet mean' +void JPEGPyramid::AvgLerpPad(JPEGImage & image){ + + int width = image.width(); //including padding + int height = image.height(); + int depth = 3; + + float top_lerp[pady_+1]; //interpolated data to fill in above the current image column + float bottom_lerp[pady_+1]; + float left_lerp[padx_+1]; + float right_lerp[padx_+1]; + float currPx = 0; + + //top (& bottom?) + for(int ch=0; ch<3; ch++){ + float avgPx = IMAGENET_MEAN_RGB[ch]; + for(int x=padx_; x < width-padx_; x++){ + + //top + currPx = image.bits()[pady_*width*depth + x*depth + ch]; + linear_interp(currPx, avgPx, pady_+1, top_lerp); //populate top_lerp + for(int y=0; y scales_; + //populate inout_lerp with a sliding range from val0 to val1 (for padding images) + void linear_interp(float val0, float val1, int n_elements, float* inout_lerp); + + //fill an image's padding with linear interpolated data: [from edge of img to imagenet mean] + void AvgLerpPad(JPEGImage & image); + private: int padx_; int pady_; diff --git a/src/stitch_pyramid/Patchwork.cpp b/src/stitch_pyramid/Patchwork.cpp index b1eaa1707c1..70c0d5e747d 100644 --- a/src/stitch_pyramid/Patchwork.cpp +++ b/src/stitch_pyramid/Patchwork.cpp @@ -67,6 +67,7 @@ interval_(pyramid.interval()) for (int i = 0; i < nbPlanes; ++i) { planes_[i] = JPEGImage(MaxCols_, MaxRows_, JPEGPyramid::NbChannels); //JPEGImage(width, height, depth) //planes_[i].fill_with_rand(); //random noise that will go between images on plane. (TODO: allow user to enable/disable) + planes_[i].fill_with_imagenet_mean(); //fill with imagenet avg pixel value } int depth = JPEGPyramid::NbChannels; diff --git a/src/stitch_pyramid/imagenet_mean.hpp b/src/stitch_pyramid/imagenet_mean.hpp new file mode 120000 index 00000000000..09012688a67 --- /dev/null +++ b/src/stitch_pyramid/imagenet_mean.hpp @@ -0,0 +1 @@ +../../include/caffe/imagenet_mean.hpp \ No newline at end of file diff --git a/src/stitch_pyramid/test_stitch_pyramid.cpp b/src/stitch_pyramid/test_stitch_pyramid.cpp index 0a87b2f95fa..56ac08ab237 100644 --- a/src/stitch_pyramid/test_stitch_pyramid.cpp +++ b/src/stitch_pyramid/test_stitch_pyramid.cpp @@ -134,6 +134,7 @@ void writePyraToJPG(JPEGPyramid pyramid); void writePatchworkToJPG(Patchwork patchwork, string output_stitched_dir, string base_filename); void print_scaleLocations(vector scaleLocations); void print_scales(Patchwork patchwork); +void test_linear_interp(); //TODO: split this test into its own function, e.g. test_stitch_pyramid() int main(int argc, char * argv[]){ @@ -172,6 +173,8 @@ int main(int argc, char * argv[]){ //print_scaleLocations(scaleLocations); print_scales(patchwork); + test_linear_interp(); + return EXIT_SUCCESS; } @@ -227,3 +230,20 @@ void print_scales(Patchwork patchwork){ } } +void test_linear_interp(){ + float val0 = 10; + float val1 = 35; + int n_elements = 10; + float inout_lerp[n_elements]; + + JPEGPyramid dummy_pyra; + dummy_pyra.linear_interp(val0, val1, n_elements, inout_lerp); + + printf("lerp results: \n "); + for(int i=0; i Date: Tue, 28 Jan 2014 14:44:10 -0800 Subject: [PATCH 28/92] add interpolation-to-mean to corner padding for image pyramid patchwork; other minor changes. -- fill corners of padding with interpolation of edge padding (which is in turn already an interpolation from the image edge to the imagenet mean). -- add .PHONY stitch target to top level makefile for building just libStitchPyramid -- minor fix to testing makefile: add a -L. to src/stitch_pyramid/build/Makefile -- update matcaffe.cpp comment with current mkoctfile-based build command (can be used to test building matcaffe under octave) -- condense str() in featpyramid_common.hpp (str() is for debugging printfs) -- add a copy of str() in JPEDPyramid.cpp (FIXME: use some common copy?) mwm --- Makefile | 5 ++++ matlab/caffe/featpyra_common.hpp | 8 +----- matlab/caffe/matcaffe.cpp | 4 +-- src/stitch_pyramid/JPEGPyramid.cpp | 45 +++++++++++++++++++++++++++++- src/stitch_pyramid/build/Makefile | 2 +- 5 files changed, 52 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 4835f4c0af1..0b83465a226 100644 --- a/Makefile +++ b/Makefile @@ -143,6 +143,11 @@ tools: init $(TOOL_BINS) examples: init $(EXAMPLE_BINS) + +stitch: $(STITCHPYRAMID_SO) + +.PHONY : stitch + $(STITCHPYRAMID_SO): $(STITCHPYRAMID_HDRS) $(STITCHPYRAMID_SRC) $(CXX) -shared -o $(STITCHPYRAMID_SO) $(STITCHPYRAMID_SRC) $(CXXFLAGS) diff --git a/matlab/caffe/featpyra_common.hpp b/matlab/caffe/featpyra_common.hpp index a90d2a2c5c3..cabafba4fab 100644 --- a/matlab/caffe/featpyra_common.hpp +++ b/matlab/caffe/featpyra_common.hpp @@ -16,10 +16,4 @@ inline float get_mean_RGB(int channel_RGB){ } */ -template< typename T > -inline std::string str(T const & i) // convert T i to string -{ - std::stringstream s; - s << i; - return s.str(); -} +template< typename T > inline std::string str(T const & i) { std::stringstream s; s << i; return s.str(); } // convert T i to string diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index c6e1b61bd2b..2c01a550a9c 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -422,10 +422,8 @@ static handler_registry handlers[] = { { "END", NULL }, }; - // building with mkoctfile -// CXXFLAGS="-fpic -DNDEBUG -O2" mkoctfile --mex matlab/caffe/matcaffe.cpp libcaffe.a -pthread -I/usr/local/include -I/usr/include/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I./src -I./include -I/usr/local/cuda/include -I/opt/intel/mkl/include -Wall -L/usr/lib -L/usr/local/lib -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib -L/opt/intel/mkl/lib -L/opt/intel/mkl/lib/intel64 -lcudart -lcublas -lcurand -lprotobuf -lopencv_core -lopencv_highgui -lglog -lmkl_rt -lmkl_intel_thread -lleveldb -lsnappy -lpthread -lboost_system -lopencv_imgproc -o matlab/caffe/caffe - +// cd ~/git_work/caffe ; CXXFLAGS="-Wall -fpic -O2" mkoctfile --mex matlab/caffe/matcaffe.cpp libcaffe.a -pthread -I/usr/local/include -I/usr/include/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I./src -I./include -I/usr/local/cuda/include -I/opt/intel/mkl/include -Wall -L/usr/lib -L/usr/local/lib -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib -L/opt/intel/mkl/lib -L/opt/intel/mkl/lib/intel64 -lcudart -lcublas -lcurand -lprotobuf -lopencv_core -lopencv_highgui -lglog -lmkl_rt -lmkl_intel_thread -lleveldb -lsnappy -lpthread -lboost_system -lopencv_imgproc -L/home/moskewcz/git_work/caffe/python/caffe/stitch_pyramid -lPyramidStitcher -I./python/caffe -o matlab/caffe/caffe /** ----------------------------------------------------------------- ** matlab entry point: caffe(api_command, arg1, arg2, ...) diff --git a/src/stitch_pyramid/JPEGPyramid.cpp b/src/stitch_pyramid/JPEGPyramid.cpp index 0c716a2dfdb..ef8930f6cd3 100644 --- a/src/stitch_pyramid/JPEGPyramid.cpp +++ b/src/stitch_pyramid/JPEGPyramid.cpp @@ -34,6 +34,9 @@ using namespace FFLD; using namespace std; +#include +template< typename T > inline std::string str(T const & i) { std::stringstream s; s << i; return s.str(); } // convert T i to string + //TODO: make this uchar? //linear interpolation, "lerp" void JPEGPyramid::linear_interp(float val0, float val1, int n_elements, float* inout_lerp){ @@ -64,6 +67,9 @@ void JPEGPyramid::AvgLerpPad(JPEGImage & image){ float right_lerp[padx_+1]; float currPx = 0; + assert( padx_ == pady_ ); // corner padding assumes this (for now) + float corner_lerp[padx_+1]; + //top (& bottom?) for(int ch=0; ch<3; ch++){ float avgPx = IMAGENET_MEAN_RGB[ch]; @@ -102,8 +108,45 @@ void JPEGPyramid::AvgLerpPad(JPEGImage & image){ image.bits()[y*width*depth + imgX*depth + ch] = right_lerp[x]; } } + // dim 0 --> - side of image + assert( padx_ == pady_ ); // corner padding assumes this (for now) + for( uint32_t dx = 0; dx != 2; ++ dx ) { + for( uint32_t dy = 0; dy != 2; ++ dy ) { + // x,y is coord of dx,dy valid corner pixel of un-padded image + uint32_t const x = dx ? (width-padx_-1) : padx_; + uint32_t const y = dy ? (height-pady_-1) : pady_; + for( uint32_t dd = 2; dd <= padx_; ++dd ) { + uint32_t const cx = x + ( dx ? dd : -dd ); // cx,y is point on existing dx padding, dd outside image + uint32_t const cy = y + ( dy ? dd : -dd ); // x,cy is point on existing dy padding, dd outside image + assert( x < width ); assert( y < height ); + assert( cx < width ); assert( cy < height ); + float const cx_y_v = image.bits()[y*width*depth + cx*depth + ch]; + float const x_cy_v = image.bits()[cy*width*depth + x*depth + ch]; + linear_interp(cx_y_v, x_cy_v, dd+1, corner_lerp); // populate corner_lerp + for( uint32_t ci = 1; ci < dd; ++ci ) { // fill in diagonal corner pixels + uint32_t const cix = x + ( dx ? ci : -ci ); + uint32_t const ciy = cy + ( dy ? -ci : ci ); + //printf( "dx=%s x=%s cx=%s ci=%s cix=%s dd=%s\n", + // str(dx).c_str(), str(x).c_str(), str(cx).c_str(), str(ci).c_str(), str(cix).c_str(), str(dd).c_str() ); + assert( cix < width ); assert( ciy < height ); + image.bits()[ciy*width*depth + cix*depth + ch] = corner_lerp[ci]; + } + } + // fill in all-mean outer half of corner (a triangle) + uint32_t const cor_x = dx ? (width-1) : 0; + uint32_t const cor_y = dy ? (height-1) : 0; + // cor_x,cor_y is coord of dx,dy corner pixel of image (including padding) + for( uint32_t dd = 0; dd < padx_; ++dd ) { + for( uint32_t ddi = 0; ddi < (padx_-dd); ++ddi ) { + uint32_t const tri_x = cor_x + ( dx ? -dd : dd ); + uint32_t const tri_y = cor_y + ( dy ? -ddi : ddi ); + assert( tri_x < width ); assert( tri_y < height ); + image.bits()[tri_y*width*depth + tri_x*depth + ch] = avgPx; + } + } + } + } } - } JPEGPyramid::JPEGPyramid() : padx_(0), pady_(0), interval_(0) diff --git a/src/stitch_pyramid/build/Makefile b/src/stitch_pyramid/build/Makefile index ba87dad3e55..0d672bbd1ba 100644 --- a/src/stitch_pyramid/build/Makefile +++ b/src/stitch_pyramid/build/Makefile @@ -10,7 +10,7 @@ all: libPyramidStitcher.so test_stitch_pyramid # dynamic link option test_stitch_pyramid: test_stitch_pyramid.o libPyramidStitcher.so - $(CXX) -o test_stitch_pyramid test_stitch_pyramid.o -lPyramidStitcher $(LDLIBS) + $(CXX) -o test_stitch_pyramid test_stitch_pyramid.o -L. -lPyramidStitcher $(LDLIBS) # static link option (doesn't like static build w/ openmp) #test_stitch_pyramid: test_stitch_pyramid.o libPyramidStitcher.a From b0af64cf8e073bcc6fdec06d014e0499d808e386 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Tue, 18 Mar 2014 14:40:27 -0700 Subject: [PATCH 29/92] add timers --- python/caffe/imagenet/featpyramid_tests.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py index 0b59f6fb53f..0831ebba042 100644 --- a/python/caffe/imagenet/featpyramid_tests.py +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -10,6 +10,7 @@ import gflags import time import caffe +import time #for visualization, can be removed easily: from matplotlib import cm, pyplot @@ -38,7 +39,11 @@ def test_pyramid_IO(caffenet, imgFname): def test_featpyramid_allScales(caffenet, imgFname): + start_time = time.time() pyra = caffenet.extract_featpyramid(imgFname) # THE CRUX + pyra_time = time.time() - start_time + print " computed pyra in %f sec" %pyra_time + feat = pyra["feat"] # optional breakpoint... From 77b207b2297c068b3508bc4d0026481fafa611e9 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Tue, 28 Jan 2014 16:28:38 -0800 Subject: [PATCH 30/92] pycaffe/stitchpyramid related makefile tweaks; add missing (PyArrayObject*) casts (to fix compile errors for some build envs). note also that there is a new SHARED_LDFLAGS makefile var that can be set to include -Wl,--no-undefined (for gcc) to avoid accidentally linking an .so missing some of its dependencies. but, since people use other compilers, it's not enabled by default, and only the stitch library build line uses the macro at this point. mwm --- Makefile | 5 ++++- python/caffe/pycaffe.cpp | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 0b83465a226..a0b062ac9aa 100644 --- a/Makefile +++ b/Makefile @@ -107,6 +107,9 @@ LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) \ $(foreach library,$(LIBRARIES),-l$(library)) PYTHON_LDFLAGS := $(LDFLAGS) $(foreach library,$(PYTHON_LIBRARIES),-l$(library)) +#SHARED_LDFLAGS := -shared -Wl,--no-undefined # for gcc, this is probably a more sane default: any undefined syms will give a link error +SHARED_LDFLAGS := -shared + ############################## # Define build targets @@ -149,7 +152,7 @@ stitch: $(STITCHPYRAMID_SO) .PHONY : stitch $(STITCHPYRAMID_SO): $(STITCHPYRAMID_HDRS) $(STITCHPYRAMID_SRC) - $(CXX) -shared -o $(STITCHPYRAMID_SO) $(STITCHPYRAMID_SRC) $(CXXFLAGS) + $(CXX) $(SHARED_LDFLAGS) -o $(STITCHPYRAMID_SO) $(STITCHPYRAMID_SRC) $(CXXFLAGS) -ljpeg py$(PROJECT): py diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index c5adbec292f..c28ca8934c1 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -475,15 +475,17 @@ struct CaffeNet { //PyArrayObject* view_npy = (PyArrayObject*)PyArray_New( &PyArray_Type, 4, dims, NPY_FLOAT, strides, (float*)PyArray_DATA(pyramid_float_npy_boost.ptr()) + sliceWidth_min, 0, 0, 0 ); #if 0 //view of boost::object + PyArrayObject * const pyramid_float_npy = (PyArrayObject *)(pyramid_float_npy_boost.ptr()); PyArrayObject* view_npy = (PyArrayObject*)PyArray_New(&PyArray_Type, 4, view_dims, NPY_FLOAT, - PyArray_STRIDES(pyramid_float_npy_boost.ptr()), //dim of array that we're slicing - (float *)PyArray_GETPTR4(pyramid_float_npy_boost.ptr(), 0, 0, sliceHeight_min, sliceWidth_min), //new dim + PyArray_STRIDES(pyramid_float_npy), //dim of array that we're slicing + (float *)PyArray_GETPTR4(pyramid_float_npy, 0, 0, sliceHeight_min, sliceWidth_min), //new dim 0, 0, 0 ); #endif #if 1 //view of boost::list[0] + PyArrayObject * const blobs_top_boost_0_npy = (PyArrayObject *)(((boost::python::object)blobs_top_boost[0]).ptr()); PyArrayObject* view_npy = (PyArrayObject*)PyArray_New(&PyArray_Type, 4, view_dims, NPY_FLOAT, - PyArray_STRIDES( ((boost::python::object)blobs_top_boost[0]).ptr() ), //dim of array that we're slicing - (float *)PyArray_GETPTR4(((boost::python::object)blobs_top_boost[0]).ptr(), 0, 0, sliceHeight_min, sliceWidth_min), //new dim + PyArray_STRIDES(blobs_top_boost_0_npy), //dim of array that we're slicing + (float *)PyArray_GETPTR4( blobs_top_boost_0_npy, 0, 0, sliceHeight_min, sliceWidth_min), //new dim 0, 0, 0 ); #endif From efbd4cbb73a73a28fc93f2f3f5a402f35b02b127 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Tue, 4 Feb 2014 18:22:54 -0800 Subject: [PATCH 31/92] change default plane size in featpyramid matlab demo to 1100x1100. the decrease from 2000x2000 to 1100x1100 should consistently allow running on GPUs with less than 4G of memory (i.e. 2G). --- matlab/caffe/featpyramid_matcaffe_demo.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index af4f2e16d6c..a8c707e22d0 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -26,7 +26,7 @@ end %model_def_file = '../../examples/imagenet_deploy.prototxt'; -model_def_file = '../../python/caffe/imagenet/imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt' +model_def_file = '../../python/caffe/imagenet/imagenet_rcnn_batch_1_input_1100x1100_output_conv5.prototxt' % NOTE: you'll have to get the pre-trained ILSVRC network model_file = '../../examples/alexnet_train_iter_470000'; From d7027dd95e55e5947e5bee04cbeed8d65515a7e5 Mon Sep 17 00:00:00 2001 From: forresti Date: Wed, 29 Jan 2014 12:42:33 -0800 Subject: [PATCH 32/92] indentation and comments --- src/stitch_pyramid/JPEGPyramid.cpp | 80 +++++++++++++++--------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/src/stitch_pyramid/JPEGPyramid.cpp b/src/stitch_pyramid/JPEGPyramid.cpp index ef8930f6cd3..5bb9f68d80e 100644 --- a/src/stitch_pyramid/JPEGPyramid.cpp +++ b/src/stitch_pyramid/JPEGPyramid.cpp @@ -70,7 +70,7 @@ void JPEGPyramid::AvgLerpPad(JPEGImage & image){ assert( padx_ == pady_ ); // corner padding assumes this (for now) float corner_lerp[padx_+1]; - //top (& bottom?) + //top, bottom, left, right for(int ch=0; ch<3; ch++){ float avgPx = IMAGENET_MEAN_RGB[ch]; for(int x=padx_; x < width-padx_; x++){ @@ -108,44 +108,46 @@ void JPEGPyramid::AvgLerpPad(JPEGImage & image){ image.bits()[y*width*depth + imgX*depth + ch] = right_lerp[x]; } } - // dim 0 --> - side of image - assert( padx_ == pady_ ); // corner padding assumes this (for now) - for( uint32_t dx = 0; dx != 2; ++ dx ) { - for( uint32_t dy = 0; dy != 2; ++ dy ) { - // x,y is coord of dx,dy valid corner pixel of un-padded image - uint32_t const x = dx ? (width-padx_-1) : padx_; - uint32_t const y = dy ? (height-pady_-1) : pady_; - for( uint32_t dd = 2; dd <= padx_; ++dd ) { - uint32_t const cx = x + ( dx ? dd : -dd ); // cx,y is point on existing dx padding, dd outside image - uint32_t const cy = y + ( dy ? dd : -dd ); // x,cy is point on existing dy padding, dd outside image - assert( x < width ); assert( y < height ); - assert( cx < width ); assert( cy < height ); - float const cx_y_v = image.bits()[y*width*depth + cx*depth + ch]; - float const x_cy_v = image.bits()[cy*width*depth + x*depth + ch]; - linear_interp(cx_y_v, x_cy_v, dd+1, corner_lerp); // populate corner_lerp - for( uint32_t ci = 1; ci < dd; ++ci ) { // fill in diagonal corner pixels - uint32_t const cix = x + ( dx ? ci : -ci ); - uint32_t const ciy = cy + ( dy ? -ci : ci ); - //printf( "dx=%s x=%s cx=%s ci=%s cix=%s dd=%s\n", - // str(dx).c_str(), str(x).c_str(), str(cx).c_str(), str(ci).c_str(), str(cix).c_str(), str(dd).c_str() ); - assert( cix < width ); assert( ciy < height ); - image.bits()[ciy*width*depth + cix*depth + ch] = corner_lerp[ci]; - } - } - // fill in all-mean outer half of corner (a triangle) - uint32_t const cor_x = dx ? (width-1) : 0; - uint32_t const cor_y = dy ? (height-1) : 0; - // cor_x,cor_y is coord of dx,dy corner pixel of image (including padding) - for( uint32_t dd = 0; dd < padx_; ++dd ) { - for( uint32_t ddi = 0; ddi < (padx_-dd); ++ddi ) { - uint32_t const tri_x = cor_x + ( dx ? -dd : dd ); - uint32_t const tri_y = cor_y + ( dy ? -ddi : ddi ); - assert( tri_x < width ); assert( tri_y < height ); - image.bits()[tri_y*width*depth + tri_x*depth + ch] = avgPx; - } - } - } - } + + //corner padding... + // dim 0 --> - side of image + assert( padx_ == pady_ ); // corner padding assumes this (for now) + for( uint32_t dx = 0; dx != 2; ++ dx ) { + for( uint32_t dy = 0; dy != 2; ++ dy ) { + // x,y is coord of dx,dy valid corner pixel of un-padded image + uint32_t const x = dx ? (width-padx_-1) : padx_; + uint32_t const y = dy ? (height-pady_-1) : pady_; + for( uint32_t dd = 2; dd <= padx_; ++dd ) { + uint32_t const cx = x + ( dx ? dd : -dd ); // cx,y is point on existing dx padding, dd outside image + uint32_t const cy = y + ( dy ? dd : -dd ); // x,cy is point on existing dy padding, dd outside image + assert( x < width ); assert( y < height ); + assert( cx < width ); assert( cy < height ); + float const cx_y_v = image.bits()[y*width*depth + cx*depth + ch]; + float const x_cy_v = image.bits()[cy*width*depth + x*depth + ch]; + linear_interp(cx_y_v, x_cy_v, dd+1, corner_lerp); // populate corner_lerp + for( uint32_t ci = 1; ci < dd; ++ci ) { // fill in diagonal corner pixels + uint32_t const cix = x + ( dx ? ci : -ci ); + uint32_t const ciy = cy + ( dy ? -ci : ci ); + //printf( "dx=%s x=%s cx=%s ci=%s cix=%s dd=%s\n", + // str(dx).c_str(), str(x).c_str(), str(cx).c_str(), str(ci).c_str(), str(cix).c_str(), str(dd).c_str() ); + assert( cix < width ); assert( ciy < height ); + image.bits()[ciy*width*depth + cix*depth + ch] = corner_lerp[ci]; + } + } + // fill in all-mean outer half of corner (a triangle) + uint32_t const cor_x = dx ? (width-1) : 0; + uint32_t const cor_y = dy ? (height-1) : 0; + // cor_x,cor_y is coord of dx,dy corner pixel of image (including padding) + for( uint32_t dd = 0; dd < padx_; ++dd ) { + for( uint32_t ddi = 0; ddi < (padx_-dd); ++ddi ) { + uint32_t const tri_x = cor_x + ( dx ? -dd : dd ); + uint32_t const tri_y = cor_y + ( dy ? -ddi : ddi ); + assert( tri_x < width ); assert( tri_y < height ); + image.bits()[tri_y*width*depth + tri_x*depth + ch] = avgPx; + } + } + } + } } } From 6dee4081b3aaf29ee4988d42a2034df5d25e493e Mon Sep 17 00:00:00 2001 From: forresti Date: Wed, 29 Jan 2014 13:29:29 -0800 Subject: [PATCH 33/92] add visualization to demo --- matlab/caffe/featpyramid_matcaffe_demo.m | 48 ++++++++++++----------- matlab/caffe/pascal_000001.jpg | Bin 0 -> 78771 bytes 2 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 matlab/caffe/pascal_000001.jpg diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index a8c707e22d0..b8f0b7c3855 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -1,7 +1,5 @@ -function pyra = featpyramid_matcaffe_demo(imfn, use_gpu) -% scores = matcaffe_demo(im, use_gpu) -% -% Demo of the matlab wrapper using the ILSVRC network to produce a feature pyramid. + +% Demo of the matlab wrapper to construct ConvNet feature pyramids % % input % imfn image filename @@ -21,27 +19,33 @@ % imfn = '../../examples/cat.jpg'; % pyra = featpyramid_matcaffe_demo(imfn, 1); -if ~exist('imfn', 'var') - imfn = '/home/moskewcz/svn_work/boda/test/pascal/000001.jpg' -end +function pyra = featpyramid_matcaffe_demo(imfn, use_gpu) + if ~exist('imfn', 'var') + imfn = './pascal_000001.jpg' + %imfn = '../../python/caffe/imagenet/pascal_009959.jpg'; + end + + %model_def_file = '../../examples/imagenet_deploy.prototxt'; + model_def_file = '../../python/caffe/imagenet/imagenet_rcnn_batch_1_input_1100x1100_output_conv5.prototxt' + % NOTE: you'll have to get the pre-trained ILSVRC network + model_file = '../../examples/alexnet_train_iter_470000'; -%model_def_file = '../../examples/imagenet_deploy.prototxt'; -model_def_file = '../../python/caffe/imagenet/imagenet_rcnn_batch_1_input_1100x1100_output_conv5.prototxt' -% NOTE: you'll have to get the pre-trained ILSVRC network -model_file = '../../examples/alexnet_train_iter_470000'; + % init caffe network (spews logging info) + caffe('init', model_def_file, model_file); -% init caffe network (spews logging info) -caffe('init', model_def_file, model_file); + % set to use GPU or CPU + if exist('use_gpu', 'var') && use_gpu + caffe('set_mode_gpu'); + else + caffe('set_mode_cpu'); + end -% set to use GPU or CPU -if exist('use_gpu', 'var') && use_gpu - caffe('set_mode_gpu'); -else - caffe('set_mode_cpu'); -end + % put into test mode + caffe('set_phase_test'); -% put into test mode -caffe('set_phase_test'); + pyra = caffe('convnet_featpyramid', imfn ); -pyra = caffe('convnet_featpyramid', imfn ); + %visualize one scale: + colormap(gray) + imagesc(squeeze(sum(pyra(1).feats, 1))) diff --git a/matlab/caffe/pascal_000001.jpg b/matlab/caffe/pascal_000001.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a13736601989ab6fc5b4dc9a6b9412a063e57b11 GIT binary patch literal 78771 zcmbTdWl$Vn&_258;sgyY!686!hXBDXKybGZ+}+(4w;%z66N0-fzPP)~;_fU2`SW|< zs(ZiO5BJ`lI$bk0=S=l;&QwpIr+Z!(UpE2orc){(H#(4uwZTKtMtR zA_M=Y%l{|!+6BNtfxCe-L4f-JfX9JDz=3=115m!%iS$3_y&3zz0tb(Ph=dG$GXwpt zL&Li_^AQlq`V zR5Zf(M8qU?^bCwl%-lS@eEb4}l3%2xWn|^#)xT+IYH91}nweXCxBOvc?c(a@?&0a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9*Xj;n&UDG65X{IIeHSF1Obg0(izDw1`HkNC0Jh{pg~&@h$R8)AdJdgcFlX VvB&+kUr+pfzs8CvrDR>%|Jj(TBfJ0r literal 0 HcmV?d00001 From 7b785fc945d6a38d0b1f9e262e0979552890195c Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 30 Jan 2014 12:42:18 -0800 Subject: [PATCH 34/92] setting up code to rip a bbox out of a pyra --- matlab/caffe/get_featureSlice.m | 18 +++++++++++++++ matlab/caffe/test_get_featureSlice.m | 34 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 matlab/caffe/get_featureSlice.m create mode 100644 matlab/caffe/test_get_featureSlice.m diff --git a/matlab/caffe/get_featureSlice.m b/matlab/caffe/get_featureSlice.m new file mode 100644 index 00000000000..f98cd3735e8 --- /dev/null +++ b/matlab/caffe/get_featureSlice.m @@ -0,0 +1,18 @@ + + +% @param pyra... should contain 'sbin' and 'scales' +% @param templateSize = desired shape of output in feature descriptor units (e.g. [6 10] root filter) +% +% do we really need image_size? +function featureSlice = get_featureSlice(pyra, bbox, templateSize, imageSize) + + %1. select a scale in the pyramid + + + + %2. rip out a slice from the appropriate scale + + +end + + diff --git a/matlab/caffe/test_get_featureSlice.m b/matlab/caffe/test_get_featureSlice.m new file mode 100644 index 00000000000..a20b81fa394 --- /dev/null +++ b/matlab/caffe/test_get_featureSlice.m @@ -0,0 +1,34 @@ + +function test_getFeatureSlice() + + %TODO: add voc-release5/features to path. + addpath('../../voc-release5/bin') + addpath('../../voc-release5/features') + + im = imread('./pascal_000001.jpg'); + + %bare bones model to run DPM's HOG code + model.features.sbin = 4; + model.padx = 8; + model.pady = 8; + model.interval = 10; + model.features.extra_octave = 0; + + pyra = featpyramid(im, model, model.padx, model.pady); + + + templateSize = [6 10]; + imageSize = size(im); + bbox.x1 = 10; + bbox.x2 = 90; + bbox.y1 = 100; + bbox.y2 = 148; + + %featureSlice = get_featureSlice(pyra, bbox, templateSize, imageSize); + + %imagesc(sum(featureSlice,3)) + +end + + + From 252737a77f94d3cf5a9d895689efde755ea2b5c5 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 30 Jan 2014 12:44:11 -0800 Subject: [PATCH 35/92] running hog pyra for regression test --- matlab/caffe/test_get_featureSlice.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/matlab/caffe/test_get_featureSlice.m b/matlab/caffe/test_get_featureSlice.m index a20b81fa394..94630a1e68f 100644 --- a/matlab/caffe/test_get_featureSlice.m +++ b/matlab/caffe/test_get_featureSlice.m @@ -8,11 +8,14 @@ function test_getFeatureSlice() im = imread('./pascal_000001.jpg'); %bare bones model to run DPM's HOG code - model.features.sbin = 4; + model.sbin = 4; + %model.features.sbin = model.sbin; model.padx = 8; model.pady = 8; model.interval = 10; model.features.extra_octave = 0; + model.features.dim = 32; + model.features.truncation_dim = 32; pyra = featpyramid(im, model, model.padx, model.pady); @@ -23,7 +26,7 @@ function test_getFeatureSlice() bbox.x2 = 90; bbox.y1 = 100; bbox.y2 = 148; - + %featureSlice = get_featureSlice(pyra, bbox, templateSize, imageSize); %imagesc(sum(featureSlice,3)) From 84fa07519c5a383676d637ae69b909e12f0f23c1 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 30 Jan 2014 13:10:20 -0800 Subject: [PATCH 36/92] testing scale calc --- matlab/caffe/get_featureSlice.m | 41 ++++++++++++++++++++++++++-- matlab/caffe/test_get_featureSlice.m | 6 ++-- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/matlab/caffe/get_featureSlice.m b/matlab/caffe/get_featureSlice.m index f98cd3735e8..5bb3d88e29c 100644 --- a/matlab/caffe/get_featureSlice.m +++ b/matlab/caffe/get_featureSlice.m @@ -1,18 +1,53 @@ % @param pyra... should contain 'sbin' and 'scales' +% @param bbox.{x1 x2 y1 y2} -- in image coordinates. % @param templateSize = desired shape of output in feature descriptor units (e.g. [6 10] root filter) % -% do we really need image_size? +% do we really need image_size? (and, imsize is typically in the pyra.) function featureSlice = get_featureSlice(pyra, bbox, templateSize, imageSize) - %1. select a scale in the pyramid +%experiment: +%pyra.sbin = 8; + %1. select a scale in the pyramid + bbox_desc = bbox_mult(bbox, 1.0/single(pyra.sbin)) % unscaled image -> unscaled feature coords. + bbox_desc_dim = [bbox_desc.y2 - bbox_desc.y1, bbox_desc.x2 - bbox_desc.x1]; %bbox dim in the space of scale=1 descriptors. + bbox_desc_scale = templateSize / bbox_desc_dim; %scale factor from (scale=1) to a scale where bbox fits in templateSize - %2. rip out a slice from the appropriate scale + scale_to_use = mean(bbox_desc_scale); %avg of scale factors for x and y dims. + [scale_to_use, scaleIdx] = findNearestScale(scale_to_use, pyra.scales); %best precomputed approx of scale_to_use + %2. rip out a slice from the appropriate scale + + bbox_to_use.x1 = bbox_desc.x1 * scale_to_use; %TODO: add padx/sbin + bbox_to_use.x2 = bbox_to_use.x1 + templateSize(2); + bbox_to_use.y1 = bbox_desc.y1 * scale_to_use; %TODO: add pady/sbin + bbox_to_use.y2 = bbox_to_use.y1 + templateSize(1); + bbox_to_use + scale_to_use + %TODO: add padx/sbin, pady/sbin + + featureSlice = []; %stub +end + +% divide a bbox.{x1 x2 y1 y2} by some value. +function bbox_out = bbox_mult(bbox, multiplier) + + bbox_out.x1 = bbox.x1 * multiplier; + bbox_out.x2 = bbox.x2 * multiplier; + bbox_out.y1 = bbox.y1 * multiplier; + bbox_out.y2 = bbox.y2 * multiplier; end +% @param scale_to_use = a scale that maps bbox to templateSize +% @param scales = list of scales that we computed in our pyramid +function [scale_to_use, scaleIdx] = findNearestScale(scale_to_use, scales) + + %scaleIdx = index of nearestScale in the list of scales + [nearestScale_distance, scaleIdx] = min(abs(scale_to_use - scales)); + scale_to_use = scales(scaleIdx); +end diff --git a/matlab/caffe/test_get_featureSlice.m b/matlab/caffe/test_get_featureSlice.m index 94630a1e68f..54fd8707aa7 100644 --- a/matlab/caffe/test_get_featureSlice.m +++ b/matlab/caffe/test_get_featureSlice.m @@ -19,15 +19,15 @@ function test_getFeatureSlice() pyra = featpyramid(im, model, model.padx, model.pady); - templateSize = [6 10]; imageSize = size(im); bbox.x1 = 10; bbox.x2 = 90; bbox.y1 = 100; bbox.y2 = 148; - - %featureSlice = get_featureSlice(pyra, bbox, templateSize, imageSize); + + pyra.sbin = model.sbin; + featureSlice = get_featureSlice(pyra, bbox, templateSize, imageSize); %imagesc(sum(featureSlice,3)) From 59f7a3905d14948d15889240d3fb14d843b47240 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 30 Jan 2014 13:34:53 -0800 Subject: [PATCH 37/92] bbox slicing from pyra looks reasonable now. (in hog space... will test in convnet space soon) --- matlab/caffe/get_featureSlice.m | 28 +++++++++++++++++----------- matlab/caffe/test_get_featureSlice.m | 21 +++++++++++++++++---- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/matlab/caffe/get_featureSlice.m b/matlab/caffe/get_featureSlice.m index 5bb3d88e29c..357f832ec64 100644 --- a/matlab/caffe/get_featureSlice.m +++ b/matlab/caffe/get_featureSlice.m @@ -1,36 +1,42 @@ % @param pyra... should contain 'sbin' and 'scales' -% @param bbox.{x1 x2 y1 y2} -- in image coordinates. +% @param bbox.{x1 x2 y1 y2} -- in image coordinates. -- must be round numbers. % @param templateSize = desired shape of output in feature descriptor units (e.g. [6 10] root filter) % % do we really need image_size? (and, imsize is typically in the pyra.) -function featureSlice = get_featureSlice(pyra, bbox, templateSize, imageSize) +function [featureSlice, scaleIdx] = get_featureSlice(pyra, bbox, templateSize, imageSize) %experiment: %pyra.sbin = 8; %1. select a scale in the pyramid - bbox_desc = bbox_mult(bbox, 1.0/single(pyra.sbin)) % unscaled image -> unscaled feature coords. + bbox_desc = bbox_mult(bbox, 1.0/single(pyra.sbin)); % unscaled image -> unscaled descriptor coords. bbox_desc_dim = [bbox_desc.y2 - bbox_desc.y1, bbox_desc.x2 - bbox_desc.x1]; %bbox dim in the space of scale=1 descriptors. bbox_desc_scale = templateSize / bbox_desc_dim; %scale factor from (scale=1) to a scale where bbox fits in templateSize scale_to_use = mean(bbox_desc_scale); %avg of scale factors for x and y dims. [scale_to_use, scaleIdx] = findNearestScale(scale_to_use, pyra.scales); %best precomputed approx of scale_to_use + %padx_desc_scaled = (pyra.padx / pyra.sbin) * scale_to_use; %in descriptor coords, at scale_to_use. + %pady_desc_scaled = (pyra.pady / pyra.sbin) * scale_to_use; + padx_desc_scaled = pyra.padx; %AHA, this is really in HOG cells and not image pixels. + pady_desc_scaled = pyra.pady; + + %2. rip out a slice from the appropriate scale - - bbox_to_use.x1 = bbox_desc.x1 * scale_to_use; %TODO: add padx/sbin - bbox_to_use.x2 = bbox_to_use.x1 + templateSize(2); - bbox_to_use.y1 = bbox_desc.y1 * scale_to_use; %TODO: add pady/sbin - bbox_to_use.y2 = bbox_to_use.y1 + templateSize(1); + + %TODO: round bbox_desc.{x1, y1} + bbox_to_use.x1 = round(bbox_desc.x1 * scale_to_use + padx_desc_scaled); %TODO: add padx/sbin + bbox_to_use.x2 = bbox_to_use.x1 + templateSize(2) - 1; + bbox_to_use.y1 = round(bbox_desc.y1 * scale_to_use + pady_desc_scaled); %TODO: add pady/sbin + bbox_to_use.y2 = bbox_to_use.y1 + templateSize(1) - 1; bbox_to_use scale_to_use + scaleIdx - %TODO: add padx/sbin, pady/sbin - - featureSlice = []; %stub + featureSlice = pyra.feat{scaleIdx}(bbox_to_use.y1 : bbox_to_use.y2, bbox_to_use.x1 : bbox_to_use.x2, :); %stub end % divide a bbox.{x1 x2 y1 y2} by some value. diff --git a/matlab/caffe/test_get_featureSlice.m b/matlab/caffe/test_get_featureSlice.m index 54fd8707aa7..bb5441d13b7 100644 --- a/matlab/caffe/test_get_featureSlice.m +++ b/matlab/caffe/test_get_featureSlice.m @@ -4,6 +4,7 @@ function test_getFeatureSlice() %TODO: add voc-release5/features to path. addpath('../../voc-release5/bin') addpath('../../voc-release5/features') + addpath('../../voc-release5/vis') im = imread('./pascal_000001.jpg'); @@ -21,16 +22,28 @@ function test_getFeatureSlice() templateSize = [6 10]; imageSize = size(im); - bbox.x1 = 10; - bbox.x2 = 90; + bbox.x1 = 110; + bbox.x2 = 190; bbox.y1 = 100; bbox.y2 = 148; pyra.sbin = model.sbin; - featureSlice = get_featureSlice(pyra, bbox, templateSize, imageSize); + [featureSlice, scaleIdx] = get_featureSlice(pyra, bbox, templateSize, imageSize); + % if using convnets... + %figure(1) + %colormap(gray); %imagesc(sum(featureSlice,3)) - + + % if using HOG... + figure(2) + w = foldHOG(featureSlice); + visualizeHOG(w); + + figure(3); + w = foldHOG(pyra.feat{scaleIdx}); + visualizeHOG(w); + end From f5073c5044f8e9b8e49b83e6ecaeff5a0be89278 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 30 Jan 2014 16:46:23 -0800 Subject: [PATCH 38/92] working on only using pyramids and no on-demand features in DPM training. root_model() now updates spos{} to 'know' its root filter shape --- matlab/caffe/get_featureSlice.m | 8 +++----- matlab/caffe/test_get_featureSlice.m | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/matlab/caffe/get_featureSlice.m b/matlab/caffe/get_featureSlice.m index 357f832ec64..0c02fa6419e 100644 --- a/matlab/caffe/get_featureSlice.m +++ b/matlab/caffe/get_featureSlice.m @@ -3,8 +3,7 @@ % @param pyra... should contain 'sbin' and 'scales' % @param bbox.{x1 x2 y1 y2} -- in image coordinates. -- must be round numbers. % @param templateSize = desired shape of output in feature descriptor units (e.g. [6 10] root filter) -% -% do we really need image_size? (and, imsize is typically in the pyra.) +% (could pass in image_size ... though we currently don't use it, and imsize is typically in pyra) function [featureSlice, scaleIdx] = get_featureSlice(pyra, bbox, templateSize, imageSize) %experiment: @@ -27,10 +26,9 @@ %2. rip out a slice from the appropriate scale - %TODO: round bbox_desc.{x1, y1} - bbox_to_use.x1 = round(bbox_desc.x1 * scale_to_use + padx_desc_scaled); %TODO: add padx/sbin + bbox_to_use.x1 = round(bbox_desc.x1 * scale_to_use + padx_desc_scaled); bbox_to_use.x2 = bbox_to_use.x1 + templateSize(2) - 1; - bbox_to_use.y1 = round(bbox_desc.y1 * scale_to_use + pady_desc_scaled); %TODO: add pady/sbin + bbox_to_use.y1 = round(bbox_desc.y1 * scale_to_use + pady_desc_scaled); bbox_to_use.y2 = bbox_to_use.y1 + templateSize(1) - 1; bbox_to_use scale_to_use diff --git a/matlab/caffe/test_get_featureSlice.m b/matlab/caffe/test_get_featureSlice.m index bb5441d13b7..ae9575dbc46 100644 --- a/matlab/caffe/test_get_featureSlice.m +++ b/matlab/caffe/test_get_featureSlice.m @@ -28,7 +28,7 @@ function test_getFeatureSlice() bbox.y2 = 148; pyra.sbin = model.sbin; - [featureSlice, scaleIdx] = get_featureSlice(pyra, bbox, templateSize, imageSize); + [featureSlice, scaleIdx] = get_featureSlice(pyra, bbox, templateSize); % if using convnets... %figure(1) From fba4623afc5b5c893a7c37c7e76dbbf76862cb81 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 30 Jan 2014 18:02:56 -0800 Subject: [PATCH 39/92] first pass at precomputing features instead of warping --- matlab/caffe/get_featureSlice.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/caffe/get_featureSlice.m b/matlab/caffe/get_featureSlice.m index 0c02fa6419e..14e88ea550d 100644 --- a/matlab/caffe/get_featureSlice.m +++ b/matlab/caffe/get_featureSlice.m @@ -4,7 +4,7 @@ % @param bbox.{x1 x2 y1 y2} -- in image coordinates. -- must be round numbers. % @param templateSize = desired shape of output in feature descriptor units (e.g. [6 10] root filter) % (could pass in image_size ... though we currently don't use it, and imsize is typically in pyra) -function [featureSlice, scaleIdx] = get_featureSlice(pyra, bbox, templateSize, imageSize) +function [featureSlice, scaleIdx] = get_featureSlice(pyra, bbox, templateSize) %experiment: %pyra.sbin = 8; From ed97d452ae8589518b5a8ed92f6a7084c42bc486 Mon Sep 17 00:00:00 2001 From: forresti Date: Fri, 31 Jan 2014 11:59:13 -0800 Subject: [PATCH 40/92] calling precompute_gt_bbox_features() from the voc5 training code --- matlab/caffe/get_featureSlice.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/matlab/caffe/get_featureSlice.m b/matlab/caffe/get_featureSlice.m index 14e88ea550d..93e7de7b1a9 100644 --- a/matlab/caffe/get_featureSlice.m +++ b/matlab/caffe/get_featureSlice.m @@ -30,11 +30,11 @@ bbox_to_use.x2 = bbox_to_use.x1 + templateSize(2) - 1; bbox_to_use.y1 = round(bbox_desc.y1 * scale_to_use + pady_desc_scaled); bbox_to_use.y2 = bbox_to_use.y1 + templateSize(1) - 1; - bbox_to_use - scale_to_use - scaleIdx + %bbox_to_use + %scale_to_use + %scaleIdx - featureSlice = pyra.feat{scaleIdx}(bbox_to_use.y1 : bbox_to_use.y2, bbox_to_use.x1 : bbox_to_use.x2, :); %stub + featureSlice = pyra.feat{scaleIdx}(bbox_to_use.y1 : bbox_to_use.y2, bbox_to_use.x1 : bbox_to_use.x2, :); end % divide a bbox.{x1 x2 y1 y2} by some value. From e0aafd0cd0f230bf1b7ac3bfc7ac9b92735472f3 Mon Sep 17 00:00:00 2001 From: forresti Date: Tue, 4 Feb 2014 19:09:37 -0800 Subject: [PATCH 41/92] looks like there's systematic shift of bboxes slightly left from where they should be. (when rounding) --- matlab/caffe/get_featureSlice.m | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/matlab/caffe/get_featureSlice.m b/matlab/caffe/get_featureSlice.m index 93e7de7b1a9..93850ad9c6f 100644 --- a/matlab/caffe/get_featureSlice.m +++ b/matlab/caffe/get_featureSlice.m @@ -4,10 +4,12 @@ % @param bbox.{x1 x2 y1 y2} -- in image coordinates. -- must be round numbers. % @param templateSize = desired shape of output in feature descriptor units (e.g. [6 10] root filter) % (could pass in image_size ... though we currently don't use it, and imsize is typically in pyra) -function [featureSlice, scaleIdx] = get_featureSlice(pyra, bbox, templateSize) +function [featureSlice, scaleIdx, roundedBox_in_px] = get_featureSlice(pyra, bbox, templateSize) %experiment: %pyra.sbin = 8; +%pyra.padx=4; +%pyra.pady=4; %1. select a scale in the pyramid @@ -35,9 +37,16 @@ %scaleIdx featureSlice = pyra.feat{scaleIdx}(bbox_to_use.y1 : bbox_to_use.y2, bbox_to_use.x1 : bbox_to_use.x2, :); + + roundedBox_in_px = bbox_mult(bbox_to_use, (pyra.sbin / scale_to_use)); %project rounded box back to img space (approx) + %roundedBox_in_px = bbox_add(roundedBox_in_px, -pyra.padx*pyra.sbin/scale_to_use); %assume padx==pady + roundedBox_in_px.x1 = roundedBox_in_px.x1 - pyra.padx*pyra.sbin/scale_to_use; + roundedBox_in_px.x2 = roundedBox_in_px.x2 - pyra.padx*pyra.sbin/scale_to_use; + roundedBox_in_px.y1 = roundedBox_in_px.y1 - pyra.pady*pyra.sbin/scale_to_use; + roundedBox_in_px.y2 = roundedBox_in_px.y2 - pyra.pady*pyra.sbin/scale_to_use; end -% divide a bbox.{x1 x2 y1 y2} by some value. +% multiply a bbox.{x1 x2 y1 y2} by some value. function bbox_out = bbox_mult(bbox, multiplier) bbox_out.x1 = bbox.x1 * multiplier; @@ -46,6 +55,14 @@ bbox_out.y2 = bbox.y2 * multiplier; end +% add some value to a bbox.{x1 x2 y1 y2}. +function bbox_out = bbox_add(bbox, num_to_add) + bbox_out.x1 = bbox.x1 + num_to_add; + bbox_out.x2 = bbox.x2 + num_to_add; + bbox_out.y1 = bbox.y1 + num_to_add; + bbox_out.y2 = bbox.y2 + num_to_add; +end + % @param scale_to_use = a scale that maps bbox to templateSize % @param scales = list of scales that we computed in our pyramid function [scale_to_use, scaleIdx] = findNearestScale(scale_to_use, scales) From ed74ae5251c26fbcdaf520bfb2503895b2a32381 Mon Sep 17 00:00:00 2001 From: forresti Date: Wed, 5 Feb 2014 14:03:19 -0800 Subject: [PATCH 42/92] centering approx bbox on each exemplar in hog space. (previously, was anchored to top left) --- matlab/caffe/get_featureSlice.m | 53 +++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/matlab/caffe/get_featureSlice.m b/matlab/caffe/get_featureSlice.m index 93850ad9c6f..57b08c0c535 100644 --- a/matlab/caffe/get_featureSlice.m +++ b/matlab/caffe/get_featureSlice.m @@ -8,10 +8,11 @@ %experiment: %pyra.sbin = 8; -%pyra.padx=4; -%pyra.pady=4; - %1. select a scale in the pyramid + %1. tweak bbox to match the aspect ratio of templateSize + %bbox = match_aspect_ratio(bbox, templateSize); + + %2. select a scale in the pyramid bbox_desc = bbox_mult(bbox, 1.0/single(pyra.sbin)); % unscaled image -> unscaled descriptor coords. bbox_desc_dim = [bbox_desc.y2 - bbox_desc.y1, bbox_desc.x2 - bbox_desc.x1]; %bbox dim in the space of scale=1 descriptors. @@ -26,19 +27,32 @@ pady_desc_scaled = pyra.pady; - %2. rip out a slice from the appropriate scale - - bbox_to_use.x1 = round(bbox_desc.x1 * scale_to_use + padx_desc_scaled); + %3. rip out a slice from the appropriate scale + + %TODO: center it on (bbox_desc.x2 - bbox_desc.x1), (bbox_desc.y2 - bbox_desc.y1) + + bbox_desc_x_center = bbox_desc.x1 + (bbox_desc.x2 - bbox_desc.x1)/2.0; + bbox_desc_y_center = bbox_desc.y1 + (bbox_desc.y2 - bbox_desc.y1)/2.0; + bbox_to_use.x1 = round(bbox_desc_x_center*scale_to_use - templateSize(2)/2.0 + padx_desc_scaled); %(center - templateWidth/2) bbox_to_use.x2 = bbox_to_use.x1 + templateSize(2) - 1; - bbox_to_use.y1 = round(bbox_desc.y1 * scale_to_use + pady_desc_scaled); + bbox_to_use.y1 = round(bbox_desc_y_center*scale_to_use - templateSize(1)/2.0 + pady_desc_scaled); %(center - templateHeight/2) bbox_to_use.y2 = bbox_to_use.y1 + templateSize(1) - 1; + %display('new...') + %bbox_to_use + + %bbox_to_use.x1 = round(bbox_desc.x1 * scale_to_use + padx_desc_scaled); + %bbox_to_use.x2 = bbox_to_use.x1 + templateSize(2) - 1; + %bbox_to_use.y1 = round(bbox_desc.y1 * scale_to_use + pady_desc_scaled); + %bbox_to_use.y2 = bbox_to_use.y1 + templateSize(1) - 1; + %display('old...') %bbox_to_use %scale_to_use %scaleIdx featureSlice = pyra.feat{scaleIdx}(bbox_to_use.y1 : bbox_to_use.y2, bbox_to_use.x1 : bbox_to_use.x2, :); - roundedBox_in_px = bbox_mult(bbox_to_use, (pyra.sbin / scale_to_use)); %project rounded box back to img space (approx) + %4. project rounded box back to img space (approx) -- for debugging + roundedBox_in_px = bbox_mult(bbox_to_use, (pyra.sbin / scale_to_use)); %roundedBox_in_px = bbox_add(roundedBox_in_px, -pyra.padx*pyra.sbin/scale_to_use); %assume padx==pady roundedBox_in_px.x1 = roundedBox_in_px.x1 - pyra.padx*pyra.sbin/scale_to_use; roundedBox_in_px.x2 = roundedBox_in_px.x2 - pyra.padx*pyra.sbin/scale_to_use; @@ -46,9 +60,30 @@ roundedBox_in_px.y2 = roundedBox_in_px.y2 - pyra.pady*pyra.sbin/scale_to_use; end +% @param gt_bbox = example bbox to slice out of pyramid (in pixel coords) +% @param templateSize = shape desired in terms of HOG cells +function gt_bbox_new = match_aspect_ratio(gt_bbox, templateSize) + + aspect_ratio_template = templateSize(1)/templateSize(2) % height/width + aspect_ratio_gt = (gt_bbox.y2 - gt_bbox.y1) / (gt_bbox.x2 - gt_bbox.x1) + + gt_bbox_new = gt_bbox; + if(aspect_ratio_template < aspect_ratio_gt) %gt_bbox is too tall + %make gt_bbox wider (height stays unchanged) + gt_width = gt_bbox.x2 - gt_bbox.x1; + gt_new_width = gt_width * (aspect_ratio_gt / aspect_ratio_template); %wider + gt_bbox_new.x2 = gt_bbox.x2 - gt_width + gt_new_width; + + elseif(aspect_ratio_template > aspect_ratio_gt) %gt_bbox is too wide + %make gt_bbox taller (width stays unchanged) + gt_height = gt_bbox.y2 - gt_bbox.y1; + gt_new_height = gt_height * (aspect_ratio_template / aspect_ratio_gt); %taller + gt_bbox_new.y2 = gt_bbox.y2 - gt_height + gt_new_height; + end +end + % multiply a bbox.{x1 x2 y1 y2} by some value. function bbox_out = bbox_mult(bbox, multiplier) - bbox_out.x1 = bbox.x1 * multiplier; bbox_out.x2 = bbox.x2 * multiplier; bbox_out.y1 = bbox.y1 * multiplier; From 223e01a7a6d166043c4e89dd9e07dd769df5b8b9 Mon Sep 17 00:00:00 2001 From: forresti Date: Wed, 5 Feb 2014 15:49:46 -0800 Subject: [PATCH 43/92] centering hog features, this time with ceil() instead of round(). also, looking at results without truncation features. --- matlab/caffe/get_featureSlice.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/matlab/caffe/get_featureSlice.m b/matlab/caffe/get_featureSlice.m index 57b08c0c535..145c61646cc 100644 --- a/matlab/caffe/get_featureSlice.m +++ b/matlab/caffe/get_featureSlice.m @@ -16,7 +16,8 @@ bbox_desc = bbox_mult(bbox, 1.0/single(pyra.sbin)); % unscaled image -> unscaled descriptor coords. bbox_desc_dim = [bbox_desc.y2 - bbox_desc.y1, bbox_desc.x2 - bbox_desc.x1]; %bbox dim in the space of scale=1 descriptors. - bbox_desc_scale = templateSize / bbox_desc_dim; %scale factor from (scale=1) to a scale where bbox fits in templateSize + %bbox_desc_scale = templateSize / bbox_desc_dim; %scale factor from (scale=1) to a scale where bbox fits in templateSize + bbox_desc_scale = (templateSize-1) / bbox_desc_dim; %pretend that template size is slightly smaller... so featureSlice will be slightly outside orig bbox scale_to_use = mean(bbox_desc_scale); %avg of scale factors for x and y dims. [scale_to_use, scaleIdx] = findNearestScale(scale_to_use, pyra.scales); %best precomputed approx of scale_to_use @@ -33,9 +34,9 @@ bbox_desc_x_center = bbox_desc.x1 + (bbox_desc.x2 - bbox_desc.x1)/2.0; bbox_desc_y_center = bbox_desc.y1 + (bbox_desc.y2 - bbox_desc.y1)/2.0; - bbox_to_use.x1 = round(bbox_desc_x_center*scale_to_use - templateSize(2)/2.0 + padx_desc_scaled); %(center - templateWidth/2) + bbox_to_use.x1 = ceil(bbox_desc_x_center*scale_to_use - templateSize(2)/2.0 + padx_desc_scaled); %(center - templateWidth/2) bbox_to_use.x2 = bbox_to_use.x1 + templateSize(2) - 1; - bbox_to_use.y1 = round(bbox_desc_y_center*scale_to_use - templateSize(1)/2.0 + pady_desc_scaled); %(center - templateHeight/2) + bbox_to_use.y1 = ceil(bbox_desc_y_center*scale_to_use - templateSize(1)/2.0 + pady_desc_scaled); %(center - templateHeight/2) bbox_to_use.y2 = bbox_to_use.y1 + templateSize(1) - 1; %display('new...') %bbox_to_use From 1b2bfb3b1eb913420707b0852d9c87f0863730c1 Mon Sep 17 00:00:00 2001 From: forresti Date: Wed, 5 Feb 2014 18:07:41 -0800 Subject: [PATCH 44/92] python API now returns imwidth, imheight of input image --- python/caffe/imagenet/featpyramid_tests.py | 1 + python/caffe/pycaffe.cpp | 2 ++ src/stitch_pyramid/JPEGPyramid.cpp | 4 +++- src/stitch_pyramid/JPEGPyramid.h | 3 +++ src/stitch_pyramid/Patchwork.cpp | 2 ++ src/stitch_pyramid/Patchwork.h | 5 ++++- 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py index 0831ebba042..1adf98e967b 100644 --- a/python/caffe/imagenet/featpyramid_tests.py +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -66,6 +66,7 @@ def test_featpyramid_allScales(caffenet, imgFname): print "\n pyra scales:" print pyra["scales"] + print "pyra[imwidth] = %d, pyra[imheight]=%d" % (pyra['imwidth'], pyra['imheight']) if __name__ == "__main__": diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index c28ca8934c1..c92cf910510 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -392,6 +392,8 @@ struct CaffeNet { //d["blobs_top"] = blobs_top; //for debugging -- stitched descriptors d["feat"] = unstitched_features; d["scales"] = scales_npy_boost; + d["imwidth"] = patchwork.imwidth_; //input image dims + d["imheight"] = patchwork.imheight_; return d; } diff --git a/src/stitch_pyramid/JPEGPyramid.cpp b/src/stitch_pyramid/JPEGPyramid.cpp index 5bb9f68d80e..201c5e5963a 100644 --- a/src/stitch_pyramid/JPEGPyramid.cpp +++ b/src/stitch_pyramid/JPEGPyramid.cpp @@ -172,7 +172,7 @@ pady_(0), interval_(0) { if (image.empty() || (padx < 1) || (pady < 1) || (interval < 1)) return; - + // Copmute the number of scales such that the smallest size of the last level is 5 const int numScales = ceil(log(min(image.width(), image.height()) / 40.0) / log(2.0)) * interval; //'max_scale' in voc5 featpyramid.m @@ -180,6 +180,8 @@ pady_(0), interval_(0) if (numScales < interval) return; + imwidth_ = image.width(); + imheight_ = image.height(); padx_ = padx; pady_ = pady; interval_ = interval; diff --git a/src/stitch_pyramid/JPEGPyramid.h b/src/stitch_pyramid/JPEGPyramid.h index 6292f0f2f43..baf9eb3cac8 100644 --- a/src/stitch_pyramid/JPEGPyramid.h +++ b/src/stitch_pyramid/JPEGPyramid.h @@ -93,6 +93,9 @@ class JPEGPyramid //fill an image's padding with linear interpolated data: [from edge of img to imagenet mean] void AvgLerpPad(JPEGImage & image); + int imwidth_; + int imheight_; + private: int padx_; int pady_; diff --git a/src/stitch_pyramid/Patchwork.cpp b/src/stitch_pyramid/Patchwork.cpp index 70c0d5e747d..d80b5aaf918 100644 --- a/src/stitch_pyramid/Patchwork.cpp +++ b/src/stitch_pyramid/Patchwork.cpp @@ -41,6 +41,8 @@ Patchwork::Patchwork() : padx_(0), pady_(0), interval_(0) Patchwork::Patchwork(const JPEGPyramid & pyramid) : padx_(pyramid.padx()), pady_(pyramid.pady()), interval_(pyramid.interval()) { + imwidth_ = pyramid.imwidth_; + imheight_ = pyramid.imheight_; scales_ = pyramid.scales_; //keep track of pyra scales nbScales = pyramid.levels().size(); //Patchwork class variable diff --git a/src/stitch_pyramid/Patchwork.h b/src/stitch_pyramid/Patchwork.h index a31d21dc2d2..7040cc75596 100644 --- a/src/stitch_pyramid/Patchwork.h +++ b/src/stitch_pyramid/Patchwork.h @@ -91,10 +91,13 @@ class Patchwork vector > rectangles_; vector scales_; - static int MaxRows_; //TODO: make these public. + static int MaxRows_; static int MaxCols_; static int HalfCols_; + int imwidth_; + int imheight_; + private: // Bottom-Left fill algorithm static int BLF(vector > & rectangles); From e8fa8490581499031b30c221f45d1b4593f8a80b Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 6 Feb 2014 10:55:19 -0800 Subject: [PATCH 45/92] setting up shared DenseNet_Params class for both the matlab and python APIs to share --- include/caffe/featpyra_common.hpp | 21 +++++++++++++++++++++ matlab/caffe/featpyra_common.hpp | 19 ------------------- matlab/caffe/matcaffe.cpp | 2 +- python/caffe/pycaffe.cpp | 18 +----------------- 4 files changed, 23 insertions(+), 37 deletions(-) create mode 100644 include/caffe/featpyra_common.hpp delete mode 100644 matlab/caffe/featpyra_common.hpp diff --git a/include/caffe/featpyra_common.hpp b/include/caffe/featpyra_common.hpp new file mode 100644 index 00000000000..47ed53ec5e7 --- /dev/null +++ b/include/caffe/featpyra_common.hpp @@ -0,0 +1,21 @@ +#include "caffe/imagenet_mean.hpp" + +//switch RGB to BGR indexing (for Caffe convention) +inline int get_BGR(int channel_RGB) { assert( channel_RGB < 3 ); return 2 - channel_RGB; } + +class DenseNet_Params{ + public: + //TODO: create a constructor or '.setDefaults()' that defines default params + + int interval; // # scales per octave (default = 10) + int imwidth; + int imheight; + int padx; + int pady; + int sbin; //convnet_subsampling_ratio. = 16 for alexnet conv5 features. + + //doesn't include 'scales', because 'scales' may be a different data type for matlab vs python + +}; + +template< typename T > inline std::string str(T const & i) { std::stringstream s; s << i; return s.str(); } // convert T i to string diff --git a/matlab/caffe/featpyra_common.hpp b/matlab/caffe/featpyra_common.hpp deleted file mode 100644 index cabafba4fab..00000000000 --- a/matlab/caffe/featpyra_common.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "caffe/imagenet_mean.hpp" - -//switch RGB to BGR indexing (for Caffe convention) -inline int get_BGR(int channel_RGB) { assert( channel_RGB < 3 ); return 2 - channel_RGB; } - - -// get avg value for imagenet pixels on particular channel -// these are defined in caffe/include/caffe/imagenet_mean.hpp -/* -inline float get_mean_RGB(int channel_RGB){ - if(channel_RGB==0) { return float(IMAGENET_MEAN_R); } - if(channel_RGB==1) { return float(IMAGENET_MEAN_G); } - if(channel_RGB==2) { return float(IMAGENET_MEAN_B); } - else { assert(0); } - return 0; -} -*/ - -template< typename T > inline std::string str(T const & i) { std::stringstream s; s << i; return s.str(); } // convert T i to string diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 2c01a550a9c..18e66290d0b 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -11,7 +11,7 @@ #include "caffe/caffe.hpp" #include "stitch_pyramid/PyramidStitcher.h" //also includes JPEGImage, Patchwork, etc #include "boost/shared_ptr.hpp" -#include "featpyra_common.hpp" +#include "caffe/featpyra_common.hpp" #include #define MEX_ARGS int nlhs, mxArray **plhs, int nrhs, const mxArray **prhs diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index c92cf910510..e7964841b81 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -15,6 +15,7 @@ #include "caffe/caffe.hpp" #include "caffe/imagenet_mean.hpp" #include "stitch_pyramid/PyramidStitcher.h" //also includes JPEGImage, Patchwork, etc +#include "caffe/featpyra_common.hpp" // Temporary solution for numpy < 1.7 versions: old macro, no promises. // You're strongly advised to upgrade to >= 1.7. @@ -231,22 +232,6 @@ struct CaffeNet { return pyramid_float_npy_boost; } - //switch RGB to BGR indexing (for Caffe convention) - int get_BGR(int channel_RGB){ - int channel_BGR; //output - - if(channel_RGB == 0) - channel_BGR = 2; - - if(channel_RGB == 1) - channel_BGR = 1; - - if(channel_RGB == 2) - channel_BGR = 0; - - return channel_BGR; - } - // for now, one batch at a time. (later, can modify this to allocate & fill a >1 batch 4d array) // @param jpeg = typically a plane from Patchwork, in packed JPEG [RGB,RGB,RGB] format // @return numpy float array of jpeg, in unpacked [BBBBB..,GGGGG..,RRRRR..] format with channel mean subtracted @@ -263,7 +248,6 @@ struct CaffeNet { //copy jpeg into jpeg_float_npy for(int ch_src=0; ch_src Date: Thu, 6 Feb 2014 11:59:42 -0800 Subject: [PATCH 46/92] factoring shared matlab+python code up to featpyra_common.cpp --- include/caffe/featpyra_common.hpp | 33 +++++++++++++++++++++++++++++++ matlab/caffe/matcaffe.cpp | 12 ++++++----- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/include/caffe/featpyra_common.hpp b/include/caffe/featpyra_common.hpp index 47ed53ec5e7..b0af0289bf1 100644 --- a/include/caffe/featpyra_common.hpp +++ b/include/caffe/featpyra_common.hpp @@ -1,4 +1,10 @@ #include "caffe/imagenet_mean.hpp" +#include "boost/shared_ptr.hpp" +#include "caffe/caffe.hpp" +#include +using namespace std; +using boost::shared_ptr; +using namespace caffe; //switch RGB to BGR indexing (for Caffe convention) inline int get_BGR(int channel_RGB) { assert( channel_RGB < 3 ); return 2 - channel_RGB; } @@ -18,4 +24,31 @@ class DenseNet_Params{ }; +typedef vector< float > vect_float; +typedef shared_ptr< vect_float > p_vect_float; +typedef vector< p_vect_float > vect_p_vect_float; + +static void raw_do_forward( shared_ptr > net_, vect_p_vect_float const & bottom ) { + vector*>& input_blobs = net_->input_blobs(); + CHECK_EQ(bottom.size(), input_blobs.size()); + for (unsigned int i = 0; i < input_blobs.size(); ++i) { + assert( bottom[i]->size() == uint32_t(input_blobs[i]->count()) ); + const float* const data_ptr = &bottom[i]->front(); + switch (Caffe::mode()) { + case Caffe::CPU: + memcpy(input_blobs[i]->mutable_cpu_data(), data_ptr, + sizeof(float) * input_blobs[i]->count()); + break; + case Caffe::GPU: + cudaMemcpy(input_blobs[i]->mutable_gpu_data(), data_ptr, + sizeof(float) * input_blobs[i]->count(), cudaMemcpyHostToDevice); + break; + default: + LOG(FATAL) << "Unknown Caffe mode."; + } // switch (Caffe::mode()) + } + //const vector*>& output_blobs = net_->ForwardPrefilled(); + net_->ForwardPrefilled(); +} + template< typename T > inline std::string str(T const & i) { std::stringstream s; s << i; return s.str(); } // convert T i to string diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 18e66290d0b..261599159ff 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -99,9 +99,9 @@ T sz_from_dims( uint32_t const num_dims, T const * const dims ) { } typedef vector< mxArray * > vect_rp_mxArray; -typedef vector< float > vect_float; -typedef shared_ptr< vect_float > p_vect_float; -typedef vector< p_vect_float > vect_p_vect_float; +//typedef vector< float > vect_float; // now defined in featpyra_common.hpp +//typedef shared_ptr< vect_float > p_vect_float; +//typedef vector< p_vect_float > vect_p_vect_float; p_vect_float make_p_vect_float( size_t const num ) { p_vect_float ret( new vect_float ); @@ -109,7 +109,7 @@ p_vect_float make_p_vect_float( size_t const num ) { return ret; }; - +/* static void raw_do_forward( vect_p_vect_float const & bottom ) { vector*>& input_blobs = net_->input_blobs(); CHECK_EQ(bottom.size(), input_blobs.size()); @@ -132,6 +132,7 @@ static void raw_do_forward( vect_p_vect_float const & bottom ) { //const vector*>& output_blobs = net_->ForwardPrefilled(); net_->ForwardPrefilled(); } +*/ static p_vect_float copy_output_blob_data( uint32_t const output_blob_ix ) { @@ -372,7 +373,8 @@ static void convnet_featpyramid(MEX_ARGS) { for(int planeID=0; planeID Date: Thu, 6 Feb 2014 15:04:49 -0800 Subject: [PATCH 47/92] convnet_featpyramid matlab function takes parameters as second arg --- include/caffe/featpyra_common.hpp | 103 +++++++++++++---------- include/caffe/imagenet_mean.hpp | 4 +- matlab/caffe/featpyramid_matcaffe_demo.m | 7 +- matlab/caffe/matcaffe.cpp | 39 +++++++-- src/stitch_pyramid/Patchwork.cpp | 2 +- 5 files changed, 99 insertions(+), 56 deletions(-) diff --git a/include/caffe/featpyra_common.hpp b/include/caffe/featpyra_common.hpp index b0af0289bf1..12d5cd8d873 100644 --- a/include/caffe/featpyra_common.hpp +++ b/include/caffe/featpyra_common.hpp @@ -2,53 +2,64 @@ #include "boost/shared_ptr.hpp" #include "caffe/caffe.hpp" #include -using namespace std; -using boost::shared_ptr; -using namespace caffe; + +namespace caffe { + + using namespace std; + using boost::shared_ptr; //switch RGB to BGR indexing (for Caffe convention) -inline int get_BGR(int channel_RGB) { assert( channel_RGB < 3 ); return 2 - channel_RGB; } - -class DenseNet_Params{ - public: - //TODO: create a constructor or '.setDefaults()' that defines default params - - int interval; // # scales per octave (default = 10) - int imwidth; - int imheight; - int padx; - int pady; - int sbin; //convnet_subsampling_ratio. = 16 for alexnet conv5 features. - - //doesn't include 'scales', because 'scales' may be a different data type for matlab vs python - -}; - -typedef vector< float > vect_float; -typedef shared_ptr< vect_float > p_vect_float; -typedef vector< p_vect_float > vect_p_vect_float; - -static void raw_do_forward( shared_ptr > net_, vect_p_vect_float const & bottom ) { - vector*>& input_blobs = net_->input_blobs(); - CHECK_EQ(bottom.size(), input_blobs.size()); - for (unsigned int i = 0; i < input_blobs.size(); ++i) { - assert( bottom[i]->size() == uint32_t(input_blobs[i]->count()) ); - const float* const data_ptr = &bottom[i]->front(); - switch (Caffe::mode()) { - case Caffe::CPU: - memcpy(input_blobs[i]->mutable_cpu_data(), data_ptr, - sizeof(float) * input_blobs[i]->count()); - break; - case Caffe::GPU: - cudaMemcpy(input_blobs[i]->mutable_gpu_data(), data_ptr, - sizeof(float) * input_blobs[i]->count(), cudaMemcpyHostToDevice); - break; - default: - LOG(FATAL) << "Unknown Caffe mode."; - } // switch (Caffe::mode()) + inline int get_BGR(int channel_RGB) { assert( channel_RGB < 3 ); return 2 - channel_RGB; } + + struct densenet_params_t { + uint32_t interval; // # scales per octave + uint32_t img_padding; // in image pixels (at scale=1.0). could later allow per-dim img_padx/img_pady as alternative. + densenet_params_t( void ) { // default values + interval = 10; + img_padding = 16; + } + }; + + typedef vector< float > vect_float; + typedef shared_ptr< vect_float > p_vect_float; + typedef vector< p_vect_float > vect_p_vect_float; + + typedef vector< uint32_t > vect_uint32_t; + typedef shared_ptr< vect_uint32_t > p_vect_uint32_t; + + // a sketch of a possible shared output type for python/matlab interfaces. missing dims for feats. + struct densenet_output_t { + p_vect_float imwidth; // not including padding + p_vect_float imheight; + p_vect_uint32_t feat_padx; + p_vect_uint32_t feat_pady; + p_vect_float scales; + vect_p_vect_float feats; + uint32_t nb_planes; + }; + + static void raw_do_forward( shared_ptr > net_, vect_p_vect_float const & bottom ) { + vector*>& input_blobs = net_->input_blobs(); + CHECK_EQ(bottom.size(), input_blobs.size()); + for (unsigned int i = 0; i < input_blobs.size(); ++i) { + assert( bottom[i]->size() == uint32_t(input_blobs[i]->count()) ); + const float* const data_ptr = &bottom[i]->front(); + switch (Caffe::mode()) { + case Caffe::CPU: + memcpy(input_blobs[i]->mutable_cpu_data(), data_ptr, + sizeof(float) * input_blobs[i]->count()); + break; + case Caffe::GPU: + cudaMemcpy(input_blobs[i]->mutable_gpu_data(), data_ptr, + sizeof(float) * input_blobs[i]->count(), cudaMemcpyHostToDevice); + break; + default: + LOG(FATAL) << "Unknown Caffe mode."; + } // switch (Caffe::mode()) + } + //const vector*>& output_blobs = net_->ForwardPrefilled(); + net_->ForwardPrefilled(); } - //const vector*>& output_blobs = net_->ForwardPrefilled(); - net_->ForwardPrefilled(); -} -template< typename T > inline std::string str(T const & i) { std::stringstream s; s << i; return s.str(); } // convert T i to string + template< typename T > inline std::string str(T const & i) { std::stringstream s; s << i; return s.str(); } // convert T i to string +} diff --git a/include/caffe/imagenet_mean.hpp b/include/caffe/imagenet_mean.hpp index 8f329bd0ddc..254e371ea30 100644 --- a/include/caffe/imagenet_mean.hpp +++ b/include/caffe/imagenet_mean.hpp @@ -12,7 +12,7 @@ #define IMAGENET_MEAN_G 116.66f #define IMAGENET_MEAN_B 104.00f -static float IMAGENET_MEAN_RGB[3] = {IMAGENET_MEAN_R, IMAGENET_MEAN_G, IMAGENET_MEAN_B}; -static float IMAGENET_MEAN_BGR[3] = {IMAGENET_MEAN_B, IMAGENET_MEAN_G, IMAGENET_MEAN_R}; +static float const IMAGENET_MEAN_RGB[3] = {IMAGENET_MEAN_R, IMAGENET_MEAN_G, IMAGENET_MEAN_B}; +static float const IMAGENET_MEAN_BGR[3] = {IMAGENET_MEAN_B, IMAGENET_MEAN_G, IMAGENET_MEAN_R}; #endif diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index b8f0b7c3855..1c66ee5bdcf 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -43,7 +43,12 @@ % put into test mode caffe('set_phase_test'); - pyra = caffe('convnet_featpyramid', imfn ); + % optionally, pass parmeters as second argument to convnet_featpyramid (set here to the defaults) + pyra_params.interval = 10; + pyra_params.img_padding = 16; + + pyra = caffe('convnet_featpyramid', imfn, pyra_params ); % call with parameters ... + % pyra = caffe('convnet_featpyramid', imfn ); % ... or with no parameters %visualize one scale: colormap(gray) diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 261599159ff..3f21d42dc29 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -195,7 +195,6 @@ static void init(MEX_ARGS) { LOG(ERROR) << "Only given " << nrhs << " arguments"; mexErrMsgTxt("Wrong number of arguments"); } - char* param_file = mxArrayToString(prhs[0]); char* model_file = mxArrayToString(prhs[1]); @@ -339,12 +338,19 @@ static void unstitch_planes(vect_rp_mxArray & out, vector const & } out.push_back(ret); } +} + +static uint32_t mx_to_u32( string const & err_str, mxArray const * const mxa ) { + if( !mxIsNumeric( mxa ) ) { mexErrMsgTxt( (err_str + ": expected a numeric value, got something else. ").c_str()); } + uint32_t const sz = mxGetNumberOfElements( mxa ); + if( sz != 1 ) { mexErrMsgTxt( (err_str+": expected a single element, but got " + str(sz) + ".").c_str()); } + return uint32_t(mxGetScalar(mxa)); } static void convnet_featpyramid(MEX_ARGS) { - if (nrhs != 1) { - LOG(ERROR) << "Given " << nrhs << " arguments, expected 1."; + if ( (nrhs < 1) || (nrhs > 2) ) { + LOG(ERROR) << "Given " << nrhs << " arguments, expected 1 or 2."; mexErrMsgTxt("Wrong number of arguments"); } if (nlhs != 1) { @@ -352,11 +358,32 @@ static void convnet_featpyramid(MEX_ARGS) { mexErrMsgTxt("Wrong number of outputs"); } char *fn_cs = mxArrayToString(prhs[0]); + if( !fn_cs ) { mexErrMsgTxt("Could not convert first argument to a string."); } string const file( fn_cs ); mxFree(fn_cs); - int padding = 16; - int interval = 10; + densenet_params_t params; // ctor sets params to defaults + + if( nrhs > 1 ) { // (try to) parse second arg as params + mxArray const * const mx_params = prhs[1]; + if( !mxIsStruct( mx_params ) ) { + mexErrMsgTxt("Expected second argument to be a struct, but it was not."); } + uint32_t const npes = mxGetNumberOfElements( mx_params ); + if( npes != 1 ) { + mexErrMsgTxt(("Expected second argument to be a struct with one element, but it had " + str(npes) + ".").c_str()); } + uint32_t const nf = mxGetNumberOfFields( mx_params ); + for( uint32_t fi = 0; fi != nf; ++fi ) { + char const * const fn = mxGetFieldNameByNumber( mx_params, fi ); + assert( fn ); + mxArray const * const mx_f = mxGetFieldByNumber( mx_params, 0, fi ); + assert( mx_f ); + if( 0 ) { } + else if( !strcmp( fn, "interval" ) ) { params.interval = mx_to_u32( "for param interval", mx_f ); } + else if( !strcmp( fn, "img_padding" ) ) { params.img_padding = mx_to_u32( "for param img_padding", mx_f ); } + else { mexErrMsgTxt( ("unknown parameter " + string(fn) ).c_str() ); } + } + } + int convnet_subsampling_ratio = 16; //for conv5 layer features int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size int resultDepth = net_->output_blobs()[0]->channels(); @@ -365,7 +392,7 @@ static void convnet_featpyramid(MEX_ARGS) { assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) //TODO: verify/assert that top-upsampled version of input img fits within planeDim - Patchwork patchwork = stitch_pyramid(file, padding, interval, planeDim); + Patchwork patchwork = stitch_pyramid(file, params.img_padding, params.interval, planeDim); int nbPlanes = patchwork.planes_.size(); vect_p_vect_float blobs_top; diff --git a/src/stitch_pyramid/Patchwork.cpp b/src/stitch_pyramid/Patchwork.cpp index d80b5aaf918..2fa05cd10f2 100644 --- a/src/stitch_pyramid/Patchwork.cpp +++ b/src/stitch_pyramid/Patchwork.cpp @@ -58,7 +58,7 @@ interval_(pyramid.interval()) // Build the patchwork planes const int nbPlanes = BLF(rectangles_); - cout << " nbPlanes = " << nbPlanes << endl; + //cout << " nbPlanes = " << nbPlanes << endl; // Constructs an empty patchwork in case of error if (nbPlanes <= 0) From cfb7491914b0f0f8317ccf99e43aae2dc77507eb Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 6 Feb 2014 15:28:32 -0800 Subject: [PATCH 48/92] changes to convnet_featpyramid matlab interface return value is now a scalar structure array with fields 'feat' (a cell array of 3D numeric arrays) and 'scales' (a 1D numeric array). --- matlab/caffe/featpyramid_matcaffe_demo.m | 5 +-- matlab/caffe/matcaffe.cpp | 41 +++++++++++------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index 1c66ee5bdcf..cfe7062f3b7 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -50,7 +50,8 @@ pyra = caffe('convnet_featpyramid', imfn, pyra_params ); % call with parameters ... % pyra = caffe('convnet_featpyramid', imfn ); % ... or with no parameters + %keyboard %visualize one scale: - colormap(gray) - imagesc(squeeze(sum(pyra(1).feats, 1))) + colormap(gray); + imagesc(squeeze(sum(pyra.feat{1}, 1))); diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 3f21d42dc29..c1f0346c994 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -215,7 +215,7 @@ static void forward(MEX_ARGS) { } -char const * fnames[] = { "scale", "feats" }; +char const * fnames[] = { "scale", "feat" }; static void test_io(MEX_ARGS) { if (nrhs != 0) { LOG(ERROR) << "Given " << nrhs << " arguments, expected 0."; @@ -299,12 +299,12 @@ p_vect_float JPEGImage_to_p_float( JPEGImage &jpeg ){ // @param descriptor_planes -- each element of the list is a plane of Caffe descriptors // typically, descriptor_planes = blobs_top. // @param depth = #channels (typically 256 for conv5) -static void unstitch_planes(vect_rp_mxArray & out, vector const & scaleLocs, vect_p_vect_float const & descriptor_planes, int depth) { - assert( out.empty() ); +static mxArray * unstitch_planes( vector const & scaleLocs, vect_p_vect_float const & descriptor_planes, int depth) { + uint32_t const nbScales = scaleLocs.size(); + mxArray * const ret = mxCreateCellMatrix( nbScales, 1 ); + assert( ret ); - int nbScales = scaleLocs.size(); - - for(int i=0; ioutput_blobs()[0]->channels(); uint32_t width = net_->output_blobs()[0]->width(); @@ -320,8 +320,8 @@ static void unstitch_planes(vect_rp_mxArray & out, vector const & // dims[3] = {depth, height, width}; mwSize ret_dims[3] = {depth, scaleLocs[i].height, scaleLocs[i].width }; // desired column-major / F / matlab dims - mxArray * const ret = mxCreateNumericArray( 3, ret_dims, mxSINGLE_CLASS, mxREAL ); - float * const ret_data = (float * )mxGetData( ret ); + mxArray * const ret_scale = mxCreateNumericArray( 3, ret_dims, mxSINGLE_CLASS, mxREAL ); + float * const ret_scale_data = (float * )mxGetData( ret_scale ); mwSize ret_sz = sz_from_dims( 3, ret_dims ); for( uint32_t x = 0; x < uint32_t(ret_dims[2]); ++x ) { for( uint32_t y = 0; y < uint32_t(ret_dims[1]); ++y ) { @@ -331,13 +331,14 @@ static void unstitch_planes(vect_rp_mxArray & out, vector const & uint32_t const dp_x = x + scaleLocs[i].xMin; uint32_t const dp_y = y + scaleLocs[i].yMin; uint32_t const dp_ix = dp_x + dp_y*dp_dims[0] + d*dp_dims[0]*dp_dims[1]; - //ret_data[rix] = float(d) + 1000.0*y + 1000000.0*x; - ret_data[rix] = dp->at(dp_ix); + //ret_scale_data[rix] = float(d) + 1000.0*y + 1000000.0*x; + ret_scale_data[rix] = dp->at(dp_ix); } } } - out.push_back(ret); + mxSetCell( ret, i, ret_scale ); } + return ret; } @@ -409,18 +410,14 @@ static void convnet_featpyramid(MEX_ARGS) { uint32_t const ret_rows = patchwork.scales_.size(); assert( scaleLocations.size() == ret_rows ); - vect_rp_mxArray feats; - unstitch_planes( feats, scaleLocations, blobs_top, resultDepth ); - assert( feats.size() == ret_rows ); + mxArray * const feats = unstitch_planes( scaleLocations, blobs_top, resultDepth ); + mxArray * const scale = mxCreateNumericMatrix( ret_rows, 1, mxSINGLE_CLASS, mxREAL ); + float * const scale_ptr = (float*)(mxGetData(scale)); + for( uint32_t r = 0; r < ret_rows; ++r ) { scale_ptr[r] = patchwork.scales_[r]; } - mxArray * ret = mxCreateStructMatrix( ret_rows, 1, 2, fnames ); - for( uint32_t r = 0; r < ret_rows; ++r ) { - mxArray * const scale = mxCreateNumericMatrix( 1, 1, mxSINGLE_CLASS, mxREAL ); - float * const scale_ptr = (float*)(mxGetData(scale)); - *scale_ptr = patchwork.scales_[r]; - mxSetFieldByNumber( ret, r, 0, scale ); - mxSetFieldByNumber( ret, r, 1, feats[r] ); - } + mxArray * ret = mxCreateStructMatrix( 1, 1, 2, fnames ); + mxSetFieldByNumber( ret, 0, 0, scale ); + mxSetFieldByNumber( ret, 0, 1, feats ); plhs[0] = ret; } From aaa149aa6039c57bd055856bce46ab244d24c589 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 6 Feb 2014 15:35:56 -0800 Subject: [PATCH 49/92] remove test_io function from matcaffe --- matlab/caffe/matcaffe.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index c1f0346c994..58e93974980 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -216,27 +216,6 @@ static void forward(MEX_ARGS) { char const * fnames[] = { "scale", "feat" }; -static void test_io(MEX_ARGS) { - if (nrhs != 0) { - LOG(ERROR) << "Given " << nrhs << " arguments, expected 0."; - mexErrMsgTxt("Wrong number of arguments"); - } - if (nlhs != 1) { - LOG(ERROR) << "Caller wanted " << nlhs << " outputs, but this function always produces 1."; - mexErrMsgTxt("Wrong number of outputs"); - } - uint32_t const ret_rows = 5; - mxArray * ret = mxCreateStructMatrix( ret_rows, 1, 2, fnames ); - for( uint32_t r = 0; r < ret_rows; ++r ) { - mxArray * const scale = mxCreateNumericMatrix( 1, 1, mxSINGLE_CLASS, mxREAL ); - float * const scale_ptr = (float*)(mxGetData(scale)); - *scale_ptr = 0.5f + float(r); - mxSetFieldByNumber( ret, r, 0, scale ); - mxArray * const feats = mxCreateNumericMatrix( 3, 3, mxSINGLE_CLASS, mxREAL ); - mxSetFieldByNumber( ret, r, 1, feats ); - } - plhs[0] = ret; -} void check_dims_equal( uint32_t const num_dims, uint32_t const * const dims_a, uint32_t const * const dims_b ) { bool dims_eq = 1; @@ -441,7 +420,6 @@ static handler_registry handlers[] = { { "set_phase_test", set_phase_test }, { "set_device", set_device }, // featpyramid functions - { "test_io", test_io }, { "convnet_featpyramid",convnet_featpyramid }, // The end. From 15aa69ab07f482d51581334a79bb803e12afde1d Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 6 Feb 2014 15:43:13 -0800 Subject: [PATCH 50/92] convnet_featpyramid matlab iface: add imwidth and imheight to output --- matlab/caffe/matcaffe.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 58e93974980..f5afd18d26f 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -215,7 +215,7 @@ static void forward(MEX_ARGS) { } -char const * fnames[] = { "scale", "feat" }; +char const * fnames[] = { "scales", "feat", "imwidth", "imheight" }; void check_dims_equal( uint32_t const num_dims, uint32_t const * const dims_a, uint32_t const * const dims_b ) { bool dims_eq = 1; @@ -394,10 +394,17 @@ static void convnet_featpyramid(MEX_ARGS) { float * const scale_ptr = (float*)(mxGetData(scale)); for( uint32_t r = 0; r < ret_rows; ++r ) { scale_ptr[r] = patchwork.scales_[r]; } - mxArray * ret = mxCreateStructMatrix( 1, 1, 2, fnames ); + mxArray * ret = mxCreateStructMatrix( 1, 1, 4, fnames ); mxSetFieldByNumber( ret, 0, 0, scale ); mxSetFieldByNumber( ret, 0, 1, feats ); + mxArray * const imwidth = mxCreateNumericMatrix( 1, 1, mxSINGLE_CLASS, mxREAL ); + *(float*)(mxGetData(imwidth)) = (float)patchwork.imwidth_; + mxArray * const imheight = mxCreateNumericMatrix( 1, 1, mxSINGLE_CLASS, mxREAL ); + *(float*)(mxGetData(imheight)) = (float)patchwork.imheight_; + mxSetFieldByNumber( ret, 0, 2, imwidth ); + mxSetFieldByNumber( ret, 0, 3, imheight ); + plhs[0] = ret; } From 764348114e24f59ef83fd64b643670eb5e336f1c Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 6 Feb 2014 16:18:15 -0800 Subject: [PATCH 51/92] convnet_featpyramid matlab iface: add placeholder feat_padx and feat_pady fields to output (always set = 1) --- matlab/caffe/matcaffe.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index f5afd18d26f..0b3457806cc 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -215,8 +215,6 @@ static void forward(MEX_ARGS) { } -char const * fnames[] = { "scales", "feat", "imwidth", "imheight" }; - void check_dims_equal( uint32_t const num_dims, uint32_t const * const dims_a, uint32_t const * const dims_b ) { bool dims_eq = 1; for( uint32_t dim = 0; dim < num_dims; ++dim ) { if( dims_a[dim] != dims_b[dim] ) { dims_eq = 0; } } @@ -328,6 +326,14 @@ static uint32_t mx_to_u32( string const & err_str, mxArray const * const mxa ) { return uint32_t(mxGetScalar(mxa)); } +static mxArray * u32_to_mx( uint32_t const val ) { // returned as float (i.e. scalar single) + mxArray * const mxa = mxCreateNumericMatrix( 1, 1, mxSINGLE_CLASS, mxREAL ); + *(float*)(mxGetData(mxa)) = (float)val; + return mxa; +} + +char const * fnames[] = { "scales", "feat", "imwidth", "imheight", "feat_padx", "feat_pady" }; + static void convnet_featpyramid(MEX_ARGS) { if ( (nrhs < 1) || (nrhs > 2) ) { LOG(ERROR) << "Given " << nrhs << " arguments, expected 1 or 2."; @@ -394,16 +400,13 @@ static void convnet_featpyramid(MEX_ARGS) { float * const scale_ptr = (float*)(mxGetData(scale)); for( uint32_t r = 0; r < ret_rows; ++r ) { scale_ptr[r] = patchwork.scales_[r]; } - mxArray * ret = mxCreateStructMatrix( 1, 1, 4, fnames ); + mxArray * ret = mxCreateStructMatrix( 1, 1, sizeof(fnames)/sizeof(char*), fnames ); // see fnames for field names mxSetFieldByNumber( ret, 0, 0, scale ); mxSetFieldByNumber( ret, 0, 1, feats ); - - mxArray * const imwidth = mxCreateNumericMatrix( 1, 1, mxSINGLE_CLASS, mxREAL ); - *(float*)(mxGetData(imwidth)) = (float)patchwork.imwidth_; - mxArray * const imheight = mxCreateNumericMatrix( 1, 1, mxSINGLE_CLASS, mxREAL ); - *(float*)(mxGetData(imheight)) = (float)patchwork.imheight_; - mxSetFieldByNumber( ret, 0, 2, imwidth ); - mxSetFieldByNumber( ret, 0, 3, imheight ); + mxSetFieldByNumber( ret, 0, 2, u32_to_mx( patchwork.imwidth_ ) ); + mxSetFieldByNumber( ret, 0, 3, u32_to_mx( patchwork.imheight_ ) ); + mxSetFieldByNumber( ret, 0, 4, u32_to_mx( 1 ) ); + mxSetFieldByNumber( ret, 0, 5, u32_to_mx( 1 ) ); plhs[0] = ret; } From 3824282f9b72100ecf843110c31920db8243d5bf Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 6 Feb 2014 16:45:24 -0800 Subject: [PATCH 52/92] convnet_featpyramid matlab/python iface changes -- add sbin to matlab output -- add feat_padx, feat_pady, sbin to python output -- add parameters to python input --- matlab/caffe/matcaffe.cpp | 3 ++- python/caffe/imagenet/featpyramid_tests.py | 18 ++++++++++++---- python/caffe/pycaffe.cpp | 24 +++++++++++++++++----- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 0b3457806cc..dcf86c9caf1 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -332,7 +332,7 @@ static mxArray * u32_to_mx( uint32_t const val ) { // returned as float (i.e. sc return mxa; } -char const * fnames[] = { "scales", "feat", "imwidth", "imheight", "feat_padx", "feat_pady" }; +char const * fnames[] = { "scales", "feat", "imwidth", "imheight", "feat_padx", "feat_pady", "sbin" }; static void convnet_featpyramid(MEX_ARGS) { if ( (nrhs < 1) || (nrhs > 2) ) { @@ -407,6 +407,7 @@ static void convnet_featpyramid(MEX_ARGS) { mxSetFieldByNumber( ret, 0, 3, u32_to_mx( patchwork.imheight_ ) ); mxSetFieldByNumber( ret, 0, 4, u32_to_mx( 1 ) ); mxSetFieldByNumber( ret, 0, 5, u32_to_mx( 1 ) ); + mxSetFieldByNumber( ret, 0, 6, u32_to_mx( convnet_subsampling_ratio ) ); plhs[0] = ret; } diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py index 1adf98e967b..5b865cd7152 100644 --- a/python/caffe/imagenet/featpyramid_tests.py +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -39,8 +39,13 @@ def test_pyramid_IO(caffenet, imgFname): def test_featpyramid_allScales(caffenet, imgFname): + densenet_params = dict() + densenet_params['interval'] = 10 + densenet_params['img_padding'] = 16 + start_time = time.time() - pyra = caffenet.extract_featpyramid(imgFname) # THE CRUX + pyra = caffenet.extract_featpyramid(imgFname, densenet_params) # THE CRUX ... + # pyra = caffenet.extract_featpyramid(imgFname) # ... or THE CRUX without parameters pyra_time = time.time() - start_time print " computed pyra in %f sec" %pyra_time @@ -49,6 +54,11 @@ def test_featpyramid_allScales(caffenet, imgFname): # optional breakpoint... #from IPython import embed #embed() + output_dir = 'output_pyra' + try: + os.makedirs( output_dir ) + except OSError, e: + pass for i in xrange(0, len(feat)): print 'feat[%d] shape: '%i @@ -62,7 +72,7 @@ def test_featpyramid_allScales(caffenet, imgFname): pyplot.figure() pyplot.title('Welcome to deep learning land. You have arrived.') pyplot.imshow(flat_descriptor, cmap = cm.gray, interpolation='nearest') - pylab.savefig('output_pyra/flat_descriptor_scale%d.jpg' %i) + pylab.savefig( output_dir + '/flat_descriptor_scale%d.jpg' % i) print "\n pyra scales:" print pyra["scales"] @@ -73,8 +83,8 @@ def test_featpyramid_allScales(caffenet, imgFname): #pretend that these flags came off the command line: imgFname = './pascal_009959.jpg' #model_def = '../../../examples/imagenet_deploy.prototxt' - model_def = './imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt' - pretrained_model = '../../../alexnet_train_iter_470000' + model_def = './imagenet_rcnn_batch_1_input_1100x1100_output_conv5.prototxt' + pretrained_model = '../../../examples/alexnet_train_iter_470000' use_gpu = True caffenet = caffe.CaffeNet(model_def, pretrained_model) diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index e7964841b81..f8759222ecc 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -29,6 +29,7 @@ using namespace caffe; // NOLINT(build/namespaces) using boost::python::extract; using boost::python::len; using boost::python::list; +using boost::python::dict; using boost::python::object; using boost::python::handle; using boost::python::vector_indexing_suite; @@ -328,10 +329,19 @@ struct CaffeNet { } //void extract_featpyramid(string file){ - boost::python::dict extract_featpyramid(string file){ + boost::python::dict extract_featpyramid(string file, dict params_dict = dict() ){ + + densenet_params_t params; // ctor sets params to defaults + list params_keys = params_dict.keys(); + for( uint32_t i = 0; i < len(params_keys); ++i) { + string const fn = extract(params_keys[i]); + object val = params_dict[params_keys[i]]; + if( 0 ) { } + else if( fn == "interval" ) { params.interval = extract(val); } + else if( fn == "img_padding" ) { params.img_padding = extract(val); } + else { throw runtime_error("unknown parameter " + string(fn) ); } + } - int padding = 16; - int interval = 10; int convnet_subsampling_ratio = 16; //for conv5 layer features int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size int resultDepth = net_->output_blobs()[0]->channels(); @@ -340,7 +350,7 @@ struct CaffeNet { assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) //TODO: verify/assert that top-upsampled version of input img fits within planeDim - Patchwork patchwork = stitch_pyramid(file, padding, interval, planeDim); + Patchwork patchwork = stitch_pyramid(file, params.img_padding, params.interval, planeDim); int nbPlanes = patchwork.planes_.size(); boost::python::list blobs_bottom; //input buffer(s) for Caffe::Forward @@ -378,6 +388,9 @@ struct CaffeNet { d["scales"] = scales_npy_boost; d["imwidth"] = patchwork.imwidth_; //input image dims d["imheight"] = patchwork.imheight_; + d["feat_padx"] = 1u; // placeholder + d["feat_pady"] = 1u; // placeholder + d["sbin"] = convnet_subsampling_ratio; return d; } @@ -527,6 +540,7 @@ struct CaffeNet { shared_ptr > net_; }; +BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(CaffeNet_extract_featpyramid_overloads, CaffeNet::extract_featpyramid, 1, 2); // The boost python module definition. @@ -545,7 +559,7 @@ BOOST_PYTHON_MODULE(pycaffe) { .def("testString", &CaffeNet::testString) .def("test_return_dict", &CaffeNet::test_return_dict) .def("testInt", &CaffeNet::testInt) - .def("extract_featpyramid", &CaffeNet::extract_featpyramid) //NEW + .def("extract_featpyramid", &CaffeNet::extract_featpyramid, CaffeNet_extract_featpyramid_overloads()) //NEW .def("blobs", &CaffeNet::blobs) .def("params", &CaffeNet::params); From 655c534e4c6266569d71ea2c732457a31393ca63 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 6 Feb 2014 17:49:04 -0800 Subject: [PATCH 53/92] adding the ability to ignore big scales if they don't fit in planes --- src/stitch_pyramid/JPEGPyramid.h | 1 - src/stitch_pyramid/Patchwork.cpp | 28 ++++++++++++++++++++-- src/stitch_pyramid/Patchwork.h | 7 ++++-- src/stitch_pyramid/test_stitch_pyramid.cpp | 4 ++-- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/stitch_pyramid/JPEGPyramid.h b/src/stitch_pyramid/JPEGPyramid.h index baf9eb3cac8..ca79c527a5b 100644 --- a/src/stitch_pyramid/JPEGPyramid.h +++ b/src/stitch_pyramid/JPEGPyramid.h @@ -96,7 +96,6 @@ class JPEGPyramid int imwidth_; int imheight_; -private: int padx_; int pady_; int interval_; diff --git a/src/stitch_pyramid/Patchwork.cpp b/src/stitch_pyramid/Patchwork.cpp index 2fa05cd10f2..714ac041cbe 100644 --- a/src/stitch_pyramid/Patchwork.cpp +++ b/src/stitch_pyramid/Patchwork.cpp @@ -38,16 +38,17 @@ Patchwork::Patchwork() : padx_(0), pady_(0), interval_(0) { } -Patchwork::Patchwork(const JPEGPyramid & pyramid) : padx_(pyramid.padx()), pady_(pyramid.pady()), +Patchwork::Patchwork(JPEGPyramid & pyramid) : padx_(pyramid.padx()), pady_(pyramid.pady()), interval_(pyramid.interval()) { imwidth_ = pyramid.imwidth_; imheight_ = pyramid.imheight_; scales_ = pyramid.scales_; //keep track of pyra scales - nbScales = pyramid.levels().size(); //Patchwork class variable //cout << " nbScales = " << nbScales << endl; //printf(" MaxRows_ = %d, MaxCols_=%d \n", MaxRows_, MaxCols_); + + prune_big_scales(pyramid); //remove scales that won't fit in (MaxRows, MaxCols) rectangles_.resize(nbScales); @@ -107,6 +108,29 @@ interval_(pyramid.interval()) } } +//remove scales that are bigger than one Patchwork plane +void Patchwork::prune_big_scales(JPEGPyramid & pyramid){ + + int first_valid_scale_idx = 0; + + for(int i=0; i < pyramid.levels_.size(); i++){ + if( (pyramid.levels_[i].width() > MaxCols_) || (pyramid.levels_[i].height() > MaxRows_) ) + { + first_valid_scale_idx = i; + + } + printf("MaxCols_=%d, MaxRows_=%d, pyramid.levels__[%d].width()=%d, pyramid.levels__[%d].height()=%d \n", MaxCols_, MaxRows_, i, pyramid.levels_[i].width(), i, pyramid.levels_[i].height()); + + } + + if(first_valid_scale_idx > 0){ + scales_.erase( scales_.begin(), scales_.begin() + first_valid_scale_idx); + pyramid.levels_.erase( pyramid.levels_.begin(), pyramid.levels_.begin() + first_valid_scale_idx); + nbScales = nbScales - first_valid_scale_idx; + printf("had to remove first %d scales, because they didn't fit in Patchwork plane \n", first_valid_scale_idx); + } +} + int Patchwork::padx() const { return padx_; diff --git a/src/stitch_pyramid/Patchwork.h b/src/stitch_pyramid/Patchwork.h index 7040cc75596..edf4dbf7816 100644 --- a/src/stitch_pyramid/Patchwork.h +++ b/src/stitch_pyramid/Patchwork.h @@ -49,8 +49,11 @@ class Patchwork /// the Patchwork will be empty. /// @note Assumes that the features of the pyramid levels are zero in the padded regions but for /// the last feature, which is assumed to be one. - Patchwork(const JPEGPyramid & pyramid); - + Patchwork(JPEGPyramid & pyramid); + + //remove scales that don't fit in planes + void prune_big_scales(JPEGPyramid & pyramid); + /// Returns the amount of horizontal zero padding (in cells). int padx() const; diff --git a/src/stitch_pyramid/test_stitch_pyramid.cpp b/src/stitch_pyramid/test_stitch_pyramid.cpp index 56ac08ab237..9a7d867979e 100644 --- a/src/stitch_pyramid/test_stitch_pyramid.cpp +++ b/src/stitch_pyramid/test_stitch_pyramid.cpp @@ -162,8 +162,8 @@ int main(int argc, char * argv[]){ writePyraToJPG(pyramid); #endif - //Patchwork patchwork = stitch_pyramid(file, padding, interval, 2000); - Patchwork patchwork = stitch_pyramid(file, padding, interval, -1); //planeDim = -1 (use defaults) + Patchwork patchwork = stitch_pyramid(file, padding, interval, 500); + //Patchwork patchwork = stitch_pyramid(file, padding, interval, -1); //planeDim = -1 (use defaults) //printScaleSizes(pyramid); writePatchworkToJPG(patchwork, output_stitched_dir, base_filename); //outputs to output_stitched_dir/base_filename_[planeID].jpg From ef6fa03b9c7b0481ed3ca65d7a840e7b511fef80 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 6 Feb 2014 19:32:55 -0800 Subject: [PATCH 54/92] solving problem of 'some pyra scales are too big for planes.' pruning scales that are too big. added some additional error checking too. --- Makefile | 5 ++-- matlab/caffe/get_featureSlice.m | 6 ++-- matlab/caffe/matcaffe.cpp | 33 ++++++++++++---------- python/caffe/imagenet/featpyramid_tests.py | 5 ++-- python/caffe/pycaffe.cpp | 10 ++++++- src/stitch_pyramid/Patchwork.cpp | 22 +++++++-------- 6 files changed, 46 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index a0b062ac9aa..effeff1495d 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,8 @@ LIBRARIES := cudart cublas curand \ PYTHON_LIBRARIES := boost_python python2.7 WARNINGS := -Wall -COMMON_FLAGS := -DNDEBUG -O2 $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) +COMMON_FLAGS := -O2 -UNDEBUG $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) +#COMMON_FLAGS := -DNDEBUG -O2 $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) NVCCFLAGS := -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS) LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) \ @@ -164,7 +165,7 @@ py: init $(STATIC_NAME) $(PY$(PROJECT)_SRC) $(PROTO_GEN_PY) $(STITCHPYRAMID_SO) mat$(PROJECT): mat mat: init $(STATIC_NAME) $(MAT$(PROJECT)_SRC) - $(MATLAB_DIR)/bin/mex $(MAT$(PROJECT)_SRC) $(STATIC_NAME) \ + $(MATLAB_DIR)/bin/mex -g $(MAT$(PROJECT)_SRC) $(STATIC_NAME) \ CXXFLAGS="\$$CXXFLAGS $(CXXFLAGS) $(WARNINGS)" -I./python/caffe \ CXXLIBS="\$$CXXLIBS $(LDFLAGS)" -L./src/stitch_pyramid -lPyramidStitcher \ -o $(MAT$(PROJECT)_SO) diff --git a/matlab/caffe/get_featureSlice.m b/matlab/caffe/get_featureSlice.m index 145c61646cc..7415c99aab2 100644 --- a/matlab/caffe/get_featureSlice.m +++ b/matlab/caffe/get_featureSlice.m @@ -22,15 +22,13 @@ scale_to_use = mean(bbox_desc_scale); %avg of scale factors for x and y dims. [scale_to_use, scaleIdx] = findNearestScale(scale_to_use, pyra.scales); %best precomputed approx of scale_to_use - %padx_desc_scaled = (pyra.padx / pyra.sbin) * scale_to_use; %in descriptor coords, at scale_to_use. - %pady_desc_scaled = (pyra.pady / pyra.sbin) * scale_to_use; - padx_desc_scaled = pyra.padx; %AHA, this is really in HOG cells and not image pixels. + padx_desc_scaled = pyra.padx; %this is in descriptor cells and not image pixels. pady_desc_scaled = pyra.pady; %3. rip out a slice from the appropriate scale - %TODO: center it on (bbox_desc.x2 - bbox_desc.x1), (bbox_desc.y2 - bbox_desc.y1) + % center bbox_to_use on (bbox_desc.x2 - bbox_desc.x1), (bbox_desc.y2 - bbox_desc.y1) bbox_desc_x_center = bbox_desc.x1 + (bbox_desc.x2 - bbox_desc.x1)/2.0; bbox_desc_y_center = bbox_desc.y1 + (bbox_desc.y2 - bbox_desc.y1)/2.0; diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index dcf86c9caf1..80bf3c262b1 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -261,11 +261,12 @@ p_vect_float JPEGImage_to_p_float( JPEGImage &jpeg ){ float const ch_mean = IMAGENET_MEAN_RGB[ch_src]; for(int y=0; yat(rix) = jpeg.bits()[y*width*depth + x*depth + ch_src] - ch_mean; - } + //jpeg: row-major, packed RGB, RGB, ... uint8_t. + //rp_float: row-major, unpacked BBBB..,GGGG..,RRRR.. float. + uint32_t const rix = ch_dst*height*width+y*width+x; + assert(rix < ret->size()); + ret->at(rix) = jpeg.bits()[y*width*depth + x*depth + ch_src] - ch_mean; + } } } return ret; @@ -302,15 +303,16 @@ static mxArray * unstitch_planes( vector const & scaleLocs, vect_ mwSize ret_sz = sz_from_dims( 3, ret_dims ); for( uint32_t x = 0; x < uint32_t(ret_dims[2]); ++x ) { for( uint32_t y = 0; y < uint32_t(ret_dims[1]); ++y ) { - for( uint32_t d = 0; d < uint32_t(ret_dims[0]); ++d ) { - uint32_t const rix = d + y*ret_dims[0] + x*ret_dims[0]*ret_dims[1]; - assert( rix < uint32_t(ret_sz) ); - uint32_t const dp_x = x + scaleLocs[i].xMin; - uint32_t const dp_y = y + scaleLocs[i].yMin; - uint32_t const dp_ix = dp_x + dp_y*dp_dims[0] + d*dp_dims[0]*dp_dims[1]; - //ret_scale_data[rix] = float(d) + 1000.0*y + 1000000.0*x; - ret_scale_data[rix] = dp->at(dp_ix); - } + for( uint32_t d = 0; d < uint32_t(ret_dims[0]); ++d ) { + uint32_t const rix = d + y*ret_dims[0] + x*ret_dims[0]*ret_dims[1]; + assert( rix < uint32_t(ret_sz) ); + uint32_t const dp_x = x + scaleLocs[i].xMin; + uint32_t const dp_y = y + scaleLocs[i].yMin; + uint32_t const dp_ix = dp_x + dp_y*dp_dims[0] + d*dp_dims[0]*dp_dims[1]; + //ret_scale_data[rix] = float(d) + 1000.0*y + 1000000.0*x; + assert(dp_ix < dp->size()); + ret_scale_data[rix] = dp->at(dp_ix); + } } } mxSetCell( ret, i, ret_scale ); @@ -384,7 +386,8 @@ static void convnet_featpyramid(MEX_ARGS) { vect_p_vect_float blobs_top; //prep input data for Caffe feature extraction for(int planeID=0; planeID((PyObject*)view_npy)); unstitched_features.append(view_npy_boost); } +printf("success in unstitch_planes \n"); return unstitched_features; } diff --git a/src/stitch_pyramid/Patchwork.cpp b/src/stitch_pyramid/Patchwork.cpp index 714ac041cbe..b7f6bc016e5 100644 --- a/src/stitch_pyramid/Patchwork.cpp +++ b/src/stitch_pyramid/Patchwork.cpp @@ -26,6 +26,7 @@ #include #include #include +#include using namespace FFLD; using namespace std; @@ -45,12 +46,15 @@ interval_(pyramid.interval()) imheight_ = pyramid.imheight_; scales_ = pyramid.scales_; //keep track of pyra scales nbScales = pyramid.levels().size(); //Patchwork class variable - //cout << " nbScales = " << nbScales << endl; //printf(" MaxRows_ = %d, MaxCols_=%d \n", MaxRows_, MaxCols_); + //printf(" before prune_big_scales(). scales_.size()=%ld, pyramid.levels_.size()=%ld \n", scales_.size(), pyramid.levels_.size()); + prune_big_scales(pyramid); //remove scales that won't fit in (MaxRows, MaxCols) - + + cout << " nbScales = " << nbScales << endl; rectangles_.resize(nbScales); + //printf(" after prune_big_scales(). scales_.size()=%ld, pyramid.levels_.size()=%ld \n", scales_.size(), pyramid.levels_.size()); for (int i = 0; i < nbScales; ++i) { rectangles_[i].first.setWidth(pyramid.levels()[i].width()); //stitching includes padding in the img size. @@ -59,11 +63,9 @@ interval_(pyramid.interval()) // Build the patchwork planes const int nbPlanes = BLF(rectangles_); - //cout << " nbPlanes = " << nbPlanes << endl; + cout << " nbPlanes = " << nbPlanes << endl; - // Constructs an empty patchwork in case of error - if (nbPlanes <= 0) - return; + assert(nbPlanes >= 0); planes_.resize(nbPlanes); #pragma omp parallel for @@ -111,16 +113,14 @@ interval_(pyramid.interval()) //remove scales that are bigger than one Patchwork plane void Patchwork::prune_big_scales(JPEGPyramid & pyramid){ - int first_valid_scale_idx = 0; + int first_valid_scale_idx = pyramid.levels_.size(); for(int i=0; i < pyramid.levels_.size(); i++){ - if( (pyramid.levels_[i].width() > MaxCols_) || (pyramid.levels_[i].height() > MaxRows_) ) + if( !((pyramid.levels_[i].width() > MaxCols_) || (pyramid.levels_[i].height() > MaxRows_)) ) { first_valid_scale_idx = i; - + break; } - printf("MaxCols_=%d, MaxRows_=%d, pyramid.levels__[%d].width()=%d, pyramid.levels__[%d].height()=%d \n", MaxCols_, MaxRows_, i, pyramid.levels_[i].width(), i, pyramid.levels_[i].height()); - } if(first_valid_scale_idx > 0){ From 071051e476ce03be891d5b21832f30eb631274a9 Mon Sep 17 00:00:00 2001 From: forresti Date: Fri, 7 Feb 2014 13:20:36 -0800 Subject: [PATCH 55/92] pruning scales that are smaller than template size --- src/stitch_pyramid/Patchwork.cpp | 36 +++++++++++++++++++--- src/stitch_pyramid/Patchwork.h | 5 ++- src/stitch_pyramid/test_stitch_pyramid.cpp | 2 +- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/stitch_pyramid/Patchwork.cpp b/src/stitch_pyramid/Patchwork.cpp index b7f6bc016e5..7bc3d207806 100644 --- a/src/stitch_pyramid/Patchwork.cpp +++ b/src/stitch_pyramid/Patchwork.cpp @@ -42,19 +42,22 @@ Patchwork::Patchwork() : padx_(0), pady_(0), interval_(0) Patchwork::Patchwork(JPEGPyramid & pyramid) : padx_(pyramid.padx()), pady_(pyramid.pady()), interval_(pyramid.interval()) { + int sbin = 16; //convnet_downsampling_factor -- TODO: take as user input + int templateWidth = 5*sbin; //TODO: take as user input + int templateHeight = 15*sbin; + imwidth_ = pyramid.imwidth_; imheight_ = pyramid.imheight_; scales_ = pyramid.scales_; //keep track of pyra scales nbScales = pyramid.levels().size(); //Patchwork class variable - //printf(" MaxRows_ = %d, MaxCols_=%d \n", MaxRows_, MaxCols_); //printf(" before prune_big_scales(). scales_.size()=%ld, pyramid.levels_.size()=%ld \n", scales_.size(), pyramid.levels_.size()); - prune_big_scales(pyramid); //remove scales that won't fit in (MaxRows, MaxCols) - + prune_small_scales(pyramid, templateWidth, templateHeight); cout << " nbScales = " << nbScales << endl; - rectangles_.resize(nbScales); //printf(" after prune_big_scales(). scales_.size()=%ld, pyramid.levels_.size()=%ld \n", scales_.size(), pyramid.levels_.size()); + + rectangles_.resize(nbScales); for (int i = 0; i < nbScales; ++i) { rectangles_[i].first.setWidth(pyramid.levels()[i].width()); //stitching includes padding in the img size. @@ -131,6 +134,31 @@ void Patchwork::prune_big_scales(JPEGPyramid & pyramid){ } } +//remove scales that are smaller than the template +void Patchwork::prune_small_scales(JPEGPyramid & pyramid, int templateWidth, int templateHeight){ + + int last_valid_scale_idx = 0; + + //for(int i=0; i < pyramid.levels_.size(); i++){ + for(int i = pyramid.levels_.size()-1; i >= 0; i--){ +//printf("pyramid.levels_[%d].width=%d, templateWidth=%d \n", i, pyramid.levels_[i].width(), templateWidth); + if( ((pyramid.levels_[i].width() >= templateWidth) && (pyramid.levels_[i].height() >= templateHeight)) ) + { + last_valid_scale_idx = i; + break; + } + } +printf(" last_valid_scale_idx = %d \n", last_valid_scale_idx); + + if(last_valid_scale_idx < pyramid.levels_.size()){ + scales_.erase( scales_.begin() + last_valid_scale_idx, scales_.end() ); + pyramid.levels_.erase( pyramid.levels_.begin() + last_valid_scale_idx, pyramid.levels_.end()); + int num_scales_to_remove = nbScales - last_valid_scale_idx; + nbScales = nbScales - num_scales_to_remove; + printf("had to remove last %d scales, because they were smaller than the template \n", num_scales_to_remove); + } +} + int Patchwork::padx() const { return padx_; diff --git a/src/stitch_pyramid/Patchwork.h b/src/stitch_pyramid/Patchwork.h index edf4dbf7816..798f9ed8516 100644 --- a/src/stitch_pyramid/Patchwork.h +++ b/src/stitch_pyramid/Patchwork.h @@ -53,7 +53,10 @@ class Patchwork //remove scales that don't fit in planes void prune_big_scales(JPEGPyramid & pyramid); - + + //remove scales that are smaller than the template + void prune_small_scales(JPEGPyramid & pyramid, int templateWidth, int templateHeight); + /// Returns the amount of horizontal zero padding (in cells). int padx() const; diff --git a/src/stitch_pyramid/test_stitch_pyramid.cpp b/src/stitch_pyramid/test_stitch_pyramid.cpp index 9a7d867979e..3ed79ddd52e 100644 --- a/src/stitch_pyramid/test_stitch_pyramid.cpp +++ b/src/stitch_pyramid/test_stitch_pyramid.cpp @@ -162,7 +162,7 @@ int main(int argc, char * argv[]){ writePyraToJPG(pyramid); #endif - Patchwork patchwork = stitch_pyramid(file, padding, interval, 500); + Patchwork patchwork = stitch_pyramid(file, padding, interval, 1000); //Patchwork patchwork = stitch_pyramid(file, padding, interval, -1); //planeDim = -1 (use defaults) //printScaleSizes(pyramid); writePatchworkToJPG(patchwork, output_stitched_dir, base_filename); //outputs to output_stitched_dir/base_filename_[planeID].jpg From 6b10cf68c5589a38001d87063d2992e3999c26d8 Mon Sep 17 00:00:00 2001 From: forresti Date: Fri, 7 Feb 2014 13:34:29 -0800 Subject: [PATCH 56/92] debugging voc5 + densenet --- matlab/caffe/convnet_featpyramid.m | 33 ++++++++++++++++++++++++ matlab/caffe/featpyramid_matcaffe_demo.m | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 matlab/caffe/convnet_featpyramid.m diff --git a/matlab/caffe/convnet_featpyramid.m b/matlab/caffe/convnet_featpyramid.m new file mode 100644 index 00000000000..33e7a85123b --- /dev/null +++ b/matlab/caffe/convnet_featpyramid.m @@ -0,0 +1,33 @@ + +% wrapper for DenseNet convnet_pyramid. +% provides some extra output params that you wouldn't get with caffe('convnet_featpyramid', ...) + +% YOU MUST CALL caffe('init', ...) BEFORE RUNNING THIS. +function pyra = convnet_featpyramid(imgFname) + + % override default params: + pyra_params.interval = 5; + pyra_params.img_padding = 16; + + % compute the pyramid: + pyra = caffe('convnet_featpyramid', imgFname, pyra_params); + + % add DPM-style fields: + pyra.sbin = 16; + pyra.padx = pyra.feat_padx; % for DPM conventions + pyra.pady = pyra.feat_pady; + pyra.num_levels = length(pyra.scales); + pyra.valid_levels = true(pyra.num_levels, 1); + + pyra.imsize = [pyra.imheight pyra.imwidth]; + pyra.feat = permute_feat(pyra.feat); % [d h w] -> [h w d] +end + +% input: pyra.feat{:}, with dims [d h w] +% output: pyra.feat{:}, with dims [h w d] +function feat = permute_feat(feat) + for featIdx = 1:length(feat) + feat{featIdx} = permute( feat{featIdx}, [2 3 1] ); + end +end + diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index cfe7062f3b7..cc9298939dc 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -44,7 +44,7 @@ caffe('set_phase_test'); % optionally, pass parmeters as second argument to convnet_featpyramid (set here to the defaults) - pyra_params.interval = 10; + pyra_params.interval = 5; pyra_params.img_padding = 16; pyra = caffe('convnet_featpyramid', imfn, pyra_params ); % call with parameters ... From d1ca61ec76df5b56b056f33bed6734796ad2488d Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 6 Feb 2014 19:50:11 -0800 Subject: [PATCH 57/92] add a matcaffe debugging printout (only printed prior to assert failure). --- matlab/caffe/matcaffe.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 80bf3c262b1..bb2519d94e2 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -310,6 +310,10 @@ static mxArray * unstitch_planes( vector const & scaleLocs, vect_ uint32_t const dp_y = y + scaleLocs[i].yMin; uint32_t const dp_ix = dp_x + dp_y*dp_dims[0] + d*dp_dims[0]*dp_dims[1]; //ret_scale_data[rix] = float(d) + 1000.0*y + 1000000.0*x; + if( dp_ix >= dp->size() ) { + printf( "x=%s scaleLocs[i].xMin=%s y=%s scaleLocs[i].yMin=%s scaleLocs[i].height=%s scaleLocs[i].width=%s\n", str(x).c_str(), str(scaleLocs[i].xMin).c_str(), str(y).c_str(), str(scaleLocs[i].yMin).c_str(), str(scaleLocs[i].height).c_str(), str(scaleLocs[i].width).c_str() ); + printf( "dp_ix=%s dp->size()=%s dp_x=%s width=%s dp_y=%s height=%s d=%s depth=%s\n", str(dp_ix).c_str(), str(dp->size()).c_str(), str(dp_x).c_str(), str(width).c_str(), str(dp_y).c_str(), str(height).c_str(), str(d).c_str(), str(depth).c_str() ); + } assert(dp_ix < dp->size()); ret_scale_data[rix] = dp->at(dp_ix); } @@ -387,7 +391,7 @@ static void convnet_featpyramid(MEX_ARGS) { //prep input data for Caffe feature extraction for(int planeID=0; planeID Date: Fri, 7 Feb 2014 14:32:12 -0800 Subject: [PATCH 58/92] assert that individual images fit in the planes --- src/stitch_pyramid/Patchwork.cpp | 2 +- src/stitch_pyramid/PyramidStitcher.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stitch_pyramid/Patchwork.cpp b/src/stitch_pyramid/Patchwork.cpp index 7bc3d207806..caad7bb4707 100644 --- a/src/stitch_pyramid/Patchwork.cpp +++ b/src/stitch_pyramid/Patchwork.cpp @@ -148,8 +148,8 @@ void Patchwork::prune_small_scales(JPEGPyramid & pyramid, int templateWidth, int break; } } -printf(" last_valid_scale_idx = %d \n", last_valid_scale_idx); + //printf(" last_valid_scale_idx = %d \n", last_valid_scale_idx); if(last_valid_scale_idx < pyramid.levels_.size()){ scales_.erase( scales_.begin() + last_valid_scale_idx, scales_.end() ); pyramid.levels_.erase( pyramid.levels_.begin() + last_valid_scale_idx, pyramid.levels_.end()); diff --git a/src/stitch_pyramid/PyramidStitcher.cpp b/src/stitch_pyramid/PyramidStitcher.cpp index da3f9f14ad5..7c09e1adced 100644 --- a/src/stitch_pyramid/PyramidStitcher.cpp +++ b/src/stitch_pyramid/PyramidStitcher.cpp @@ -10,6 +10,7 @@ #include #include #include +#include using namespace FFLD; using namespace std; @@ -61,6 +62,8 @@ vector unstitch_pyramid_locations(Patchwork &patchwork, { int nbScales = patchwork.nbScales; vector scaleLocations(nbScales); + int planeWidth = patchwork.MaxCols(); + int planeHeight = patchwork.MaxRows(); for(int i=0; i unstitch_pyramid_locations(Patchwork &patchwork, scaleLocations[i].planeID = patchwork.rectangles_[i].second; + + assert( (scaleLocations[i].xMin + scaleLocations[i].width) <= planeWidth ); + assert( (scaleLocations[i].yMin + scaleLocations[i].height) <= planeHeight ); } return scaleLocations; From 019cfbf068a2fdbf2aa9e256aad6e0465ae3187c Mon Sep 17 00:00:00 2001 From: forresti Date: Tue, 11 Feb 2014 17:06:39 -0800 Subject: [PATCH 59/92] getting 33% ap on inria with densenet + 1component. --- matlab/caffe/convnet_featpyramid.m | 11 ++++-- matlab/caffe/featpyramid_matcaffe_demo.m | 9 ++++- matlab/caffe/matcaffe.cpp | 49 +++++++++++++++++------- src/stitch_pyramid/Patchwork.cpp | 13 +++++-- src/stitch_pyramid/PyramidStitcher.cpp | 10 ++++- 5 files changed, 68 insertions(+), 24 deletions(-) diff --git a/matlab/caffe/convnet_featpyramid.m b/matlab/caffe/convnet_featpyramid.m index 33e7a85123b..21fe6c2f36d 100644 --- a/matlab/caffe/convnet_featpyramid.m +++ b/matlab/caffe/convnet_featpyramid.m @@ -3,11 +3,13 @@ % provides some extra output params that you wouldn't get with caffe('convnet_featpyramid', ...) % YOU MUST CALL caffe('init', ...) BEFORE RUNNING THIS. -function pyra = convnet_featpyramid(imgFname) +function pyra = convnet_featpyramid(imgFname, pyra_params) - % override default params: - pyra_params.interval = 5; - pyra_params.img_padding = 16; + if(nargin < 2) + % use these as default params (more defaults are in the DenseNet C++ code) + pyra_params.interval = 5; + pyra_params.img_padding = 16; + end % compute the pyramid: pyra = caffe('convnet_featpyramid', imgFname, pyra_params); @@ -21,6 +23,7 @@ pyra.imsize = [pyra.imheight pyra.imwidth]; pyra.feat = permute_feat(pyra.feat); % [d h w] -> [h w d] + pyra.scales = double(pyra.scales); %get_detection_trees prefers double end % input: pyra.feat{:}, with dims [d h w] diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index cc9298939dc..1e8f6e18693 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -26,13 +26,19 @@ end %model_def_file = '../../examples/imagenet_deploy.prototxt'; - model_def_file = '../../python/caffe/imagenet/imagenet_rcnn_batch_1_input_1100x1100_output_conv5.prototxt' + model_def_file = '../../python/caffe/imagenet/imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt' % NOTE: you'll have to get the pre-trained ILSVRC network model_file = '../../examples/alexnet_train_iter_470000'; + %is_init = caffe('is_init'); + %display([' (before calling init) caffe is init? = ' num2str(is_init)]); + % init caffe network (spews logging info) caffe('init', model_def_file, model_file); + %is_init = caffe('is_init'); + %display([' (after calling init) caffe is init? = ' num2str(is_init)]); + % set to use GPU or CPU if exist('use_gpu', 'var') && use_gpu caffe('set_mode_gpu'); @@ -55,3 +61,4 @@ colormap(gray); imagesc(squeeze(sum(pyra.feat{1}, 1))); + diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index bb2519d94e2..31c7b8fa471 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -18,6 +18,19 @@ using namespace caffe; // NOLINT(build/namespaces) + uint32_t mx_to_u32( string const & err_str, mxArray const * const mxa ) { + if( !mxIsNumeric( mxa ) ) { mexErrMsgTxt( (err_str + ": expected a numeric value, got something else. ").c_str()); } + uint32_t const sz = mxGetNumberOfElements( mxa ); + if( sz != 1 ) { mexErrMsgTxt( (err_str+": expected a single element, but got " + str(sz) + ".").c_str()); } + return uint32_t(mxGetScalar(mxa)); +} + +static mxArray * u32_to_mx( uint32_t const val ) { // returned as float (i.e. scalar single) + mxArray * const mxa = mxCreateNumericMatrix( 1, 1, mxSINGLE_CLASS, mxREAL ); + *(float*)(mxGetData(mxa)) = (float)val; + return mxa; +} + // The pointer to the internal caffe::Net instance static shared_ptr > net_; @@ -205,6 +218,21 @@ static void init(MEX_ARGS) { mxFree(model_file); } + +static void is_init(MEX_ARGS) { + if ( (nrhs != 0) ) { + LOG(ERROR) << "Given " << nrhs << " arguments, expected 0."; + mexErrMsgTxt("Wrong number of arguments"); + } + if (nlhs != 1) { + LOG(ERROR) << "Caller wanted " << nlhs << " outputs, but this function always produces 1."; + mexErrMsgTxt("Wrong number of outputs"); + } + bool ret = (bool)net_; //null check + plhs[0] = u32_to_mx(ret); +} + + static void forward(MEX_ARGS) { if (nrhs != 1) { LOG(ERROR) << "Only given " << nrhs << " arguments"; @@ -325,22 +353,15 @@ static mxArray * unstitch_planes( vector const & scaleLocs, vect_ } -static uint32_t mx_to_u32( string const & err_str, mxArray const * const mxa ) { - if( !mxIsNumeric( mxa ) ) { mexErrMsgTxt( (err_str + ": expected a numeric value, got something else. ").c_str()); } - uint32_t const sz = mxGetNumberOfElements( mxa ); - if( sz != 1 ) { mexErrMsgTxt( (err_str+": expected a single element, but got " + str(sz) + ".").c_str()); } - return uint32_t(mxGetScalar(mxa)); -} - -static mxArray * u32_to_mx( uint32_t const val ) { // returned as float (i.e. scalar single) - mxArray * const mxa = mxCreateNumericMatrix( 1, 1, mxSINGLE_CLASS, mxREAL ); - *(float*)(mxGetData(mxa)) = (float)val; - return mxa; -} char const * fnames[] = { "scales", "feat", "imwidth", "imheight", "feat_padx", "feat_pady", "sbin" }; static void convnet_featpyramid(MEX_ARGS) { + + if ( !net_ ) { + LOG(ERROR) << "convnet was not initialized. please call 'init' and select CPU or GPU mode."; + mexErrMsgTxt("convnet was not initialized. please call 'init' and select CPU or GPU mode."); + } if ( (nrhs < 1) || (nrhs > 2) ) { LOG(ERROR) << "Given " << nrhs << " arguments, expected 1 or 2."; mexErrMsgTxt("Wrong number of arguments"); @@ -353,7 +374,8 @@ static void convnet_featpyramid(MEX_ARGS) { if( !fn_cs ) { mexErrMsgTxt("Could not convert first argument to a string."); } string const file( fn_cs ); mxFree(fn_cs); - + + densenet_params_t params; // ctor sets params to defaults if( nrhs > 1 ) { // (try to) parse second arg as params @@ -432,6 +454,7 @@ static handler_registry handlers[] = { // Public API functions { "forward", forward }, { "init", init }, + { "is_init", is_init }, { "set_mode_cpu", set_mode_cpu }, { "set_mode_gpu", set_mode_gpu }, { "set_phase_train", set_phase_train }, diff --git a/src/stitch_pyramid/Patchwork.cpp b/src/stitch_pyramid/Patchwork.cpp index caad7bb4707..649632d44da 100644 --- a/src/stitch_pyramid/Patchwork.cpp +++ b/src/stitch_pyramid/Patchwork.cpp @@ -43,8 +43,8 @@ Patchwork::Patchwork(JPEGPyramid & pyramid) : padx_(pyramid.padx()), pady_(pyram interval_(pyramid.interval()) { int sbin = 16; //convnet_downsampling_factor -- TODO: take as user input - int templateWidth = 5*sbin; //TODO: take as user input - int templateHeight = 15*sbin; + int templateWidth = (3+1)*sbin; //TODO: take as user input + int templateHeight = (8+1)*sbin; imwidth_ = pyramid.imwidth_; imheight_ = pyramid.imheight_; @@ -278,7 +278,9 @@ int Patchwork::BLF(vector > & rectangles) for (int i = 0; (rect.second == -1) && (i < gaps.size()); ++i) { for (g = gaps[i].begin(); g != gaps[i].end(); ++g) { - if ((g->width() >= rect.first.width()) && (g->height() >= rect.first.height())) { + if ((g->width() > rect.first.width()) && (g->height() > rect.first.height())) //Forrest -- avoid bizarre bounds error + //if ((g->width() >= rect.first.width()) && (g->height() >= rect.first.height())) + { rect.second = i; break; } @@ -297,7 +299,10 @@ int Patchwork::BLF(vector > & rectangles) // Insert the rectangle in the gap rect.first.setX(g->x()); rect.first.setY(g->y()); - + + //printf(" put scale %d in this gap: xMin=%d, xMax=%d, yMin=%d, yMax=%d \n", i, g->x(), g->x() + rect.first.width(), + // g->y(), g->y() + rect.first.height()); + // Remove all the intersecting gaps, and add newly created gaps for (g = gaps[rect.second].begin(); g != gaps[rect.second].end();) { if (!((rect.first.right() < g->left()) || (rect.first.bottom() < g->top()) || diff --git a/src/stitch_pyramid/PyramidStitcher.cpp b/src/stitch_pyramid/PyramidStitcher.cpp index 7c09e1adced..fe0d9d1cbc5 100644 --- a/src/stitch_pyramid/PyramidStitcher.cpp +++ b/src/stitch_pyramid/PyramidStitcher.cpp @@ -70,16 +70,22 @@ vector unstitch_pyramid_locations(Patchwork &patchwork, scaleLocations[i].xMin = patchwork.rectangles_[i].first.x() / convnet_subsampling_ratio; scaleLocations[i].width = patchwork.rectangles_[i].first.width() / convnet_subsampling_ratio; scaleLocations[i].xMax = scaleLocations[i].width + scaleLocations[i].xMin; //already accounts for subsampling ratio + //scaleLocations[i].xMin = (patchwork.rectangles_[i].first.x() + patchwork.rectangles_[i].first.width()) / convnet_subsampling_ratio; scaleLocations[i].yMin = patchwork.rectangles_[i].first.y() / convnet_subsampling_ratio; scaleLocations[i].height = patchwork.rectangles_[i].first.height() / convnet_subsampling_ratio; scaleLocations[i].yMax = scaleLocations[i].height + scaleLocations[i].yMin; //already accounts for subsampling ratio + //scaleLocations[i].yMax = (patchwork.rectangles_[i].first.y() + patchwork.rectangles_[i].first.height()) / convnet_subsampling_ratio; scaleLocations[i].planeID = patchwork.rectangles_[i].second; + //printf(" scale idx = %d \n", i); + //printf(" image xMax = %d, planeWidth = %d \n", scaleLocations[i].xMax, planeWidth/convnet_subsampling_ratio); + //printf(" image yMax = %d, planeHeight = %d \n", scaleLocations[i].yMax, planeHeight/convnet_subsampling_ratio); + //printf(" yMax, in rgb space = %d \n", (patchwork.rectangles_[i].first.y() + patchwork.rectangles_[i].first.height())); - assert( (scaleLocations[i].xMin + scaleLocations[i].width) <= planeWidth ); - assert( (scaleLocations[i].yMin + scaleLocations[i].height) <= planeHeight ); + assert( scaleLocations[i].xMax < planeWidth/convnet_subsampling_ratio ); + assert( scaleLocations[i].yMax < planeHeight/convnet_subsampling_ratio ); } return scaleLocations; From 79021c4ead924f5f8f19682047ee8881b59bbd5a Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Tue, 11 Feb 2014 19:07:01 -0800 Subject: [PATCH 60/92] add layer_strides() vector/accessor to net.{cpp,h} ... and use it to compute sbin / convnet_subsampling_ratio in get_sbin() in featpyra_common.hpp --- include/caffe/featpyra_common.hpp | 10 ++++++++++ include/caffe/net.hpp | 3 +++ src/caffe/net.cpp | 1 + 3 files changed, 14 insertions(+) diff --git a/include/caffe/featpyra_common.hpp b/include/caffe/featpyra_common.hpp index 12d5cd8d873..031d2b1e19a 100644 --- a/include/caffe/featpyra_common.hpp +++ b/include/caffe/featpyra_common.hpp @@ -61,5 +61,15 @@ namespace caffe { net_->ForwardPrefilled(); } + // get sbin as product of strides. note that a stride of 0 in the + // caffe strides vector indictes a layer has no stride. such layers + // are ignored in this calculation + static uint32_t get_sbin( shared_ptr > net_ ) { + vect_uint32_t const & strides = net_->layer_strides(); + uint32_t ret = 1; + for( vect_uint32_t::const_iterator i = strides.begin(); i != strides.end(); ++i ) { if( *i ) { ret *= (*i); } } + return ret; + } + template< typename T > inline std::string str(T const & i) { std::stringstream s; s << i; return s.str(); } // convert T i to string } diff --git a/include/caffe/net.hpp b/include/caffe/net.hpp index b5a57b3c5a4..cb415624463 100644 --- a/include/caffe/net.hpp +++ b/include/caffe/net.hpp @@ -62,6 +62,8 @@ class Net { inline const string& name() { return name_; } // returns the layer names inline const vector& layer_names() { return layer_names_; } + // returns the layer strides + inline const vector& layer_strides() { return layer_strides_; } // returns the blob names inline const vector& blob_names() { return blob_names_; } // returns the blobs @@ -91,6 +93,7 @@ class Net { // Individual layers in the net vector > > layers_; vector layer_names_; + vector layer_strides_; vector layer_need_backward_; // blobs stores the blobs that store intermediate results between the // layers. diff --git a/src/caffe/net.cpp b/src/caffe/net.cpp index e976dfd5fd0..cd265a21de9 100644 --- a/src/caffe/net.cpp +++ b/src/caffe/net.cpp @@ -67,6 +67,7 @@ void Net::Init(const NetParameter& in_param) { const LayerParameter& layer_param = layer_connection.layer(); layers_.push_back(shared_ptr >(GetLayer(layer_param))); layer_names_.push_back(layer_param.name()); + layer_strides_.push_back(layer_param.has_stride()?layer_param.stride():0); LOG(INFO) << "Creating Layer " << layer_param.name(); bool need_backward = param.force_backward(); // Figure out this layer's input and output From c4961d9453e17f05fca108963128058ac92f16a4 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Tue, 11 Feb 2014 19:12:15 -0800 Subject: [PATCH 61/92] weaken too-strong assertion in PyramidStitcher.cpp on {x,y}Max versus plane size --- src/stitch_pyramid/PyramidStitcher.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stitch_pyramid/PyramidStitcher.cpp b/src/stitch_pyramid/PyramidStitcher.cpp index fe0d9d1cbc5..29b24572367 100644 --- a/src/stitch_pyramid/PyramidStitcher.cpp +++ b/src/stitch_pyramid/PyramidStitcher.cpp @@ -84,8 +84,8 @@ vector unstitch_pyramid_locations(Patchwork &patchwork, //printf(" image yMax = %d, planeHeight = %d \n", scaleLocations[i].yMax, planeHeight/convnet_subsampling_ratio); //printf(" yMax, in rgb space = %d \n", (patchwork.rectangles_[i].first.y() + patchwork.rectangles_[i].first.height())); - assert( scaleLocations[i].xMax < planeWidth/convnet_subsampling_ratio ); - assert( scaleLocations[i].yMax < planeHeight/convnet_subsampling_ratio ); + assert( scaleLocations[i].xMax <= (planeWidth/convnet_subsampling_ratio) ); + assert( scaleLocations[i].yMax <= (planeHeight/convnet_subsampling_ratio) ); } return scaleLocations; From d1220a7613588ca81fdab24945cd5c624228dce4 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Tue, 11 Feb 2014 19:21:35 -0800 Subject: [PATCH 62/92] rename convnet_subsampling_ratio -> sbin --- matlab/caffe/matcaffe.cpp | 6 ++--- python/caffe/pycaffe.cpp | 6 ++--- src/stitch_pyramid/PyramidStitcher.cpp | 26 +++++++++++----------- src/stitch_pyramid/PyramidStitcher.h | 2 +- src/stitch_pyramid/test_stitch_pyramid.cpp | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 31c7b8fa471..45adf5489cd 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -398,7 +398,7 @@ static void convnet_featpyramid(MEX_ARGS) { } } - int convnet_subsampling_ratio = 16; //for conv5 layer features + int sbin = 16; //for conv5 layer features int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size int resultDepth = net_->output_blobs()[0]->channels(); @@ -420,7 +420,7 @@ static void convnet_featpyramid(MEX_ARGS) { blobs_top.push_back( p_vect_float_from_output_blob_0() ); } - vector scaleLocations = unstitch_pyramid_locations(patchwork, convnet_subsampling_ratio); + vector scaleLocations = unstitch_pyramid_locations(patchwork, sbin); uint32_t const ret_rows = patchwork.scales_.size(); assert( scaleLocations.size() == ret_rows ); @@ -436,7 +436,7 @@ static void convnet_featpyramid(MEX_ARGS) { mxSetFieldByNumber( ret, 0, 3, u32_to_mx( patchwork.imheight_ ) ); mxSetFieldByNumber( ret, 0, 4, u32_to_mx( 1 ) ); mxSetFieldByNumber( ret, 0, 5, u32_to_mx( 1 ) ); - mxSetFieldByNumber( ret, 0, 6, u32_to_mx( convnet_subsampling_ratio ) ); + mxSetFieldByNumber( ret, 0, 6, u32_to_mx( sbin ) ); plhs[0] = ret; } diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index 50d96a55b48..9650b7fe62f 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -350,7 +350,7 @@ printf("success in unstitch_planes \n"); else { throw runtime_error("unknown parameter " + string(fn) ); } } - int convnet_subsampling_ratio = 16; //for conv5 layer features + int sbin = 16; //for conv5 layer features int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size int resultDepth = net_->output_blobs()[0]->channels(); @@ -385,7 +385,7 @@ printf("success in unstitch_planes \n"); printf("\n\n in pycaffe.cpp extract_featpyramid(). planeDim=%d\n", planeDim); - vector scaleLocations = unstitch_pyramid_locations(patchwork, convnet_subsampling_ratio); + vector scaleLocations = unstitch_pyramid_locations(patchwork, sbin); boost::python::list unstitched_features = unstitch_planes(scaleLocations, blobs_top, resultDepth); boost::python::object scales_npy_boost = get_scales_boost(patchwork); @@ -398,7 +398,7 @@ printf("success in unstitch_planes \n"); d["imheight"] = patchwork.imheight_; d["feat_padx"] = 1u; // placeholder d["feat_pady"] = 1u; // placeholder - d["sbin"] = convnet_subsampling_ratio; + d["sbin"] = sbin; return d; } diff --git a/src/stitch_pyramid/PyramidStitcher.cpp b/src/stitch_pyramid/PyramidStitcher.cpp index 29b24572367..fd5828c229c 100644 --- a/src/stitch_pyramid/PyramidStitcher.cpp +++ b/src/stitch_pyramid/PyramidStitcher.cpp @@ -54,11 +54,11 @@ Patchwork stitch_pyramid(string file, int padding, int interval, int planeDim) return patchwork; } -//@param convnet_subsampling_ratio = difference between input image dim and convnet feature dim +//@param sbin = difference between input image dim and convnet feature dim // e.g. if input img is 200x200 and conv5 is 25x25 ... 200/25=8 -> 8x downsampling in convnet -//JPEGPyramid unstitch_pyramid(Patchwork image_patchwork, float* convnet_planes, int convnet_subsampling_ratio){ +//JPEGPyramid unstitch_pyramid(Patchwork image_patchwork, float* convnet_planes, int sbin){ vector unstitch_pyramid_locations(Patchwork &patchwork, - int convnet_subsampling_ratio) + int sbin) { int nbScales = patchwork.nbScales; vector scaleLocations(nbScales); @@ -67,25 +67,25 @@ vector unstitch_pyramid_locations(Patchwork &patchwork, for(int i=0; i unstitch_pyramid_locations(Patchwork &patchwork, - int convnet_subsampling_ratio); + int sbin); #endif diff --git a/src/stitch_pyramid/test_stitch_pyramid.cpp b/src/stitch_pyramid/test_stitch_pyramid.cpp index 3ed79ddd52e..50ff86660ed 100644 --- a/src/stitch_pyramid/test_stitch_pyramid.cpp +++ b/src/stitch_pyramid/test_stitch_pyramid.cpp @@ -167,9 +167,9 @@ int main(int argc, char * argv[]){ //printScaleSizes(pyramid); writePatchworkToJPG(patchwork, output_stitched_dir, base_filename); //outputs to output_stitched_dir/base_filename_[planeID].jpg - int convnet_subsampling_ratio = 1; // we're not actually computing convnet features in this test, + int sbin = 1; // we're not actually computing convnet features in this test, // so there's no feature downsampling. - vector scaleLocations = unstitch_pyramid_locations(patchwork, convnet_subsampling_ratio); + vector scaleLocations = unstitch_pyramid_locations(patchwork, sbin); //print_scaleLocations(scaleLocations); print_scales(patchwork); From 515ff5eda88c40489363459fa742cc8564473002 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Tue, 11 Feb 2014 19:33:37 -0800 Subject: [PATCH 63/92] use get_sbin(net_) to get sbin in pycaffe and matcaffe. but, TODO/FIXME the hard-coded usage in Patchwork.cpp --- matlab/caffe/matcaffe.cpp | 2 +- python/caffe/pycaffe.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 45adf5489cd..0f9acf8a8bd 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -398,7 +398,7 @@ static void convnet_featpyramid(MEX_ARGS) { } } - int sbin = 16; //for conv5 layer features + int sbin = get_sbin(net_); //for conv5 layer features int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size int resultDepth = net_->output_blobs()[0]->channels(); diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index 9650b7fe62f..a755893b392 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -350,7 +350,7 @@ printf("success in unstitch_planes \n"); else { throw runtime_error("unknown parameter " + string(fn) ); } } - int sbin = 16; //for conv5 layer features + int sbin = get_sbin(net_); //for conv5 layer features int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size int resultDepth = net_->output_blobs()[0]->channels(); From a2a178ec03424461745475ded814fc6736fae89c Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 13 Feb 2014 14:12:37 -0800 Subject: [PATCH 64/92] matcaffe: init google logging with "matcaffe" as name --- matlab/caffe/matcaffe.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 0f9acf8a8bd..2b49c33da9f 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -204,6 +204,7 @@ static void set_device(MEX_ARGS) { } static void init(MEX_ARGS) { + google::InitGoogleLogging("matcaffe"); if (nrhs != 2) { LOG(ERROR) << "Only given " << nrhs << " arguments"; mexErrMsgTxt("Wrong number of arguments"); From 99e3a83a73872a1517b5f814c8582092ea7c1bae Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 13 Feb 2014 14:13:23 -0800 Subject: [PATCH 65/92] makefile: remove unneeded -UNDEBUG, add commented -DENABLE_ALLOC_TRACE example cflags --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index effeff1495d..4573a4affe9 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,8 @@ LIBRARIES := cudart cublas curand \ PYTHON_LIBRARIES := boost_python python2.7 WARNINGS := -Wall -COMMON_FLAGS := -O2 -UNDEBUG $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) +COMMON_FLAGS := -O2 $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) +#COMMON_FLAGS := -O3 -DENABLE_ALLOC_TRACE $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) #COMMON_FLAGS := -DNDEBUG -O2 $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) NVCCFLAGS := -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS) From 2c2ec6413d947bd19edc20fdbc36e7dcef0dcb70 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 13 Feb 2014 19:35:31 -0800 Subject: [PATCH 66/92] enabling user-configurability of 'minimum desired scale' in the form of feat_minHeight,feat_minWidth. this is now usable in the the Python wrapper. We should add it to Matlab wrapper soon. --- include/caffe/featpyra_common.hpp | 4 ++++ python/caffe/imagenet/featpyramid_tests.py | 6 +++-- python/caffe/pycaffe.cpp | 20 +++++++--------- src/stitch_pyramid/Patchwork.cpp | 28 +++++++++++++--------- src/stitch_pyramid/Patchwork.h | 10 ++++++-- src/stitch_pyramid/PyramidStitcher.cpp | 7 +++--- src/stitch_pyramid/PyramidStitcher.h | 3 ++- src/stitch_pyramid/test_stitch_pyramid.cpp | 6 +++-- 8 files changed, 52 insertions(+), 32 deletions(-) diff --git a/include/caffe/featpyra_common.hpp b/include/caffe/featpyra_common.hpp index 031d2b1e19a..14906b78eb9 100644 --- a/include/caffe/featpyra_common.hpp +++ b/include/caffe/featpyra_common.hpp @@ -14,9 +14,13 @@ namespace caffe { struct densenet_params_t { uint32_t interval; // # scales per octave uint32_t img_padding; // in image pixels (at scale=1.0). could later allow per-dim img_padx/img_pady as alternative. + uint32_t feat_minWidth; //smallest desired output scale, in terms of descriptor dimensions + uint32_t feat_minHeight; densenet_params_t( void ) { // default values interval = 10; img_padding = 16; + feat_minWidth = 1; + feat_minHeight = 1; } }; diff --git a/python/caffe/imagenet/featpyramid_tests.py b/python/caffe/imagenet/featpyramid_tests.py index bf9d3b07784..31250eb5a28 100644 --- a/python/caffe/imagenet/featpyramid_tests.py +++ b/python/caffe/imagenet/featpyramid_tests.py @@ -42,6 +42,8 @@ def test_featpyramid_allScales(caffenet, imgFname): densenet_params = dict() densenet_params['interval'] = 10 densenet_params['img_padding'] = 16 + densenet_params['feat_minWidth'] = 10 #smallest desired scale, in terms of feature map dims + densenet_params['feat_minHeight'] = 10 start_time = time.time() pyra = caffenet.extract_featpyramid(imgFname, densenet_params) # THE CRUX ... @@ -81,8 +83,8 @@ def test_featpyramid_allScales(caffenet, imgFname): if __name__ == "__main__": #pretend that these flags came off the command line: - #imgFname = './pascal_009959.jpg' - imgFname = '/media/big_disk/datasets/INRIA_PASCAL_jpg/VOCdevkit/VOC2007/Images/crop001002.jpg' + imgFname = './pascal_009959.jpg' + #imgFname = '/media/big_disk/datasets/INRIA_PASCAL_jpg/VOCdevkit/VOC2007/Images/crop001002.jpg' #model_def = '../../../examples/imagenet_deploy.prototxt' model_def = './imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt' pretrained_model = '../../../examples/alexnet_train_iter_470000' diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index a755893b392..00d304233ee 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -304,14 +304,9 @@ struct CaffeNet { int nbScales = scaleLocs.size(); int batchsize = 1; //TODO: assert that batchsize really is 1. -printf("in unstitch planes \n"); - for(int i=0; iinput_blobs()[0]->width(); //assume that all preallocated blobs are same size + int resultDepth = net_->output_blobs()[0]->channels(); + densenet_params_t params; // ctor sets params to defaults list params_keys = params_dict.keys(); for( uint32_t i = 0; i < len(params_keys); ++i) { @@ -347,18 +345,18 @@ printf("success in unstitch_planes \n"); if( 0 ) { } else if( fn == "interval" ) { params.interval = extract(val); } else if( fn == "img_padding" ) { params.img_padding = extract(val); } + else if( fn == "feat_minHeight" ) { params.feat_minHeight = extract(val); } + else if( fn == "feat_minWidth" ) { params.feat_minWidth = extract(val); } else { throw runtime_error("unknown parameter " + string(fn) ); } } - - int sbin = get_sbin(net_); //for conv5 layer features - int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size - int resultDepth = net_->output_blobs()[0]->channels(); + int img_minHeight = params.feat_minHeight * sbin; + int img_minWidth = params.feat_minWidth * sbin; assert(net_->input_blobs()[0]->width() == net_->input_blobs()[0]->height()); //assume square planes in Caffe. (can relax this if necessary) assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) //TODO: verify/assert that top-upsampled version of input img fits within planeDim - Patchwork patchwork = stitch_pyramid(file, params.img_padding, params.interval, planeDim); + Patchwork patchwork = stitch_pyramid(file, img_minHeight, img_minWidth, params.img_padding, params.interval, planeDim); int nbPlanes = patchwork.planes_.size(); boost::python::list blobs_bottom; //input buffer(s) for Caffe::Forward diff --git a/src/stitch_pyramid/Patchwork.cpp b/src/stitch_pyramid/Patchwork.cpp index 649632d44da..db1ee6f89f5 100644 --- a/src/stitch_pyramid/Patchwork.cpp +++ b/src/stitch_pyramid/Patchwork.cpp @@ -31,9 +31,12 @@ using namespace FFLD; using namespace std; +//static vars (TODO: make these not static...) int Patchwork::MaxRows_(0); int Patchwork::MaxCols_(0); int Patchwork::HalfCols_(0); +int Patchwork::img_minWidth_(0); +int Patchwork::img_minHeight_(0); Patchwork::Patchwork() : padx_(0), pady_(0), interval_(0) { @@ -42,9 +45,9 @@ Patchwork::Patchwork() : padx_(0), pady_(0), interval_(0) Patchwork::Patchwork(JPEGPyramid & pyramid) : padx_(pyramid.padx()), pady_(pyramid.pady()), interval_(pyramid.interval()) { - int sbin = 16; //convnet_downsampling_factor -- TODO: take as user input - int templateWidth = (3+1)*sbin; //TODO: take as user input - int templateHeight = (8+1)*sbin; + //int sbin = 16; //convnet_downsampling_factor -- TODO: take as user input + //int templateWidth = (6+1)*sbin; //TODO: take as user input + //int templateHeight = (16+1)*sbin; imwidth_ = pyramid.imwidth_; imheight_ = pyramid.imheight_; @@ -53,7 +56,7 @@ interval_(pyramid.interval()) //printf(" before prune_big_scales(). scales_.size()=%ld, pyramid.levels_.size()=%ld \n", scales_.size(), pyramid.levels_.size()); prune_big_scales(pyramid); //remove scales that won't fit in (MaxRows, MaxCols) - prune_small_scales(pyramid, templateWidth, templateHeight); + prune_small_scales(pyramid, img_minWidth_, img_minHeight_); //img_minWidth and img_minHeight are configured in Patchwork::Init() cout << " nbScales = " << nbScales << endl; //printf(" after prune_big_scales(). scales_.size()=%ld, pyramid.levels_.size()=%ld \n", scales_.size(), pyramid.levels_.size()); @@ -130,19 +133,19 @@ void Patchwork::prune_big_scales(JPEGPyramid & pyramid){ scales_.erase( scales_.begin(), scales_.begin() + first_valid_scale_idx); pyramid.levels_.erase( pyramid.levels_.begin(), pyramid.levels_.begin() + first_valid_scale_idx); nbScales = nbScales - first_valid_scale_idx; - printf("had to remove first %d scales, because they didn't fit in Patchwork plane \n", first_valid_scale_idx); + printf(" had to remove first %d scales, because they didn't fit in Patchwork plane \n", first_valid_scale_idx); } } //remove scales that are smaller than the template -void Patchwork::prune_small_scales(JPEGPyramid & pyramid, int templateWidth, int templateHeight){ +void Patchwork::prune_small_scales(JPEGPyramid & pyramid, int img_minWidth_, int img_minHeight_){ int last_valid_scale_idx = 0; //for(int i=0; i < pyramid.levels_.size(); i++){ for(int i = pyramid.levels_.size()-1; i >= 0; i--){ -//printf("pyramid.levels_[%d].width=%d, templateWidth=%d \n", i, pyramid.levels_[i].width(), templateWidth); - if( ((pyramid.levels_[i].width() >= templateWidth) && (pyramid.levels_[i].height() >= templateHeight)) ) +//printf("pyramid.levels_[%d].width=%d, img_minWidth_=%d \n", i, pyramid.levels_[i].width(), img_minWidth_); + if( ((pyramid.levels_[i].width() >= img_minWidth_) && (pyramid.levels_[i].height() >= img_minHeight_)) ) { last_valid_scale_idx = i; break; @@ -155,7 +158,7 @@ void Patchwork::prune_small_scales(JPEGPyramid & pyramid, int templateWidth, int pyramid.levels_.erase( pyramid.levels_.begin() + last_valid_scale_idx, pyramid.levels_.end()); int num_scales_to_remove = nbScales - last_valid_scale_idx; nbScales = nbScales - num_scales_to_remove; - printf("had to remove last %d scales, because they were smaller than the template \n", num_scales_to_remove); + printf(" had to remove last %d scales, because they were smaller than the minimum that you specified in (feat_minWidth, feat_minHeight) \n", num_scales_to_remove); } } @@ -179,7 +182,7 @@ bool Patchwork::empty() const return planes_.empty(); } -bool Patchwork::Init(int maxRows, int maxCols) +bool Patchwork::Init(int maxRows, int maxCols, int img_minWidth, int img_minHeight) { // It is an error if maxRows or maxCols are too small if ((maxRows < 2) || (maxCols < 2)) @@ -188,10 +191,13 @@ bool Patchwork::Init(int maxRows, int maxCols) // Temporary matrices //JPEGPyramid::Matrix tmp(maxRows * JPEGPyramid::NbChannels, maxCols + 2); - int dims[2] = {maxRows, maxCols}; + //int dims[2] = {maxRows, maxCols}; MaxRows_ = maxRows; MaxCols_ = maxCols; HalfCols_ = maxCols / 2 + 1; + + img_minWidth_ = img_minWidth; + //img_minHeight_ = img_minHeight; } int Patchwork::MaxRows() diff --git a/src/stitch_pyramid/Patchwork.h b/src/stitch_pyramid/Patchwork.h index 798f9ed8516..66ee18fd312 100644 --- a/src/stitch_pyramid/Patchwork.h +++ b/src/stitch_pyramid/Patchwork.h @@ -55,7 +55,7 @@ class Patchwork void prune_big_scales(JPEGPyramid & pyramid); //remove scales that are smaller than the template - void prune_small_scales(JPEGPyramid & pyramid, int templateWidth, int templateHeight); + void prune_small_scales(JPEGPyramid & pyramid, int img_minWidth_, int img_minHeight_); /// Returns the amount of horizontal zero padding (in cells). int padx() const; @@ -78,9 +78,10 @@ class Patchwork /// Initializes the data structures. /// @param[in] maxRows Maximum number of rows of a pyramid level (including padding). /// @param[in] maxCols Maximum number of columns of a pyramid level (including padding). + /// @param[in] img_minWidth, img_minHeight = size of smallest desired scale (in pixels) /// @returns Whether the initialization was successful. /// @note Must be called before any other method (including constructors). - static bool Init(int maxRows, int maxCols); + static bool Init(int maxRows, int maxCols, int img_minWidth, int img_minHeight); /// Returns the current maximum number of rows of a pyramid level (including padding). static int MaxRows(); @@ -101,6 +102,11 @@ class Patchwork static int MaxCols_; static int HalfCols_; + //size of smallest image scale desired by user + static int img_minWidth_; + static int img_minHeight_; + + //size of input image int imwidth_; int imheight_; diff --git a/src/stitch_pyramid/PyramidStitcher.cpp b/src/stitch_pyramid/PyramidStitcher.cpp index fd5828c229c..e06b337489b 100644 --- a/src/stitch_pyramid/PyramidStitcher.cpp +++ b/src/stitch_pyramid/PyramidStitcher.cpp @@ -19,7 +19,8 @@ using namespace std; // @param planeDim == width == height of planes to cover with images (optional) // if planeDim <= 0, then ignore planeDim and compute plane size based on input image dims -Patchwork stitch_pyramid(string file, int padding, int interval, int planeDim) +Patchwork stitch_pyramid(string file, int img_minWidth, int img_minHeight, + int padding, int interval, int planeDim) { JPEGImage image(file); if (image.empty()) { @@ -48,7 +49,7 @@ Patchwork stitch_pyramid(string file, int padding, int interval, int planeDim) planeHeight = max(planeWidth, planeHeight); } - Patchwork::Init(planeHeight, planeWidth); + Patchwork::Init(planeHeight, planeWidth, img_minWidth, img_minHeight); const Patchwork patchwork(pyramid); //STITCH return patchwork; @@ -85,7 +86,7 @@ vector unstitch_pyramid_locations(Patchwork &patchwork, //printf(" yMax, in rgb space = %d \n", (patchwork.rectangles_[i].first.y() + patchwork.rectangles_[i].first.height())); assert( scaleLocations[i].xMax <= (planeWidth/sbin) ); - assert( scaleLocations[i].yMax <= (planeHeight/sbin) ); + assert( scaleLocations[i].yMax <= (planeHeight/sbin) ); } return scaleLocations; diff --git a/src/stitch_pyramid/PyramidStitcher.h b/src/stitch_pyramid/PyramidStitcher.h index 7d088683b69..d96d8aa0ae2 100644 --- a/src/stitch_pyramid/PyramidStitcher.h +++ b/src/stitch_pyramid/PyramidStitcher.h @@ -31,7 +31,8 @@ class ScaleLocation{ //image -> multiscale pyramid -> stitch to same-sized planes for Caffe convnet -Patchwork stitch_pyramid(string file, int padding=8, int interval=10, int planeDim=-1); +Patchwork stitch_pyramid(string file, int img_minWidth=1, int img_minHeight=1, + int padding=8, int interval=10, int planeDim=-1); // coordinates for unstitching the feature descriptors from planes. // sorted in descending order of size. diff --git a/src/stitch_pyramid/test_stitch_pyramid.cpp b/src/stitch_pyramid/test_stitch_pyramid.cpp index 50ff86660ed..f5f524d6cd8 100644 --- a/src/stitch_pyramid/test_stitch_pyramid.cpp +++ b/src/stitch_pyramid/test_stitch_pyramid.cpp @@ -162,8 +162,10 @@ int main(int argc, char * argv[]){ writePyraToJPG(pyramid); #endif - Patchwork patchwork = stitch_pyramid(file, padding, interval, 1000); - //Patchwork patchwork = stitch_pyramid(file, padding, interval, -1); //planeDim = -1 (use defaults) + int img_minWidth = 200; //just a test + int img_minHeight = 200; + Patchwork patchwork = stitch_pyramid(file, img_minWidth, img_minHeight, padding, interval, 1000); + //Patchwork patchwork = stitch_pyramid(file, img_minWidth, img_minHeight, padding, interval, -1); //planeDim = -1 (use defaults) //printScaleSizes(pyramid); writePatchworkToJPG(patchwork, output_stitched_dir, base_filename); //outputs to output_stitched_dir/base_filename_[planeID].jpg From eacacdb3554e3b0ae84e07210106cbf42abc42c4 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Fri, 14 Feb 2014 10:59:52 -0800 Subject: [PATCH 67/92] swap matcaffe demo plane size 2000 -> 1100 (again) --- matlab/caffe/featpyramid_matcaffe_demo.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index 1e8f6e18693..4a3c21a69d0 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -26,7 +26,7 @@ end %model_def_file = '../../examples/imagenet_deploy.prototxt'; - model_def_file = '../../python/caffe/imagenet/imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt' + model_def_file = '../../python/caffe/imagenet/imagenet_rcnn_batch_1_input_1100x1100_output_conv5.prototxt' % NOTE: you'll have to get the pre-trained ILSVRC network model_file = '../../examples/alexnet_train_iter_470000'; From 688419fdea338fc7f9a72a5f8179b2d51a331ca3 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Fri, 14 Feb 2014 11:05:05 -0800 Subject: [PATCH 68/92] matcaffe: almost-minimal commit to fix/add feat_min{Width,Height} support note that matcaffe was broken (would compile, but would have incorrect behavior) when feat_min{Width,Height} were added these since the function that should have been taking them has 5 int args, all with defaults, and new args were added in middle of the arg list. --- matlab/caffe/featpyramid_matcaffe_demo.m | 2 ++ matlab/caffe/matcaffe.cpp | 7 ++++++- python/caffe/pycaffe.cpp | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index 4a3c21a69d0..c6868dfd0d4 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -52,6 +52,8 @@ % optionally, pass parmeters as second argument to convnet_featpyramid (set here to the defaults) pyra_params.interval = 5; pyra_params.img_padding = 16; + pyra_params.feat_minWidth = 1; + pyra_params.feat_minHeight = 1; pyra = caffe('convnet_featpyramid', imfn, pyra_params ); % call with parameters ... % pyra = caffe('convnet_featpyramid', imfn ); % ... or with no parameters diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 2b49c33da9f..984458cca2c 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -395,6 +395,8 @@ static void convnet_featpyramid(MEX_ARGS) { if( 0 ) { } else if( !strcmp( fn, "interval" ) ) { params.interval = mx_to_u32( "for param interval", mx_f ); } else if( !strcmp( fn, "img_padding" ) ) { params.img_padding = mx_to_u32( "for param img_padding", mx_f ); } + else if( !strcmp( fn, "feat_minHeight" ) ) { params.feat_minHeight = mx_to_u32( "for param feat_minHeight", mx_f ); } + else if( !strcmp( fn, "feat_minWidth" ) ) { params.feat_minWidth = mx_to_u32( "for param feat_minWidth", mx_f ); } else { mexErrMsgTxt( ("unknown parameter " + string(fn) ).c_str() ); } } } @@ -403,11 +405,14 @@ static void convnet_featpyramid(MEX_ARGS) { int planeDim = net_->input_blobs()[0]->width(); //assume that all preallocated blobs are same size int resultDepth = net_->output_blobs()[0]->channels(); + uint32_t const img_minHeight = params.feat_minHeight * sbin; + uint32_t const img_minWidth = params.feat_minWidth * sbin; + assert(net_->input_blobs()[0]->width() == net_->input_blobs()[0]->height()); //assume square planes in Caffe. (can relax this if necessary) assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) //TODO: verify/assert that top-upsampled version of input img fits within planeDim - Patchwork patchwork = stitch_pyramid(file, params.img_padding, params.interval, planeDim); + Patchwork patchwork = stitch_pyramid(file, img_minHeight, img_minWidth, params.img_padding, params.interval, planeDim); int nbPlanes = patchwork.planes_.size(); vect_p_vect_float blobs_top; diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index 00d304233ee..bc592ea1115 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -349,8 +349,8 @@ struct CaffeNet { else if( fn == "feat_minWidth" ) { params.feat_minWidth = extract(val); } else { throw runtime_error("unknown parameter " + string(fn) ); } } - int img_minHeight = params.feat_minHeight * sbin; - int img_minWidth = params.feat_minWidth * sbin; + uint32_t const img_minHeight = params.feat_minHeight * sbin; + uint32_t const img_minWidth = params.feat_minWidth * sbin; assert(net_->input_blobs()[0]->width() == net_->input_blobs()[0]->height()); //assume square planes in Caffe. (can relax this if necessary) assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) From 0d1cfb207de70f1937e15229dd323cad0784951b Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Fri, 14 Feb 2014 11:07:27 -0800 Subject: [PATCH 69/92] matcaffe demo: set interval=10 (the default) to agree with comment --- matlab/caffe/featpyramid_matcaffe_demo.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index c6868dfd0d4..ec05f18830b 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -50,7 +50,7 @@ caffe('set_phase_test'); % optionally, pass parmeters as second argument to convnet_featpyramid (set here to the defaults) - pyra_params.interval = 5; + pyra_params.interval = 10; pyra_params.img_padding = 16; pyra_params.feat_minWidth = 1; pyra_params.feat_minHeight = 1; From cbaea7700b8cf18caf4547a09661978cdb51e7cc Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Fri, 14 Feb 2014 11:10:53 -0800 Subject: [PATCH 70/92] remove unneeded and unused defaults from stitch_pyramid() decl --- src/stitch_pyramid/PyramidStitcher.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stitch_pyramid/PyramidStitcher.h b/src/stitch_pyramid/PyramidStitcher.h index d96d8aa0ae2..4d5e209fca2 100644 --- a/src/stitch_pyramid/PyramidStitcher.h +++ b/src/stitch_pyramid/PyramidStitcher.h @@ -31,8 +31,8 @@ class ScaleLocation{ //image -> multiscale pyramid -> stitch to same-sized planes for Caffe convnet -Patchwork stitch_pyramid(string file, int img_minWidth=1, int img_minHeight=1, - int padding=8, int interval=10, int planeDim=-1); +Patchwork stitch_pyramid(string file, int img_minWidth, int img_minHeight, + int padding, int interval, int planeDim); // coordinates for unstitching the feature descriptors from planes. // sorted in descending order of size. From 294054fbdcd78c06d05622f6b18e80f93ba7f3a8 Mon Sep 17 00:00:00 2001 From: forresti Date: Fri, 14 Feb 2014 13:53:43 -0800 Subject: [PATCH 71/92] forgot to initialize img_minHeight_. fixed. --- src/stitch_pyramid/Patchwork.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stitch_pyramid/Patchwork.cpp b/src/stitch_pyramid/Patchwork.cpp index db1ee6f89f5..3c58a4832cb 100644 --- a/src/stitch_pyramid/Patchwork.cpp +++ b/src/stitch_pyramid/Patchwork.cpp @@ -197,7 +197,7 @@ bool Patchwork::Init(int maxRows, int maxCols, int img_minWidth, int img_minHeig HalfCols_ = maxCols / 2 + 1; img_minWidth_ = img_minWidth; - //img_minHeight_ = img_minHeight; + img_minHeight_ = img_minHeight; } int Patchwork::MaxRows() From 30d999a07d5c0347db09628647f15dfee0896ef9 Mon Sep 17 00:00:00 2001 From: forresti Date: Fri, 14 Feb 2014 14:39:47 -0800 Subject: [PATCH 72/92] better scheme for convnet_featpyramid to unpack user's params --- matlab/caffe/convnet_featpyramid.m | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/matlab/caffe/convnet_featpyramid.m b/matlab/caffe/convnet_featpyramid.m index 21fe6c2f36d..fb8a4f4abba 100644 --- a/matlab/caffe/convnet_featpyramid.m +++ b/matlab/caffe/convnet_featpyramid.m @@ -5,11 +5,19 @@ % YOU MUST CALL caffe('init', ...) BEFORE RUNNING THIS. function pyra = convnet_featpyramid(imgFname, pyra_params) - if(nargin < 2) - % use these as default params (more defaults are in the DenseNet C++ code) + %set defaults for params not passed by user + if( ~exist('pyra_params') || ~isfield(pyra_params, 'interval') ) pyra_params.interval = 5; + end + if( ~exist('pyra_params') || ~isfield(pyra_params, 'img_padding') ) pyra_params.img_padding = 16; end + if( ~exist('pyra_params') || ~isfield(pyra_params, 'feat_minWidth') ) + pyra_params.feat_minWidth = 1; + end + if( ~exist('pyra_params') || ~isfield(pyra_params, 'feat_minHeight') ) + pyra_params.feat_minHeight = 1; + end % compute the pyramid: pyra = caffe('convnet_featpyramid', imgFname, pyra_params); From 42dde72ac2cd6b2207321a07550385b623515f3c Mon Sep 17 00:00:00 2001 From: forresti Date: Fri, 14 Feb 2014 14:57:52 -0800 Subject: [PATCH 73/92] testing out the 'user-selectable min image scale' stuff in python and matlab. also, commenting out InitGoogleLogging() in matcaffe until we decide how to avoid multiple calls to InitGoogleLogging --- matlab/caffe/matcaffe.cpp | 6 ++++-- python/caffe/pycaffe.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 984458cca2c..dbdc6ffd57a 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -204,7 +204,9 @@ static void set_device(MEX_ARGS) { } static void init(MEX_ARGS) { - google::InitGoogleLogging("matcaffe"); + //if(!google::IsGoogleLoggingInitialized()){ + // google::InitGoogleLogging("matcaffe"); + //} if (nrhs != 2) { LOG(ERROR) << "Only given " << nrhs << " arguments"; mexErrMsgTxt("Wrong number of arguments"); @@ -412,7 +414,7 @@ static void convnet_featpyramid(MEX_ARGS) { assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) //TODO: verify/assert that top-upsampled version of input img fits within planeDim - Patchwork patchwork = stitch_pyramid(file, img_minHeight, img_minWidth, params.img_padding, params.interval, planeDim); + Patchwork patchwork = stitch_pyramid(file, img_minWidth, img_minHeight, params.img_padding, params.interval, planeDim); int nbPlanes = patchwork.planes_.size(); vect_p_vect_float blobs_top; diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index bc592ea1115..bd5d562d171 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -356,7 +356,7 @@ struct CaffeNet { assert(net_->input_blobs()[0]->num() == 1); //for now, one plane at a time.) //TODO: verify/assert that top-upsampled version of input img fits within planeDim - Patchwork patchwork = stitch_pyramid(file, img_minHeight, img_minWidth, params.img_padding, params.interval, planeDim); + Patchwork patchwork = stitch_pyramid(file, img_minWidth, img_minHeight, params.img_padding, params.interval, planeDim); int nbPlanes = patchwork.planes_.size(); boost::python::list blobs_bottom; //input buffer(s) for Caffe::Forward From 67ffe15457788c8df215a859a09e3953c9a2abbd Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Fri, 14 Feb 2014 14:19:57 -0800 Subject: [PATCH 74/92] improve google logging init for matcaffe but note that it is still wrong. at a minimum, maybe we should have a way to disable trying to init logging (i.e. as a param to caffe('init')) as a workaround for the multiple-library usage case? --- matlab/caffe/matcaffe.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index dbdc6ffd57a..0c6abcd0dc0 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -203,10 +203,13 @@ static void set_device(MEX_ARGS) { Caffe::SetDevice(device_id); } + static void init(MEX_ARGS) { - //if(!google::IsGoogleLoggingInitialized()){ - // google::InitGoogleLogging("matcaffe"); - //} + // this isn't good enough, but it's better than nothing. see + // https://code.google.com/p/google-glog/issues/detail?id=113 + static bool glog_is_init = 0; + if( !glog_is_init ) { google::InitGoogleLogging("matcaffe"); glog_is_init=1; } + if (nrhs != 2) { LOG(ERROR) << "Only given " << nrhs << " arguments"; mexErrMsgTxt("Wrong number of arguments"); From 0c83487826e11218b6ed95755c66a0c589b1dc91 Mon Sep 17 00:00:00 2001 From: forresti Date: Fri, 14 Feb 2014 16:12:01 -0800 Subject: [PATCH 75/92] simplified demo --- python/caffe/featpyramid_demo.py | 71 ++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 python/caffe/featpyramid_demo.py diff --git a/python/caffe/featpyramid_demo.py b/python/caffe/featpyramid_demo.py new file mode 100644 index 00000000000..dc1aa6b5b6d --- /dev/null +++ b/python/caffe/featpyramid_demo.py @@ -0,0 +1,71 @@ +''' +test cases for multiscale pyramids of Convnet features. + + used power_wrapper.py as a starting point. +''' + +import numpy as np +import os +import sys +import gflags +import time +import caffe +import time + +#for visualization, can be removed easily: +from matplotlib import cm, pyplot +import pylab + +def test_featpyramid_allScales(caffenet, imgFname): + + densenet_params = dict() + densenet_params['interval'] = 10 + densenet_params['img_padding'] = 16 + densenet_params['feat_minWidth'] = 10 #smallest desired scale, in terms of feature map dims + densenet_params['feat_minHeight'] = 10 + + start_time = time.time() + pyra = caffenet.extract_featpyramid(imgFname, densenet_params) # THE CRUX ... + # pyra = caffenet.extract_featpyramid(imgFname) # ... or THE CRUX without parameters + pyra_time = time.time() - start_time + print " computed pyra in %f sec" %pyra_time + + feat = pyra["feat"] + + output_dir = 'output_pyra' + try: + os.makedirs( output_dir ) + except OSError, e: + pass + + for i in xrange(0, len(feat)): + print 'feat[%d] shape: '%i + print feat[i].shape + + #prep for visualization (sum over depth of descriptors) + flat_descriptor = np.sum(feat[i], axis=1) #e.g. (1, depth=256, height=124, width=124) -> (1, 124, 124) + flat_descriptor = flat_descriptor[0] #(1, 124, 124) -> (124, 124) ... first image (in a batch size of 1) + + #visualization + pyplot.figure() + pyplot.title('Welcome to deep learning land. You have arrived.') + pyplot.imshow(flat_descriptor, cmap = cm.gray, interpolation='nearest') + pylab.savefig( output_dir + '/flat_descriptor_scale%d.jpg' % i) + + print "\n pyra scales:" + print pyra["scales"] + print "pyra[imwidth] = %d, pyra[imheight]=%d" % (pyra['imwidth'], pyra['imheight']) + +if __name__ == "__main__": + + imgFname = './pascal_009959.jpg' + model_def = './imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt' + pretrained_model = '../../../examples/alexnet_train_iter_470000' + use_gpu = True + + caffenet = caffe.CaffeNet(model_def, pretrained_model) + caffenet.set_phase_test() + if use_gpu: + caffenet.set_mode_gpu() + + test_featpyramid_allScales(caffenet, imgFname) From 745c0f77e7a57444d1a9212c50a02fc5d30029d9 Mon Sep 17 00:00:00 2001 From: forresti Date: Fri, 14 Feb 2014 17:33:28 -0800 Subject: [PATCH 76/92] handling 'pull bbox out of pyra' for boxes that are near the edge. --- matlab/caffe/get_featureSlice.m | 54 ++++++++++++++------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/matlab/caffe/get_featureSlice.m b/matlab/caffe/get_featureSlice.m index 7415c99aab2..275594480fb 100644 --- a/matlab/caffe/get_featureSlice.m +++ b/matlab/caffe/get_featureSlice.m @@ -25,6 +25,8 @@ padx_desc_scaled = pyra.padx; %this is in descriptor cells and not image pixels. pady_desc_scaled = pyra.pady; + scale_width_desc = size(pyra.feat{scaleIdx},2); + scale_height_desc = size(pyra.feat{scaleIdx},1); %3. rip out a slice from the appropriate scale @@ -33,22 +35,34 @@ bbox_desc_x_center = bbox_desc.x1 + (bbox_desc.x2 - bbox_desc.x1)/2.0; bbox_desc_y_center = bbox_desc.y1 + (bbox_desc.y2 - bbox_desc.y1)/2.0; bbox_to_use.x1 = ceil(bbox_desc_x_center*scale_to_use - templateSize(2)/2.0 + padx_desc_scaled); %(center - templateWidth/2) + bbox_to_use.x1 = max(1, bbox_to_use.x1); % make sure we didn't fall off the edge bbox_to_use.x2 = bbox_to_use.x1 + templateSize(2) - 1; bbox_to_use.y1 = ceil(bbox_desc_y_center*scale_to_use - templateSize(1)/2.0 + pady_desc_scaled); %(center - templateHeight/2) + bbox_to_use.y1 = max(1, bbox_to_use.y1); % make sure we didn't fall off the edge bbox_to_use.y2 = bbox_to_use.y1 + templateSize(1) - 1; - %display('new...') - %bbox_to_use - %bbox_to_use.x1 = round(bbox_desc.x1 * scale_to_use + padx_desc_scaled); - %bbox_to_use.x2 = bbox_to_use.x1 + templateSize(2) - 1; - %bbox_to_use.y1 = round(bbox_desc.y1 * scale_to_use + pady_desc_scaled); - %bbox_to_use.y2 = bbox_to_use.y1 + templateSize(1) - 1; - %display('old...') + %4. make sure the slice fits into the overall space. + + if(bbox_to_use.x2 > scale_width_desc) %if we fell off the edge... + x_offset = bbox_to_use.x2 - scale_width_desc; %amount by which we fell off the edge + bbox_to_use.x1 = bbox_to_use.x1 - x_offset; + bbox_to_use.x2 = bbox_to_use.x2 - x_offset; + end + if(bbox_to_use.y2 > scale_height_desc) %if we fell off the edge... + y_offset = bbox_to_use.y2 - scale_height_desc; %amount by which we fell off the edge + bbox_to_use.y1 = bbox_to_use.y1 - y_offset; + bbox_to_use.y2 = bbox_to_use.y2 - y_offset; + end + %bbox_to_use %scale_to_use %scaleIdx - - featureSlice = pyra.feat{scaleIdx}(bbox_to_use.y1 : bbox_to_use.y2, bbox_to_use.x1 : bbox_to_use.x2, :); + try + featureSlice = pyra.feat{scaleIdx}(bbox_to_use.y1 : bbox_to_use.y2, bbox_to_use.x1 : bbox_to_use.x2, :); + catch + display('problem with get_featureSlice... you can debug it') + keyboard + end %4. project rounded box back to img space (approx) -- for debugging roundedBox_in_px = bbox_mult(bbox_to_use, (pyra.sbin / scale_to_use)); @@ -59,28 +73,6 @@ roundedBox_in_px.y2 = roundedBox_in_px.y2 - pyra.pady*pyra.sbin/scale_to_use; end -% @param gt_bbox = example bbox to slice out of pyramid (in pixel coords) -% @param templateSize = shape desired in terms of HOG cells -function gt_bbox_new = match_aspect_ratio(gt_bbox, templateSize) - - aspect_ratio_template = templateSize(1)/templateSize(2) % height/width - aspect_ratio_gt = (gt_bbox.y2 - gt_bbox.y1) / (gt_bbox.x2 - gt_bbox.x1) - - gt_bbox_new = gt_bbox; - if(aspect_ratio_template < aspect_ratio_gt) %gt_bbox is too tall - %make gt_bbox wider (height stays unchanged) - gt_width = gt_bbox.x2 - gt_bbox.x1; - gt_new_width = gt_width * (aspect_ratio_gt / aspect_ratio_template); %wider - gt_bbox_new.x2 = gt_bbox.x2 - gt_width + gt_new_width; - - elseif(aspect_ratio_template > aspect_ratio_gt) %gt_bbox is too wide - %make gt_bbox taller (width stays unchanged) - gt_height = gt_bbox.y2 - gt_bbox.y1; - gt_new_height = gt_height * (aspect_ratio_template / aspect_ratio_gt); %taller - gt_bbox_new.y2 = gt_bbox.y2 - gt_height + gt_new_height; - end -end - % multiply a bbox.{x1 x2 y1 y2} by some value. function bbox_out = bbox_mult(bbox, multiplier) bbox_out.x1 = bbox.x1 * multiplier; From 869ef4dcbc25d54d5d033a22eaa884348b93f119 Mon Sep 17 00:00:00 2001 From: forresti Date: Tue, 18 Feb 2014 15:55:44 -0800 Subject: [PATCH 77/92] fix paths in demo --- python/caffe/featpyramid_demo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/caffe/featpyramid_demo.py b/python/caffe/featpyramid_demo.py index dc1aa6b5b6d..eca0dc791ca 100644 --- a/python/caffe/featpyramid_demo.py +++ b/python/caffe/featpyramid_demo.py @@ -7,7 +7,7 @@ import numpy as np import os import sys -import gflags +#import gflags import time import caffe import time @@ -58,9 +58,9 @@ def test_featpyramid_allScales(caffenet, imgFname): if __name__ == "__main__": - imgFname = './pascal_009959.jpg' - model_def = './imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt' - pretrained_model = '../../../examples/alexnet_train_iter_470000' + imgFname = './imagenet/pascal_009959.jpg' + model_def = './imagenet/imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt' + pretrained_model = '../../examples/alexnet_train_iter_470000' use_gpu = True caffenet = caffe.CaffeNet(model_def, pretrained_model) From 7c9966f687605ab21f82165f4b36b9a0fed8aaa2 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 20 Feb 2014 18:00:38 -0800 Subject: [PATCH 78/92] tweaking demos; looking at receptive fields --- matlab/caffe/featpyramid_matcaffe_demo.m | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index ec05f18830b..dc2cc22b571 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -30,15 +30,9 @@ % NOTE: you'll have to get the pre-trained ILSVRC network model_file = '../../examples/alexnet_train_iter_470000'; - %is_init = caffe('is_init'); - %display([' (before calling init) caffe is init? = ' num2str(is_init)]); - % init caffe network (spews logging info) caffe('init', model_def_file, model_file); - %is_init = caffe('is_init'); - %display([' (after calling init) caffe is init? = ' num2str(is_init)]); - % set to use GPU or CPU if exist('use_gpu', 'var') && use_gpu caffe('set_mode_gpu'); @@ -55,12 +49,15 @@ pyra_params.feat_minWidth = 1; pyra_params.feat_minHeight = 1; - pyra = caffe('convnet_featpyramid', imfn, pyra_params ); % call with parameters ... + pyra = convnet_featpyramid(imfn, pyra_params); + %pyra = caffe('convnet_featpyramid', imfn, pyra_params ); % call with parameters ... % pyra = caffe('convnet_featpyramid', imfn ); % ... or with no parameters %keyboard %visualize one scale: colormap(gray); - imagesc(squeeze(sum(pyra.feat{1}, 1))); + %imagesc(squeeze(sum(pyra.feat{1}, 1))); + imagesc(squeeze(sum(pyra.feat{1}, 3))); +keyboard From 41b3e9b937ccb1afe1a9102808aa7527882f4c77 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 20 Feb 2014 18:03:12 -0800 Subject: [PATCH 79/92] remove 'keyboard' call --- matlab/caffe/featpyramid_matcaffe_demo.m | 1 - 1 file changed, 1 deletion(-) diff --git a/matlab/caffe/featpyramid_matcaffe_demo.m b/matlab/caffe/featpyramid_matcaffe_demo.m index dc2cc22b571..13fd81ea325 100644 --- a/matlab/caffe/featpyramid_matcaffe_demo.m +++ b/matlab/caffe/featpyramid_matcaffe_demo.m @@ -59,5 +59,4 @@ %imagesc(squeeze(sum(pyra.feat{1}, 1))); imagesc(squeeze(sum(pyra.feat{1}, 3))); -keyboard From 1b634f859156b34d1c56fb10569c07e26beb7cfa Mon Sep 17 00:00:00 2001 From: forresti Date: Sat, 22 Feb 2014 16:09:32 -0800 Subject: [PATCH 80/92] automating pascal evaluation, and setting up feature caching --- matlab/caffe/convnet_featpyramid_cache.m | 77 ++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 matlab/caffe/convnet_featpyramid_cache.m diff --git a/matlab/caffe/convnet_featpyramid_cache.m b/matlab/caffe/convnet_featpyramid_cache.m new file mode 100644 index 00000000000..ec20b5828d7 --- /dev/null +++ b/matlab/caffe/convnet_featpyramid_cache.m @@ -0,0 +1,77 @@ + +% wrapper for DenseNet convnet_pyramid. +% provides some extra output params that you wouldn't get with caffe('convnet_featpyramid', ...) +% this 'cache' verison enables precomputing features once (not once per pascal category... REALLY ONCE.) + +% YOU MUST CALL caffe('init', ...) BEFORE RUNNING THIS. +function pyra = convnet_featpyramid(imgFname, pyra_params) + + %set defaults for params not passed by user + if( ~exist('pyra_params') || ~isfield(pyra_params, 'interval') ) + pyra_params.interval = 5; + end + if( ~exist('pyra_params') || ~isfield(pyra_params, 'img_padding') ) + pyra_params.img_padding = 16; + end + + %save the user's minWidth and minHeight (if it exists) + if( exist('pyra_params') && isfield(pyra_params, 'feat_minWidth') ) + local_pyra_params.feat_minWidth = pyra_params.feat_minWidth; + end + if( exist('pyra_params') && isfield(pyra_params, 'feat_minHeight') ) + local_pyra_params.feat_minHeight = pyra_params.feat_minHeight; + end + + %for 'cache' version, we compute all scales, then prune the too-small ones in Matlab. + pyra_params.feat_minWidth = 1; + pyra_params.feat_minHeight = 1; + + % compute the pyramid: + pyra = caffe('convnet_featpyramid', imgFname, pyra_params); + + % add DPM-style fields: + pyra.sbin = 16; + pyra.padx = pyra.feat_padx; % for DPM conventions + pyra.pady = pyra.feat_pady; + pyra.num_levels = length(pyra.scales); + pyra.valid_levels = true(pyra.num_levels, 1); + + pyra.imsize = [pyra.imheight pyra.imwidth]; + pyra.feat = permute_feat(pyra.feat); % [d h w] -> [h w d] + pyra.scales = double(pyra.scales); %get_detection_trees prefers double + + pyra = prune_small_scales(pyra, local_pyra_params); +end + +% input: pyra.feat{:}, with dims [d h w] +% output: pyra.feat{:}, with dims [h w d] +function feat = permute_feat(feat) + for featIdx = 1:length(feat) + feat{featIdx} = permute( feat{featIdx}, [2 3 1] ); + end +end + +% needs feat_minHeight and feat_minWidth to be defined in pyra_params. +% prune too-small scales +function pyra = prune_small_scales(pyra, pyra_params) + + if( ~exist('pyra_params') || ~isfield(pyra_params, 'feat_minWidth') ) + return; + end + if( ~exist('pyra_params') || ~isfield(pyra_params, 'feat_minHeight') ) + return; + end + + num_scales = length(pyra.scales); + + for scaleIdx = 1:num_scales + [h w d] = size(pyra.feat{scaleIdx}); + if (h < pyra_params.feat_minHeight) || (w < pyra_params.feat_minWidth) + %found a scale that's too small. prune it. + pyra.valid_levels(scaleIdx) = false; + pyra.feat{scaleIdx} = []; %clear the too-small scale, just to be safe. + end + end +end + + From ea449b1e4006e8148d4ff4c303f69de64be7235d Mon Sep 17 00:00:00 2001 From: forresti Date: Sat, 22 Feb 2014 18:08:38 -0800 Subject: [PATCH 81/92] fleshing out cached feature functionality --- matlab/caffe/convnet_featpyramid_cache.m | 67 ++++++++++++++++++------ 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/matlab/caffe/convnet_featpyramid_cache.m b/matlab/caffe/convnet_featpyramid_cache.m index ec20b5828d7..2c0ce89d49c 100644 --- a/matlab/caffe/convnet_featpyramid_cache.m +++ b/matlab/caffe/convnet_featpyramid_cache.m @@ -3,8 +3,10 @@ % provides some extra output params that you wouldn't get with caffe('convnet_featpyramid', ...) % this 'cache' verison enables precomputing features once (not once per pascal category... REALLY ONCE.) +% to enable caching, you simply define 'pyra_params.feature_dir' + % YOU MUST CALL caffe('init', ...) BEFORE RUNNING THIS. -function pyra = convnet_featpyramid(imgFname, pyra_params) +function pyra = convnet_featpyramid(imgFname, pyra_params, feature_dir) %set defaults for params not passed by user if( ~exist('pyra_params') || ~isfield(pyra_params, 'interval') ) @@ -22,27 +24,57 @@ local_pyra_params.feat_minHeight = pyra_params.feat_minHeight; end - %for 'cache' version, we compute all scales, then prune the too-small ones in Matlab. - pyra_params.feat_minWidth = 1; - pyra_params.feat_minHeight = 1; + % only use caching if user provided pyra_params.feature_dir. + if( exist('feature_dir') == 1 ) % ==1 means 'exists in workspace' + useCache = true; + [path basename ext] = fileparts(imgFname); + cache_location = [feature_dir '/' basename '.mat']; + pyra = try_cache(imgFname, pyra_params, cache_location); %returns [] if cached object does not exist + else + useCache = false; + cache_location = ''; + pyra = []; + end + + if isempty(pyra) + %for 'cache' version, we compute all scales, then prune the too-small ones in Matlab. + pyra_params.feat_minWidth = 1; + pyra_params.feat_minHeight = 1; - % compute the pyramid: - pyra = caffe('convnet_featpyramid', imgFname, pyra_params); + % compute the pyramid: + pyra = caffe('convnet_featpyramid', imgFname, pyra_params); - % add DPM-style fields: - pyra.sbin = 16; - pyra.padx = pyra.feat_padx; % for DPM conventions - pyra.pady = pyra.feat_pady; - pyra.num_levels = length(pyra.scales); - pyra.valid_levels = true(pyra.num_levels, 1); + % add DPM-style fields: + pyra.sbin = 16; + pyra.padx = pyra.feat_padx; % for DPM conventions + pyra.pady = pyra.feat_pady; + pyra.num_levels = length(pyra.scales); + pyra.valid_levels = true(pyra.num_levels, 1); - pyra.imsize = [pyra.imheight pyra.imwidth]; - pyra.feat = permute_feat(pyra.feat); % [d h w] -> [h w d] - pyra.scales = double(pyra.scales); %get_detection_trees prefers double + pyra.imsize = [pyra.imheight pyra.imwidth]; + pyra.feat = permute_feat(pyra.feat); % [d h w] -> [h w d] + pyra.scales = double(pyra.scales); %get_detection_trees prefers double + pyra.im = imgFname; + + if useCache == true + save(cache_location, 'pyra'); + end + end pyra = prune_small_scales(pyra, local_pyra_params); end +function pyra = try_cache(imgFname, pyra_params, cache_location) + try + load(cache_location); %contains pyra + assert( exist('pyra') == 1 ); %make sure we actually loaded the pyramid. + assert( strcmp(pyra.im, imgFname) == 1 ) %make sure we got the right pyramid + display(' found cached features'); + catch + pyra = []; + end +end + % input: pyra.feat{:}, with dims [d h w] % output: pyra.feat{:}, with dims [h w d] function feat = permute_feat(feat) @@ -63,15 +95,18 @@ end num_scales = length(pyra.scales); - + num_pruned = 0; + for scaleIdx = 1:num_scales [h w d] = size(pyra.feat{scaleIdx}); if (h < pyra_params.feat_minHeight) || (w < pyra_params.feat_minWidth) %found a scale that's too small. prune it. pyra.valid_levels(scaleIdx) = false; pyra.feat{scaleIdx} = []; %clear the too-small scale, just to be safe. + num_pruned = num_pruned + 1; end end + display([' had to remove last ' int2str(num_pruned) ' scales, because they were smaller than the minimum that you specified in (feat_minWidth, feat_minHeight)']) end From 4db11fa2e819d8facc97782fec2824cd27d58966 Mon Sep 17 00:00:00 2001 From: forresti Date: Tue, 4 Mar 2014 01:06:29 -0800 Subject: [PATCH 82/92] various cpu mode tweaks --- Makefile | 2 +- matlab/caffe/convnet_featpyramid_cache.m | 5 +++++ python/caffe/featpyramid_demo.py | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4573a4affe9..31cf9f97613 100644 --- a/Makefile +++ b/Makefile @@ -165,7 +165,7 @@ py: init $(STATIC_NAME) $(PY$(PROJECT)_SRC) $(PROTO_GEN_PY) $(STITCHPYRAMID_SO) mat$(PROJECT): mat -mat: init $(STATIC_NAME) $(MAT$(PROJECT)_SRC) +mat: init $(STATIC_NAME) $(MAT$(PROJECT)_SRC) $(STITCHPYRAMID_SO) $(MATLAB_DIR)/bin/mex -g $(MAT$(PROJECT)_SRC) $(STATIC_NAME) \ CXXFLAGS="\$$CXXFLAGS $(CXXFLAGS) $(WARNINGS)" -I./python/caffe \ CXXLIBS="\$$CXXLIBS $(LDFLAGS)" -L./src/stitch_pyramid -lPyramidStitcher \ diff --git a/matlab/caffe/convnet_featpyramid_cache.m b/matlab/caffe/convnet_featpyramid_cache.m index 2c0ce89d49c..d282e8eb511 100644 --- a/matlab/caffe/convnet_featpyramid_cache.m +++ b/matlab/caffe/convnet_featpyramid_cache.m @@ -19,9 +19,13 @@ %save the user's minWidth and minHeight (if it exists) if( exist('pyra_params') && isfield(pyra_params, 'feat_minWidth') ) local_pyra_params.feat_minWidth = pyra_params.feat_minWidth; + else + local_pyra_params.feat_minWidth = 1; end if( exist('pyra_params') && isfield(pyra_params, 'feat_minHeight') ) local_pyra_params.feat_minHeight = pyra_params.feat_minHeight; + else + local_pyra_params.feat_minHeight = 1; end % only use caching if user provided pyra_params.feature_dir. @@ -103,6 +107,7 @@ %found a scale that's too small. prune it. pyra.valid_levels(scaleIdx) = false; pyra.feat{scaleIdx} = []; %clear the too-small scale, just to be safe. + pyra.scales(scaleIdx) = NaN; num_pruned = num_pruned + 1; end end diff --git a/python/caffe/featpyramid_demo.py b/python/caffe/featpyramid_demo.py index eca0dc791ca..eaa88c73c15 100644 --- a/python/caffe/featpyramid_demo.py +++ b/python/caffe/featpyramid_demo.py @@ -61,11 +61,14 @@ def test_featpyramid_allScales(caffenet, imgFname): imgFname = './imagenet/pascal_009959.jpg' model_def = './imagenet/imagenet_rcnn_batch_1_input_2000x2000_output_conv5.prototxt' pretrained_model = '../../examples/alexnet_train_iter_470000' - use_gpu = True + use_gpu = False + #use_gpu = True caffenet = caffe.CaffeNet(model_def, pretrained_model) caffenet.set_phase_test() if use_gpu: caffenet.set_mode_gpu() + else: + caffenet.set_mode_cpu() test_featpyramid_allScales(caffenet, imgFname) From cd364b2f39541c090bf6e5a9541cbef1d072fde2 Mon Sep 17 00:00:00 2001 From: forresti Date: Sun, 2 Mar 2014 16:28:44 -0800 Subject: [PATCH 83/92] sped stitch_pyramid up a bit (maybe 2x?) by avoiding calls to uninlined image.bits(). --- src/stitch_pyramid/JPEGImage.cpp | 3 ++- src/stitch_pyramid/JPEGPyramid.cpp | 26 ++++++++++++---------- src/stitch_pyramid/test_stitch_pyramid.cpp | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/stitch_pyramid/JPEGImage.cpp b/src/stitch_pyramid/JPEGImage.cpp index 4e4d26719f5..4ac7328e43b 100644 --- a/src/stitch_pyramid/JPEGImage.cpp +++ b/src/stitch_pyramid/JPEGImage.cpp @@ -62,12 +62,13 @@ void JPEGImage::fill_with_imagenet_mean(){ int height = this->height(); int width = this->width(); int depth = this->depth(); + uint8_t* imagePtr = this->bits(); for (int ch = 0; ch < depth; ch++){ uint8_t ch_mean = (uint8_t)IMAGENET_MEAN_RGB[ch]; for (int y = 0; y < height; y++){ for (int x = 0; x < width; x++){ - this->bits()[y*width*depth + x*depth + ch] = ch_mean; + imagePtr[y*width*depth + x*depth + ch] = ch_mean; //this->bits()[y*width*depth + x*depth + ch] = (uint8_t)uniform_distribution(0, 255); } } diff --git a/src/stitch_pyramid/JPEGPyramid.cpp b/src/stitch_pyramid/JPEGPyramid.cpp index 201c5e5963a..70817e028d7 100644 --- a/src/stitch_pyramid/JPEGPyramid.cpp +++ b/src/stitch_pyramid/JPEGPyramid.cpp @@ -70,42 +70,44 @@ void JPEGPyramid::AvgLerpPad(JPEGImage & image){ assert( padx_ == pady_ ); // corner padding assumes this (for now) float corner_lerp[padx_+1]; + uint8_t* imagePtr = image.bits(); + //top, bottom, left, right for(int ch=0; ch<3; ch++){ float avgPx = IMAGENET_MEAN_RGB[ch]; for(int x=padx_; x < width-padx_; x++){ //top - currPx = image.bits()[pady_*width*depth + x*depth + ch]; + currPx = imagePtr[pady_*width*depth + x*depth + ch]; linear_interp(currPx, avgPx, pady_+1, top_lerp); //populate top_lerp for(int y=0; y Date: Mon, 3 Mar 2014 23:13:26 -0800 Subject: [PATCH 84/92] tweaks to model and training script --- matlab/caffe/matcaffe.cpp | 5 +++-- python/caffe/featpyramid_demo.py | 1 - python/caffe/pycaffe.cpp | 31 ++++++++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index 0c6abcd0dc0..dc6511a1a87 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -287,7 +287,8 @@ p_vect_float JPEGImage_to_p_float( JPEGImage &jpeg ){ uint32_t const ret_sz = sz_from_dims( 4U, dims ); p_vect_float ret = make_p_vect_float( ret_sz ); - + uint8_t* jpegPtr = jpeg.bits(); + //copy jpeg into jpeg_float_npy for(int ch_src=0; ch_srcsize()); - ret->at(rix) = jpeg.bits()[y*width*depth + x*depth + ch_src] - ch_mean; + ret->at(rix) = jpegPtr[y*width*depth + x*depth + ch_src] - ch_mean; } } } diff --git a/python/caffe/featpyramid_demo.py b/python/caffe/featpyramid_demo.py index eaa88c73c15..9cee5f1c3f5 100644 --- a/python/caffe/featpyramid_demo.py +++ b/python/caffe/featpyramid_demo.py @@ -10,7 +10,6 @@ #import gflags import time import caffe -import time #for visualization, can be removed easily: from matplotlib import cm, pyplot diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index bd5d562d171..d985bde7c56 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -7,6 +7,7 @@ #include "boost/python.hpp" #include "boost/python/suite/indexing/vector_indexing_suite.hpp" +#include #include "numpy/arrayobject.h" #include // NOLINT(build/include_order) @@ -35,6 +36,13 @@ using boost::python::handle; using boost::python::vector_indexing_suite; +//TODO: remove... or agree on a good timer. +double read_timer_forPycaffe(){ + struct timeval start; + gettimeofday( &start, NULL ); + return (double)((start.tv_sec) + 1.0e-6 * (start.tv_usec)); //in seconds +} + // wrap shared_ptr > in a class that we construct in C++ and pass // to Python class CaffeBlob { @@ -246,16 +254,18 @@ struct CaffeNet { PyArrayObject* jpeg_float_npy = (PyArrayObject*)PyArray_New( &PyArray_Type, 4, dims, NPY_FLOAT, 0, 0, 0, 0, 0 ); //numpy malloc + uint8_t* jpegPtr = jpeg.bits(); + //copy jpeg into jpeg_float_npy for(int ch_src=0; ch_srcinput_blobs()[0]->num() == 1); //for now, one plane at a time.) //TODO: verify/assert that top-upsampled version of input img fits within planeDim - Patchwork patchwork = stitch_pyramid(file, img_minWidth, img_minHeight, params.img_padding, params.interval, planeDim); +double start_patchwork = read_timer_forPycaffe(); + Patchwork patchwork = stitch_pyramid(file, img_minWidth, img_minHeight, params.img_padding, params.interval, planeDim); +double time_patchwork = read_timer_forPycaffe() - start_patchwork; +printf(" patchwork: %f sec \n", time_patchwork); + int nbPlanes = patchwork.planes_.size(); boost::python::list blobs_bottom; //input buffer(s) for Caffe::Forward @@ -365,7 +379,12 @@ struct CaffeNet { //prep input data for Caffe feature extraction for(int planeID=0; planeID((PyObject*)currPlane_npy)); //numpy -> wrap in boost boost::python::list blobs_bottom_tmp; //input to Caffe::Forward blobs_bottom_tmp.append(currPlane_npy_boost); //put the output array in list [list length = 1, because batchsize = 1] @@ -378,14 +397,20 @@ struct CaffeNet { blobs_top_tmp.append(resultPlane_npy_boost); //put the output array in list [list length = 1, because batchsize = 1] blobs_top.append(resultPlane_npy_boost); //for long-term keeping (return a list that might be longer than 1) +double start_forward = read_timer_forPycaffe(); Forward(blobs_bottom_tmp, blobs_top_tmp); //lists of blobs... bottom[0]=curr input planes, top_tmp[0]=curr output descriptors +double time_forward = read_timer_forPycaffe() - start_forward; +printf(" forward plane: %f sec \n\n", time_forward); } printf("\n\n in pycaffe.cpp extract_featpyramid(). planeDim=%d\n", planeDim); +//double start_unstitch = read_timer_forPycaffe(); vector scaleLocations = unstitch_pyramid_locations(patchwork, sbin); boost::python::list unstitched_features = unstitch_planes(scaleLocations, blobs_top, resultDepth); boost::python::object scales_npy_boost = get_scales_boost(patchwork); +//double time_unstitch = read_timer_forPycaffe() - start_unstitch; +//printf(" unstitch planes: %f sec \n", time_unstitch); boost::python::dict d; //d["blobs_bottom"] = blobs_bottom; //for debugging -- stitched pyra in RGB From 8e8c3a0223ce7866ef4d360089c1c3fbf11cb600 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 13 Mar 2014 12:03:27 -0700 Subject: [PATCH 85/92] less restrictive check on filename --- matlab/caffe/convnet_featpyramid_cache.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/matlab/caffe/convnet_featpyramid_cache.m b/matlab/caffe/convnet_featpyramid_cache.m index d282e8eb511..390a2839cda 100644 --- a/matlab/caffe/convnet_featpyramid_cache.m +++ b/matlab/caffe/convnet_featpyramid_cache.m @@ -6,8 +6,7 @@ % to enable caching, you simply define 'pyra_params.feature_dir' % YOU MUST CALL caffe('init', ...) BEFORE RUNNING THIS. -function pyra = convnet_featpyramid(imgFname, pyra_params, feature_dir) - +function pyra = convnet_featpyramid_cache(imgFname, pyra_params, feature_dir) %set defaults for params not passed by user if( ~exist('pyra_params') || ~isfield(pyra_params, 'interval') ) pyra_params.interval = 5; @@ -72,7 +71,11 @@ try load(cache_location); %contains pyra assert( exist('pyra') == 1 ); %make sure we actually loaded the pyramid. - assert( strcmp(pyra.im, imgFname) == 1 ) %make sure we got the right pyramid + + [path basename_gold ext] = fileparts(imgFname); + [path basename_input ext] = fileparts(pyra.im); + assert( strcmp(basename_input, basename_gold) == 1 ) %make sure we got the right pyramid + %assert( strcmp(pyra.im, imgFname) == 1 ) %make sure we got the right pyramid display(' found cached features'); catch pyra = []; From 25a399dddb716ea4d4499c55a6b04b7073ca18f2 Mon Sep 17 00:00:00 2001 From: forresti Date: Thu, 13 Mar 2014 12:07:36 -0700 Subject: [PATCH 86/92] pyramid padding calculation --- matlab/caffe/convnet_featpyramid.m | 2 +- matlab/caffe/get_featureSlice.m | 7 ++----- matlab/caffe/matcaffe.cpp | 7 +++++-- python/caffe/pycaffe.cpp | 4 ++-- src/stitch_pyramid/PyramidStitcher.cpp | 1 + 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/matlab/caffe/convnet_featpyramid.m b/matlab/caffe/convnet_featpyramid.m index fb8a4f4abba..9e155227865 100644 --- a/matlab/caffe/convnet_featpyramid.m +++ b/matlab/caffe/convnet_featpyramid.m @@ -23,7 +23,7 @@ pyra = caffe('convnet_featpyramid', imgFname, pyra_params); % add DPM-style fields: - pyra.sbin = 16; + %pyra.sbin = 16; pyra.padx = pyra.feat_padx; % for DPM conventions pyra.pady = pyra.feat_pady; pyra.num_levels = length(pyra.scales); diff --git a/matlab/caffe/get_featureSlice.m b/matlab/caffe/get_featureSlice.m index 275594480fb..2b61597aa40 100644 --- a/matlab/caffe/get_featureSlice.m +++ b/matlab/caffe/get_featureSlice.m @@ -6,9 +6,6 @@ % (could pass in image_size ... though we currently don't use it, and imsize is typically in pyra) function [featureSlice, scaleIdx, roundedBox_in_px] = get_featureSlice(pyra, bbox, templateSize) -%experiment: -%pyra.sbin = 8; - %1. tweak bbox to match the aspect ratio of templateSize %bbox = match_aspect_ratio(bbox, templateSize); @@ -16,8 +13,8 @@ bbox_desc = bbox_mult(bbox, 1.0/single(pyra.sbin)); % unscaled image -> unscaled descriptor coords. bbox_desc_dim = [bbox_desc.y2 - bbox_desc.y1, bbox_desc.x2 - bbox_desc.x1]; %bbox dim in the space of scale=1 descriptors. - %bbox_desc_scale = templateSize / bbox_desc_dim; %scale factor from (scale=1) to a scale where bbox fits in templateSize - bbox_desc_scale = (templateSize-1) / bbox_desc_dim; %pretend that template size is slightly smaller... so featureSlice will be slightly outside orig bbox + bbox_desc_scale = templateSize / bbox_desc_dim; %scale factor from (scale=1) to a scale where bbox fits in templateSize + %bbox_desc_scale = (templateSize-1) / bbox_desc_dim; %pretend that template size is slightly smaller... so featureSlice will be slightly outside orig bbox scale_to_use = mean(bbox_desc_scale); %avg of scale factors for x and y dims. [scale_to_use, scaleIdx] = findNearestScale(scale_to_use, pyra.scales); %best precomputed approx of scale_to_use diff --git a/matlab/caffe/matcaffe.cpp b/matlab/caffe/matcaffe.cpp index dc6511a1a87..1e9a59f3b3e 100644 --- a/matlab/caffe/matcaffe.cpp +++ b/matlab/caffe/matcaffe.cpp @@ -441,13 +441,16 @@ static void convnet_featpyramid(MEX_ARGS) { float * const scale_ptr = (float*)(mxGetData(scale)); for( uint32_t r = 0; r < ret_rows; ++r ) { scale_ptr[r] = patchwork.scales_[r]; } + int feat_padx = params.img_padding / sbin; + int feat_pady = params.img_padding / sbin; + mxArray * ret = mxCreateStructMatrix( 1, 1, sizeof(fnames)/sizeof(char*), fnames ); // see fnames for field names mxSetFieldByNumber( ret, 0, 0, scale ); mxSetFieldByNumber( ret, 0, 1, feats ); mxSetFieldByNumber( ret, 0, 2, u32_to_mx( patchwork.imwidth_ ) ); mxSetFieldByNumber( ret, 0, 3, u32_to_mx( patchwork.imheight_ ) ); - mxSetFieldByNumber( ret, 0, 4, u32_to_mx( 1 ) ); - mxSetFieldByNumber( ret, 0, 5, u32_to_mx( 1 ) ); + mxSetFieldByNumber( ret, 0, 4, u32_to_mx( feat_padx ) ); + mxSetFieldByNumber( ret, 0, 5, u32_to_mx( feat_pady ) ); mxSetFieldByNumber( ret, 0, 6, u32_to_mx( sbin ) ); plhs[0] = ret; diff --git a/python/caffe/pycaffe.cpp b/python/caffe/pycaffe.cpp index d985bde7c56..37fd3980852 100644 --- a/python/caffe/pycaffe.cpp +++ b/python/caffe/pycaffe.cpp @@ -419,8 +419,8 @@ printf(" forward plane: %f sec \n\n", time_forward); d["scales"] = scales_npy_boost; d["imwidth"] = patchwork.imwidth_; //input image dims d["imheight"] = patchwork.imheight_; - d["feat_padx"] = 1u; // placeholder - d["feat_pady"] = 1u; // placeholder + d["feat_padx"] = params.img_padding / sbin; + d["feat_pady"] = params.img_padding / sbin; d["sbin"] = sbin; return d; diff --git a/src/stitch_pyramid/PyramidStitcher.cpp b/src/stitch_pyramid/PyramidStitcher.cpp index e06b337489b..1fcc1b8645e 100644 --- a/src/stitch_pyramid/PyramidStitcher.cpp +++ b/src/stitch_pyramid/PyramidStitcher.cpp @@ -28,6 +28,7 @@ Patchwork stitch_pyramid(string file, int img_minWidth, int img_minHeight, } int upsampleFactor = 2; //TODO: make this an input param? + //int upsampleFactor = 3; // Compute the downsample+stitch JPEGPyramid pyramid(image, padding, padding, interval, upsampleFactor); //multiscale DOWNSAMPLE with (padx == pady == padding) From d208df72377ec45021c5f50864ac742105061e9e Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 13 Mar 2014 17:42:54 -0700 Subject: [PATCH 87/92] Makefile: add mkoctfile_mat rule to build .mex file with octave (for the brave) --- Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Makefile b/Makefile index 31cf9f97613..d68ea1a2255 100644 --- a/Makefile +++ b/Makefile @@ -172,6 +172,18 @@ mat: init $(STATIC_NAME) $(MAT$(PROJECT)_SRC) $(STITCHPYRAMID_SO) -o $(MAT$(PROJECT)_SO) @echo +mkoctfile_mat$(PROJECT): mkoctfile_mat + +# CXXFLAGS="-Wall -fpic -O2" mkoctfile --mex matlab/caffe/matcaffe.cpp libcaffe.a -pthread -I/usr/local/include -I/usr/include/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I./src -I./include -I/usr/local/cuda/include -I/opt/intel/mkl/include -Wall -L/usr/lib -L/usr/local/lib -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib -L/opt/intel/mkl/lib -L/opt/intel/mkl/lib/intel64 -lcudart -lcublas -lcurand -lprotobuf -lopencv_core -lopencv_highgui -lglog -lmkl_rt -lmkl_intel_thread -lleveldb -lsnappy -lpthread -lboost_system -lopencv_imgproc -L/home/moskewcz/git_work/caffe/python/caffe/stitch_pyramid -lPyramidStitcher -I./python/caffe -o matlab/caffe/caffe + + +mkoctfile_mat: init $(STATIC_NAME) $(MAT$(PROJECT)_SRC) $(STITCHPYRAMID_SO) + CXXFLAGS="$$CXXFLAGS $(CXXFLAGS)" \ + DL_LDFLAGS="$$DL_LDFLAGS $(SHARED_LDFLAGS)" \ + LFLAGS="$$LFLAGS $(LDFLAGS) -L./src/stitch_pyramid -lPyramidStitcher" \ + mkoctfile --mex -g -v $(MAT$(PROJECT)_SRC) $(STATIC_NAME) -o $(MAT$(PROJECT)_SO) + @echo + $(NAME): init $(PROTO_OBJS) $(OBJS) $(CXX) -shared -o $(NAME) $(OBJS) $(CXXFLAGS) $(LDFLAGS) $(WARNINGS) @echo From d342fca9684b009f359a464eadc703285ab16e90 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Thu, 13 Mar 2014 17:44:00 -0700 Subject: [PATCH 88/92] fix Makefile to use $(SHARED_LDFLAGS) instead of a hard-coded '-shared' for building pycaffe --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d68ea1a2255..8cce7bfe514 100644 --- a/Makefile +++ b/Makefile @@ -159,7 +159,7 @@ $(STITCHPYRAMID_SO): $(STITCHPYRAMID_HDRS) $(STITCHPYRAMID_SRC) py$(PROJECT): py py: init $(STATIC_NAME) $(PY$(PROJECT)_SRC) $(PROTO_GEN_PY) $(STITCHPYRAMID_SO) - $(CXX) -shared -o $(PY$(PROJECT)_SO) $(PY$(PROJECT)_SRC) -L./src/stitch_pyramid -lPyramidStitcher -I./src/stitch_pyramid \ + $(CXX) $(SHARED_LDFLAGS) -o $(PY$(PROJECT)_SO) $(PY$(PROJECT)_SRC) -L./src/stitch_pyramid -lPyramidStitcher -I./src/stitch_pyramid \ $(STATIC_NAME) $(CXXFLAGS) $(PYTHON_LDFLAGS) @echo From 3c85b8f88f67aec3d0026c3d517699c357daf721 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Tue, 25 Mar 2014 17:19:52 -0700 Subject: [PATCH 89/92] add DENSENET_MERGE_TODO and add DenseNet header to README.md --- DENSENET_MERGE_TODO | 15 +++++++++++++++ README.md | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 DENSENET_MERGE_TODO diff --git a/DENSENET_MERGE_TODO b/DENSENET_MERGE_TODO new file mode 100644 index 00000000000..3a2541a64f1 --- /dev/null +++ b/DENSENET_MERGE_TODO @@ -0,0 +1,15 @@ + +list of the issues blocking the merge of the DenseNet feature branch: + +- critical +-- replacement of GPL'd code (including removal from history) +-- update build process / Makefile to match current practice +-- tests +-- trivial: remove DenseNet README.md header +-- trivial: remove this todo file + +- unclear neccessity, semantics, and/or priority +-- general cleanup of commit sequence (probably mostly squashing) +-- input interface changes (i.e. jpeg filname as input -> ?) +-- output interface changes (?, but probably something: image support size, multiple layer output, alignment, etc.) +-- if still reading image files after any iface changes and removal of GPL code, use XX instead of YY diff --git a/README.md b/README.md index 586c412901e..eb0ea7f05cb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ +# -- WARNING: THIS IS AN FORK/FEATURE BRANCH OF [CAFFE](http://github.com/BVLC/caffe) (PR PENDING). -- +## DenseNet + +[DenseNet: Efficient Computation of Deep ConvNet Feature Pyramids](http://arxiv.org/densenet_paper_url_here) +Forrest Iandola,Matt Moskewicz,Sergey Karayev,Ross Girshick,Kurt Keutzer,and Trevor Darrell + +Except where noted individual files, all new files / changes in this branch are: +Copyright (c) 2013 Matthew Moskewicz and Forrest Iandola + + +## Original Caffe README.md follows + [Caffe: Convolutional Architecture for Fast Feature Extraction](http://caffe.berkeleyvision.org) Created by [Yangqing Jia](http://daggerfs.com), UC Berkeley EECS department. From bd3dfa8157362aaf98709f9b01268b789368c558 Mon Sep 17 00:00:00 2001 From: Matthew Moskewicz Date: Tue, 8 Apr 2014 12:10:22 -0700 Subject: [PATCH 90/92] update README.md with DenseNet arXiv paper link; fix/polish attribution/license note there too. --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eb0ea7f05cb..2f79f9707ef 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ # -- WARNING: THIS IS AN FORK/FEATURE BRANCH OF [CAFFE](http://github.com/BVLC/caffe) (PR PENDING). -- ## DenseNet -[DenseNet: Efficient Computation of Deep ConvNet Feature Pyramids](http://arxiv.org/densenet_paper_url_here) -Forrest Iandola,Matt Moskewicz,Sergey Karayev,Ross Girshick,Kurt Keutzer,and Trevor Darrell +[DenseNet: Implementing Efficient ConvNet Descriptor Pyramids](http://arxiv.org/abs/1404.1869) +Forrest Iandola, Matt Moskewicz, Sergey Karayev, Ross Girshick, Trevor Darrell, and Kurt Keutzer -Except where noted individual files, all new files / changes in this branch are: +Except where noted in individual files, all new code files / changes in this branch are: Copyright (c) 2013 Matthew Moskewicz and Forrest Iandola +and are BSD 2-Clause licensed with the same as the original source (see [LICENSE](LICENSE)). +The two example images are taken from the PASCAL vision benchmark set. ## Original Caffe README.md follows From 87174835cdc3458f4572dd9d3d3d0c62b3f917ba Mon Sep 17 00:00:00 2001 From: Forrest Iandola Date: Tue, 8 Apr 2014 12:58:59 -0700 Subject: [PATCH 91/92] Update README.md Added some DenseNet API documentation. This will probably percolate from this top-level README.md to the caffe.berkeleyvision.org gh-pages. --- README.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2f79f9707ef..096bf7dd8cb 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,73 @@ # -- WARNING: THIS IS AN FORK/FEATURE BRANCH OF [CAFFE](http://github.com/BVLC/caffe) (PR PENDING). -- ## DenseNet -[DenseNet: Implementing Efficient ConvNet Descriptor Pyramids](http://arxiv.org/abs/1404.1869) -Forrest Iandola, Matt Moskewicz, Sergey Karayev, Ross Girshick, Trevor Darrell, and Kurt Keutzer +[DenseNet: Implementing Efficient ConvNet Descriptor Pyramids](http://arxiv.org/abs/1404.1869)
+Forrest Iandola, Matt Moskewicz, Sergey Karayev, Ross Girshick, Trevor Darrell, and Kurt Keutzer.
+Arxiv technical report, April 2014. +Licensing
Except where noted in individual files, all new code files / changes in this branch are: Copyright (c) 2013 Matthew Moskewicz and Forrest Iandola and are BSD 2-Clause licensed with the same as the original source (see [LICENSE](LICENSE)). The two example images are taken from the PASCAL vision benchmark set. +DenseNet APIs in Matlab and Python
+The DenseNet API is fairly similar to the popular `featpyramid.m` HOG extraction API from the [voc-release5 Deformable Parts Model code](https://github.com/rbgirshick/voc-dpm/blob/master/features/featpyramid.m). Our primary API function is called `convnet_featpyramid()`. + +Running DenseNet in Matlab
+`caffe/matlab/caffe/featpyramid_matcaffe_demo.m` is a good example to start with. Or, we can walk through it together here: + +```matlab + %Caffe setup: + model_def_file = 'CAFFE_ROOT/python/caffe/imagenet/imagenet_rcnn_batch_1_input_1100x1100_output_conv5.prototxt' + % NOTE: you'll have to get the pre-trained ILSVRC network + model_file = 'path/to/alexnet_train_iter_470000'; + caffe('init', model_def_file, model_file); + caffe('set_mode_gpu') %CPU mode works too + caffe('set_phase_test') + + %using DenseNet: + image = 'myImage.jpg' %must be JPEG + pyra = convnet_featpyramid(image) +``` + +Running DenseNet in Matlab (advanced users)
+```matlab + % (you need to do Caffe setup first, as shown in above example) + image = 'myImage.jpg' + + %optional parameters (code will still run with incomplete or nonexistant pyra_params): + pyra_params.interval = 5; %octaves per pyramid scale + pyra_params.img_padding = 16 %padding around image (in pixels) + pyra_params.feat_minWidth = 6; %select smallest scale in pyramid (in output feature dimensions) + pyra_params.feat_minHeight = 6; %in output feature dimensions + pyra = convnet_featpyramid(image, pyra_params) + + %taking a look at the output pyramid: + scales: [40x1 double] %resolution of each pyramid scale + feat: {40x1 cell} %descriptors (one cell array per scale) + imwidth: 353 %input image size in pixels + imheight: 500 + feat_padx: 1 %border padding around descriptors (img_padding/sbin) + feat_pady: 1 + sbin: 16 %approx. downsampling factor from pixels to descriptors + padx: 1 %extra copy of feat_pad{x,y}. silly...should remove? + pady: 1 + num_levels: 40 %num scales in pyramid + valid_levels: [40x1 logical] +``` + +Running DenseNet in Python
+The Python API is similar to the Matlab API described above. +`caffe/python/caffe/featpyramid_demo.py` is a good starting point for using DenseNet in Python. + + +Other notes: +- As with many other operations in Caffe, you'll need to download a pretrained Alexnet CNN prior to running our DenseNet demo. +- For most of our default examples, we use the 'Alexnet' network and output descriptors from the conv5 layer. You can adjust these decisions by editing the 'prototxt' files used at setup time. + + ## Original Caffe README.md follows [Caffe: Convolutional Architecture for Fast Feature Extraction](http://caffe.berkeleyvision.org) From cbc7d8c4664d74935a65dc7fbcf0835d327a6646 Mon Sep 17 00:00:00 2001 From: forresti Date: Fri, 11 Apr 2014 11:59:34 -0700 Subject: [PATCH 92/92] remove relics of hardcoded sbin --- matlab/caffe/convnet_featpyramid.m | 1 - matlab/caffe/convnet_featpyramid_cache.m | 1 - 2 files changed, 2 deletions(-) diff --git a/matlab/caffe/convnet_featpyramid.m b/matlab/caffe/convnet_featpyramid.m index 9e155227865..66e568bfa14 100644 --- a/matlab/caffe/convnet_featpyramid.m +++ b/matlab/caffe/convnet_featpyramid.m @@ -23,7 +23,6 @@ pyra = caffe('convnet_featpyramid', imgFname, pyra_params); % add DPM-style fields: - %pyra.sbin = 16; pyra.padx = pyra.feat_padx; % for DPM conventions pyra.pady = pyra.feat_pady; pyra.num_levels = length(pyra.scales); diff --git a/matlab/caffe/convnet_featpyramid_cache.m b/matlab/caffe/convnet_featpyramid_cache.m index 390a2839cda..2114044c7e2 100644 --- a/matlab/caffe/convnet_featpyramid_cache.m +++ b/matlab/caffe/convnet_featpyramid_cache.m @@ -48,7 +48,6 @@ pyra = caffe('convnet_featpyramid', imgFname, pyra_params); % add DPM-style fields: - pyra.sbin = 16; pyra.padx = pyra.feat_padx; % for DPM conventions pyra.pady = pyra.feat_pady; pyra.num_levels = length(pyra.scales);