├── .gitignore ├── LICENSE ├── README.md ├── deep-learning-datasets-maker ├── Makefile ├── README.html ├── README.txt ├── __init__.py ├── help │ ├── Makefile │ ├── make.bat │ └── source │ │ ├── conf.py │ │ └── index.rst ├── i18n │ └── af.ts ├── icon.png ├── metadata.txt ├── pb_tool.cfg ├── plugin_upload.py ├── pylintrc ├── resources.py ├── resources.qrc ├── scripts │ ├── compile-strings.sh │ ├── run-env-linux.sh │ └── update-strings.sh ├── split_rs_data.py ├── split_rs_data_dialog.py ├── split_rs_data_dialog_base.ui ├── test │ ├── __init__.py │ ├── qgis_interface.py │ ├── tenbytenraster.asc │ ├── tenbytenraster.asc.aux.xml │ ├── tenbytenraster.keywords │ ├── tenbytenraster.lic │ ├── tenbytenraster.prj │ ├── tenbytenraster.qml │ ├── test_init.py │ ├── test_qgis_environment.py │ ├── test_resources.py │ ├── test_split_rs_data_dialog.py │ ├── test_translations.py │ └── utilities.py └── utils │ ├── COCO │ ├── __init__.py │ ├── pycococreatortools │ │ ├── __init__.py │ │ └── pycococreatortools.py │ ├── shape_to_coco.py │ ├── slice_dataset.py │ ├── tif_process.py │ └── visualize_coco.py │ ├── __init__.py │ ├── checkPIP.py │ ├── color.txt │ ├── intSegGDAL.py │ ├── paddlepaddle_split_dataset_list.py │ ├── rasterize.py │ └── splitting.py ├── docs └── img │ ├── logo.png │ └── logo2.png └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | .qt_for_python/ 3 | .vscode/settings.json 4 | data/ 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 
2 |
3 |

4 |

Deep Learning Dataset Maker

5 |

We ❤️ Open Source

6 |
7 |
8 | 9 | [![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-380/) [![QGIS 3.16.13](https://img.shields.io/badge/qgis-3.16.13-green.svg)](https://www.qgis.org/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) ![license](https://img.shields.io/github/license/deepbands/buildseg) ![release](https://img.shields.io/badge/release-v0.2-red.svg) 10 | 11 | ## Deep Learning Datasets Maker is a QGIS plugin to make datasets creation easier for raster and vector data. 12 | Run [QGIS Desktop App (3.18)](https://qgis.org/en/site/) vi BinderHub! Click the button below to launch a server: 13 | 14 | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Youssef-Harby/jupyter-qgis/qgis?urlpath=desktop) 15 | 16 | 17 |

18 | 19 | 20 | 21 |

22 | 23 | ## How to use 24 | 25 | 1. Download and install [QGIS](https://www.qgis.org/en/site/) and clone the repo : 26 | ``` git 27 | git clone git@github.com:deepbands/deep-learning-datasets-maker.git 28 | ``` 29 | 2. Install requirements : 30 | - Enter the folder and install dependent libraries using OSGeo4W shell (Open As Administrator) : 31 | ``` shell 32 | cd deep-learning-datasets-maker 33 | pip install -r requirements.txt 34 | ``` 35 | - Or open OSGeo4W shell as administrator and enter : 36 | ``` shell 37 | pip install Cython scikit-image Pillow pycocotools --user 38 | ``` 39 | 40 | 3. Copy folder named deep-learning-datasets-maker in QGIS configuration folder and choose the plugin from plugin manager in QGIS (If not appeared restart QGIS). 41 | - You can know this folder from QGIS Setting Menu at the top-left of QGIS UI `Settings > User Profiles > Open Active Profile Folder` . 42 | - Go to `python/plugins` then paste the deep-learning-datasets-maker folder. 43 | - Full path should be like : `C:\Users\$USER\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\deep-learning-datasets-maker`. 44 | 45 | 4. Open QGIS, load your raster and vector data then select the output paths for rasterized, images and labels then click `ok`. 46 | 47 | ## TODO 48 | **v0.2** 49 | - [ ] Fix: If vector layer saved in memory not in file, `rasterize` can't work. 50 | - [x] Splitting raster data into equal pieces with [GDAL](https://github.com/OSGeo/gdal) , https://gdal.org/. 51 | - [X] Fix: Splitiing Image Size. 52 | - [x] Rasterize shapefile to raster in the same satellite pixel size and projection. 53 | - [x] Convert 24 or 16 bit raster to 8 bit. 54 | - [x] Export as jpg (for raster) and png (for rasterized shapefile) with GDAL. 55 | - [X] Converted semantic segmentation (0 and 1) to instance segmentation for labels (the original label is 0/255) option, and the result is a single-channel image that uses a palette to color. ![](https://s3.bmp.ovh/imgs/2021/09/008c5b768b7e477a.png) 56 | - [X] PaddlePaddle Train/Val/Testing list text. 57 | - [X] Use GDAL for instance segmentation instead of openCV. 58 | - [X] Support COCO format. 59 | - [X] Update plugin's UI : 60 | - [X] Add new checkbox for other annotations like COCO. 61 | 62 | **v0.3** 63 | - [ ] Fix : raster and vector full path on Linux/macOS (Sometimes cannot gdal/ogr.open from the full path because of forward slash ``/path_to_raster`` and backward slash ``\path_to_raster`` ) 64 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/Makefile: -------------------------------------------------------------------------------- 1 | #/*************************************************************************** 2 | # SplitRSData 3 | # 4 | # tools to handle raster and vector data to split it into small pieces equaled in size for machine learning datasets 5 | # ------------------- 6 | # begin : 2021-12-08 7 | # git sha : $Format:%H$ 8 | # copyright : (C) 2021 by Youssef Harby 9 | # email : youssef_harby@yahoo.com 10 | # ***************************************************************************/ 11 | # 12 | #/*************************************************************************** 13 | # * * 14 | # * This program is free software; you can redistribute it and/or modify * 15 | # * it under the terms of the GNU General Public License as published by * 16 | # * the Free Software Foundation; either version 2 of the License, or * 17 | # * (at your option) any later version. * 18 | # * * 19 | # ***************************************************************************/ 20 | 21 | ################################################# 22 | # Edit the following to match your sources lists 23 | ################################################# 24 | 25 | 26 | #Add iso code for any locales you want to support here (space separated) 27 | # default is no locales 28 | # LOCALES = af 29 | LOCALES = 30 | 31 | # If locales are enabled, set the name of the lrelease binary on your system. If 32 | # you have trouble compiling the translations, you may have to specify the full path to 33 | # lrelease 34 | #LRELEASE = lrelease 35 | #LRELEASE = lrelease-qt4 36 | 37 | 38 | # translation 39 | SOURCES = \ 40 | __init__.py \ 41 | split_rs_data.py split_rs_data_dialog.py 42 | 43 | PLUGINNAME = split_rs_data 44 | 45 | PY_FILES = \ 46 | __init__.py \ 47 | split_rs_data.py split_rs_data_dialog.py 48 | 49 | UI_FILES = split_rs_data_dialog_base.ui 50 | 51 | EXTRAS = metadata.txt icon.png 52 | 53 | EXTRA_DIRS = 54 | 55 | COMPILED_RESOURCE_FILES = resources.py 56 | 57 | PEP8EXCLUDE=pydev,resources.py,conf.py,third_party,ui 58 | 59 | # QGISDIR points to the location where your plugin should be installed. 60 | # This varies by platform, relative to your HOME directory: 61 | # * Linux: 62 | # .local/share/QGIS/QGIS3/profiles/default/python/plugins/ 63 | # * Mac OS X: 64 | # Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins 65 | # * Windows: 66 | # AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins' 67 | 68 | QGISDIR=C:\Users\Youss\AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins 69 | 70 | ################################################# 71 | # Normally you would not need to edit below here 72 | ################################################# 73 | 74 | HELP = help/build/html 75 | 76 | PLUGIN_UPLOAD = $(c)/plugin_upload.py 77 | 78 | RESOURCE_SRC=$(shell grep '^ *@@g;s/.*>//g' | tr '\n' ' ') 79 | 80 | .PHONY: default 81 | default: 82 | @echo While you can use make to build and deploy your plugin, pb_tool 83 | @echo is a much better solution. 84 | @echo A Python script, pb_tool provides platform independent management of 85 | @echo your plugins and runs anywhere. 86 | @echo You can install pb_tool using: pip install pb_tool 87 | @echo See https://g-sherman.github.io/plugin_build_tool/ for info. 88 | 89 | compile: $(COMPILED_RESOURCE_FILES) 90 | 91 | %.py : %.qrc $(RESOURCES_SRC) 92 | pyrcc5 -o $*.py $< 93 | 94 | %.qm : %.ts 95 | $(LRELEASE) $< 96 | 97 | test: compile transcompile 98 | @echo 99 | @echo "----------------------" 100 | @echo "Regression Test Suite" 101 | @echo "----------------------" 102 | 103 | @# Preceding dash means that make will continue in case of errors 104 | @-export PYTHONPATH=`pwd`:$(PYTHONPATH); \ 105 | export QGIS_DEBUG=0; \ 106 | export QGIS_LOG_FILE=/dev/null; \ 107 | nosetests -v --with-id --with-coverage --cover-package=. \ 108 | 3>&1 1>&2 2>&3 3>&- || true 109 | @echo "----------------------" 110 | @echo "If you get a 'no module named qgis.core error, try sourcing" 111 | @echo "the helper script we have provided first then run make test." 112 | @echo "e.g. source run-env-linux.sh ; make test" 113 | @echo "----------------------" 114 | 115 | deploy: compile doc transcompile 116 | @echo 117 | @echo "------------------------------------------" 118 | @echo "Deploying plugin to your .qgis2 directory." 119 | @echo "------------------------------------------" 120 | # The deploy target only works on unix like operating system where 121 | # the Python plugin directory is located at: 122 | # $HOME/$(QGISDIR)/python/plugins 123 | mkdir -p $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 124 | cp -vf $(PY_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 125 | cp -vf $(UI_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 126 | cp -vf $(COMPILED_RESOURCE_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 127 | cp -vf $(EXTRAS) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 128 | cp -vfr i18n $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 129 | cp -vfr $(HELP) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)/help 130 | # Copy extra directories if any 131 | (foreach EXTRA_DIR,(EXTRA_DIRS), cp -R (EXTRA_DIR) (HOME)/(QGISDIR)/python/plugins/(PLUGINNAME)/;) 132 | 133 | 134 | # The dclean target removes compiled python files from plugin directory 135 | # also deletes any .git entry 136 | dclean: 137 | @echo 138 | @echo "-----------------------------------" 139 | @echo "Removing any compiled python files." 140 | @echo "-----------------------------------" 141 | find $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) -iname "*.pyc" -delete 142 | find $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) -iname ".git" -prune -exec rm -Rf {} \; 143 | 144 | 145 | derase: 146 | @echo 147 | @echo "-------------------------" 148 | @echo "Removing deployed plugin." 149 | @echo "-------------------------" 150 | rm -Rf $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 151 | 152 | zip: deploy dclean 153 | @echo 154 | @echo "---------------------------" 155 | @echo "Creating plugin zip bundle." 156 | @echo "---------------------------" 157 | # The zip target deploys the plugin and creates a zip file with the deployed 158 | # content. You can then upload the zip file on http://plugins.qgis.org 159 | rm -f $(PLUGINNAME).zip 160 | cd $(HOME)/$(QGISDIR)/python/plugins; zip -9r $(CURDIR)/$(PLUGINNAME).zip $(PLUGINNAME) 161 | 162 | package: compile 163 | # Create a zip package of the plugin named $(PLUGINNAME).zip. 164 | # This requires use of git (your plugin development directory must be a 165 | # git repository). 166 | # To use, pass a valid commit or tag as follows: 167 | # make package VERSION=Version_0.3.2 168 | @echo 169 | @echo "------------------------------------" 170 | @echo "Exporting plugin to zip package. " 171 | @echo "------------------------------------" 172 | rm -f $(PLUGINNAME).zip 173 | git archive --prefix=$(PLUGINNAME)/ -o $(PLUGINNAME).zip $(VERSION) 174 | echo "Created package: $(PLUGINNAME).zip" 175 | 176 | upload: zip 177 | @echo 178 | @echo "-------------------------------------" 179 | @echo "Uploading plugin to QGIS Plugin repo." 180 | @echo "-------------------------------------" 181 | $(PLUGIN_UPLOAD) $(PLUGINNAME).zip 182 | 183 | transup: 184 | @echo 185 | @echo "------------------------------------------------" 186 | @echo "Updating translation files with any new strings." 187 | @echo "------------------------------------------------" 188 | @chmod +x scripts/update-strings.sh 189 | @scripts/update-strings.sh $(LOCALES) 190 | 191 | transcompile: 192 | @echo 193 | @echo "----------------------------------------" 194 | @echo "Compiled translation files to .qm files." 195 | @echo "----------------------------------------" 196 | @chmod +x scripts/compile-strings.sh 197 | @scripts/compile-strings.sh $(LRELEASE) $(LOCALES) 198 | 199 | transclean: 200 | @echo 201 | @echo "------------------------------------" 202 | @echo "Removing compiled translation files." 203 | @echo "------------------------------------" 204 | rm -f i18n/*.qm 205 | 206 | clean: 207 | @echo 208 | @echo "------------------------------------" 209 | @echo "Removing uic and rcc generated files" 210 | @echo "------------------------------------" 211 | rm $(COMPILED_UI_FILES) $(COMPILED_RESOURCE_FILES) 212 | 213 | doc: 214 | @echo 215 | @echo "------------------------------------" 216 | @echo "Building documentation using sphinx." 217 | @echo "------------------------------------" 218 | cd help; make html 219 | 220 | pylint: 221 | @echo 222 | @echo "-----------------" 223 | @echo "Pylint violations" 224 | @echo "-----------------" 225 | @pylint --reports=n --rcfile=pylintrc . || true 226 | @echo 227 | @echo "----------------------" 228 | @echo "If you get a 'no module named qgis.core' error, try sourcing" 229 | @echo "the helper script we have provided first then run make pylint." 230 | @echo "e.g. source run-env-linux.sh ; make pylint" 231 | @echo "----------------------" 232 | 233 | 234 | # Run pep8 style checking 235 | #http://pypi.python.org/pypi/pep8 236 | pep8: 237 | @echo 238 | @echo "-----------" 239 | @echo "PEP8 issues" 240 | @echo "-----------" 241 | @pep8 --repeat --ignore=E203,E121,E122,E123,E124,E125,E126,E127,E128 --exclude $(PEP8EXCLUDE) . || true 242 | @echo "-----------" 243 | @echo "Ignored in PEP8 check:" 244 | @echo $(PEP8EXCLUDE) 245 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/README.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Plugin Builder Results

4 | 5 | Congratulations! You just built a plugin for QGIS!

6 | 7 |
8 | Your plugin SplitRSData was created in:
9 |   C:/Users/Youss/Documents/pp/New folder/myplugin\split_rs_data 10 |

11 | Your QGIS plugin directory is located at:
12 |   C:/Users/Youss/AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins 13 |

14 |

What's Next

15 |
    16 |
  1. If resources.py is not present in your plugin directory, compile the resources file using pyrcc5 (simply use pb_tool or make if you have automake) 17 |
  2. Optionally, test the generated sources using make test (or run tests from your IDE) 18 |
  3. Copy the entire directory containing your new plugin to the QGIS plugin directory (see Notes below) 19 |
  4. Test the plugin by enabling it in the QGIS plugin manager 20 |
  5. Customize it by editing the implementation file split_rs_data.py 21 |
  6. Create your own custom icon, replacing the default icon.png 22 |
  7. Modify your user interface by opening split_rs_data_dialog_base.ui in Qt Designer 23 |
24 | Notes: 25 |
    26 |
  • You can use pb_tool to compile, deploy, and manage your plugin. Tweak the pb_tool.cfg file included with your plugin as you add files. Install pb_tool using 27 | pip or easy_install. See http://loc8.cc/pb_tool for more information. 28 |
  • You can also use the Makefile to compile and deploy when you 29 | make changes. This requires GNU make (gmake). The Makefile is ready to use, however you 30 | will have to edit it to add addional Python source files, dialogs, and translations. 31 |
32 |
33 |
34 |

35 | For information on writing PyQGIS code, see http://loc8.cc/pyqgis_resources for a list of resources. 36 |

37 |
38 |

39 | ©2011-2019 GeoApt LLC - geoapt.com 40 |

41 | 42 | 43 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/README.txt: -------------------------------------------------------------------------------- 1 | Plugin Builder Results 2 | 3 | Your plugin SplitRSData was created in: 4 | C:/Users/Youss/Documents/pp/New folder/myplugin\split_rs_data 5 | 6 | Your QGIS plugin directory is located at: 7 | C:/Users/Youss/AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins 8 | 9 | What's Next: 10 | 11 | * Copy the entire directory containing your new plugin to the QGIS plugin 12 | directory 13 | 14 | * Compile the resources file using pyrcc5 15 | 16 | * Run the tests (``make test``) 17 | 18 | * Test the plugin by enabling it in the QGIS plugin manager 19 | 20 | * Customize it by editing the implementation file: ``split_rs_data.py`` 21 | 22 | * Create your own custom icon, replacing the default icon.png 23 | 24 | * Modify your user interface by opening SplitRSData_dialog_base.ui in Qt Designer 25 | 26 | * You can use the Makefile to compile your Ui and resource files when 27 | you make changes. This requires GNU make (gmake) 28 | 29 | For more information, see the PyQGIS Developer Cookbook at: 30 | http://www.qgis.org/pyqgis-cookbook/index.html 31 | 32 | (C) 2011-2018 GeoApt LLC - geoapt.com 33 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | SplitRSData 5 | A QGIS plugin 6 | tools to handle raster and vector data to split it into small pieces equaled in size for machine learning datasets 7 | Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ 8 | ------------------- 9 | begin : 2021-12-08 10 | copyright : (C) 2021 by Youssef Harby 11 | email : youssef_harby@yahoo.com 12 | git sha : $Format:%H$ 13 | ***************************************************************************/ 14 | 15 | /*************************************************************************** 16 | * * 17 | * This program is free software; you can redistribute it and/or modify * 18 | * it under the terms of the GNU General Public License as published by * 19 | * the Free Software Foundation; either version 2 of the License, or * 20 | * (at your option) any later version. * 21 | * * 22 | ***************************************************************************/ 23 | This script initializes the plugin, making it known to QGIS. 24 | """ 25 | 26 | 27 | # noinspection PyPep8Naming 28 | def classFactory(iface): # pylint: disable=invalid-name 29 | """Load SplitRSData class from file SplitRSData. 30 | 31 | :param iface: A QGIS interface instance. 32 | :type iface: QgsInterface 33 | """ 34 | # 35 | from .split_rs_data import SplitRSData 36 | return SplitRSData(iface) 37 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/help/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 14 | 15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest 16 | 17 | help: 18 | @echo "Please use \`make ' where is one of" 19 | @echo " html to make standalone HTML files" 20 | @echo " dirhtml to make HTML files named index.html in directories" 21 | @echo " singlehtml to make a single large HTML file" 22 | @echo " pickle to make pickle files" 23 | @echo " json to make JSON files" 24 | @echo " htmlhelp to make HTML files and a HTML help project" 25 | @echo " qthelp to make HTML files and a qthelp project" 26 | @echo " devhelp to make HTML files and a Devhelp project" 27 | @echo " epub to make an epub" 28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 29 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 30 | @echo " text to make text files" 31 | @echo " man to make manual pages" 32 | @echo " changes to make an overview of all changed/added/deprecated items" 33 | @echo " linkcheck to check all external links for integrity" 34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 35 | 36 | clean: 37 | -rm -rf $(BUILDDIR)/* 38 | 39 | html: 40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 41 | @echo 42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 43 | 44 | dirhtml: 45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 48 | 49 | singlehtml: 50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 51 | @echo 52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 53 | 54 | pickle: 55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 56 | @echo 57 | @echo "Build finished; now you can process the pickle files." 58 | 59 | json: 60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 61 | @echo 62 | @echo "Build finished; now you can process the JSON files." 63 | 64 | htmlhelp: 65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 66 | @echo 67 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 68 | ".hhp project file in $(BUILDDIR)/htmlhelp." 69 | 70 | qthelp: 71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 72 | @echo 73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/template_class.qhcp" 76 | @echo "To view the help file:" 77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/template_class.qhc" 78 | 79 | devhelp: 80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 81 | @echo 82 | @echo "Build finished." 83 | @echo "To view the help file:" 84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/template_class" 85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/template_class" 86 | @echo "# devhelp" 87 | 88 | epub: 89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 90 | @echo 91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 92 | 93 | latex: 94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 95 | @echo 96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 98 | "(use \`make latexpdf' here to do that automatically)." 99 | 100 | latexpdf: 101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 102 | @echo "Running LaTeX files through pdflatex..." 103 | make -C $(BUILDDIR)/latex all-pdf 104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 105 | 106 | text: 107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 108 | @echo 109 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 110 | 111 | man: 112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 113 | @echo 114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 115 | 116 | changes: 117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 118 | @echo 119 | @echo "The overview file is in $(BUILDDIR)/changes." 120 | 121 | linkcheck: 122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 123 | @echo 124 | @echo "Link check complete; look for any errors in the above output " \ 125 | "or in $(BUILDDIR)/linkcheck/output.txt." 126 | 127 | doctest: 128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 129 | @echo "Testing of doctests in the sources finished, look at the " \ 130 | "results in $(BUILDDIR)/doctest/output.txt." 131 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/help/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source 10 | if NOT "%PAPER%" == "" ( 11 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 12 | ) 13 | 14 | if "%1" == "" goto help 15 | 16 | if "%1" == "help" ( 17 | :help 18 | echo.Please use `make ^` where ^ is one of 19 | echo. html to make standalone HTML files 20 | echo. dirhtml to make HTML files named index.html in directories 21 | echo. singlehtml to make a single large HTML file 22 | echo. pickle to make pickle files 23 | echo. json to make JSON files 24 | echo. htmlhelp to make HTML files and a HTML help project 25 | echo. qthelp to make HTML files and a qthelp project 26 | echo. devhelp to make HTML files and a Devhelp project 27 | echo. epub to make an epub 28 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 29 | echo. text to make text files 30 | echo. man to make manual pages 31 | echo. changes to make an overview over all changed/added/deprecated items 32 | echo. linkcheck to check all external links for integrity 33 | echo. doctest to run all doctests embedded in the documentation if enabled 34 | goto end 35 | ) 36 | 37 | if "%1" == "clean" ( 38 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 39 | del /q /s %BUILDDIR%\* 40 | goto end 41 | ) 42 | 43 | if "%1" == "html" ( 44 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 45 | echo. 46 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 47 | goto end 48 | ) 49 | 50 | if "%1" == "dirhtml" ( 51 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 52 | echo. 53 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 54 | goto end 55 | ) 56 | 57 | if "%1" == "singlehtml" ( 58 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 59 | echo. 60 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 61 | goto end 62 | ) 63 | 64 | if "%1" == "pickle" ( 65 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 66 | echo. 67 | echo.Build finished; now you can process the pickle files. 68 | goto end 69 | ) 70 | 71 | if "%1" == "json" ( 72 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 73 | echo. 74 | echo.Build finished; now you can process the JSON files. 75 | goto end 76 | ) 77 | 78 | if "%1" == "htmlhelp" ( 79 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 80 | echo. 81 | echo.Build finished; now you can run HTML Help Workshop with the ^ 82 | .hhp project file in %BUILDDIR%/htmlhelp. 83 | goto end 84 | ) 85 | 86 | if "%1" == "qthelp" ( 87 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 88 | echo. 89 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 90 | .qhcp project file in %BUILDDIR%/qthelp, like this: 91 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\template_class.qhcp 92 | echo.To view the help file: 93 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\template_class.ghc 94 | goto end 95 | ) 96 | 97 | if "%1" == "devhelp" ( 98 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 99 | echo. 100 | echo.Build finished. 101 | goto end 102 | ) 103 | 104 | if "%1" == "epub" ( 105 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 106 | echo. 107 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 108 | goto end 109 | ) 110 | 111 | if "%1" == "latex" ( 112 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 113 | echo. 114 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 115 | goto end 116 | ) 117 | 118 | if "%1" == "text" ( 119 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 120 | echo. 121 | echo.Build finished. The text files are in %BUILDDIR%/text. 122 | goto end 123 | ) 124 | 125 | if "%1" == "man" ( 126 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 127 | echo. 128 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 129 | goto end 130 | ) 131 | 132 | if "%1" == "changes" ( 133 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 134 | echo. 135 | echo.The overview file is in %BUILDDIR%/changes. 136 | goto end 137 | ) 138 | 139 | if "%1" == "linkcheck" ( 140 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 141 | echo. 142 | echo.Link check complete; look for any errors in the above output ^ 143 | or in %BUILDDIR%/linkcheck/output.txt. 144 | goto end 145 | ) 146 | 147 | if "%1" == "doctest" ( 148 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 149 | echo. 150 | echo.Testing of doctests in the sources finished, look at the ^ 151 | results in %BUILDDIR%/doctest/output.txt. 152 | goto end 153 | ) 154 | 155 | :end 156 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/help/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # SplitRSData documentation build configuration file, created by 4 | # sphinx-quickstart on Sun Feb 12 17:11:03 2012. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = ['sphinx.ext.todo', 'sphinx.ext.imgmath', 'sphinx.ext.viewcode'] 29 | 30 | # Add any paths that contain templates here, relative to this directory. 31 | templates_path = ['_templates'] 32 | 33 | # The suffix of source filenames. 34 | source_suffix = '.rst' 35 | 36 | # The encoding of source files. 37 | #source_encoding = 'utf-8-sig' 38 | 39 | # The master toctree document. 40 | master_doc = 'index' 41 | 42 | # General information about the project. 43 | project = u'SplitRSData' 44 | copyright = u'2013, Youssef Harby' 45 | 46 | # The version info for the project you're documenting, acts as replacement for 47 | # |version| and |release|, also used in various other places throughout the 48 | # built documents. 49 | # 50 | # The short X.Y version. 51 | version = '0.1' 52 | # The full version, including alpha/beta/rc tags. 53 | release = '0.1' 54 | 55 | # The language for content autogenerated by Sphinx. Refer to documentation 56 | # for a list of supported languages. 57 | #language = None 58 | 59 | # There are two options for replacing |today|: either, you set today to some 60 | # non-false value, then it is used: 61 | #today = '' 62 | # Else, today_fmt is used as the format for a strftime call. 63 | #today_fmt = '%B %d, %Y' 64 | 65 | # List of patterns, relative to source directory, that match files and 66 | # directories to ignore when looking for source files. 67 | exclude_patterns = [] 68 | 69 | # The reST default role (used for this markup: `text`) to use for all documents. 70 | #default_role = None 71 | 72 | # If true, '()' will be appended to :func: etc. cross-reference text. 73 | #add_function_parentheses = True 74 | 75 | # If true, the current module name will be prepended to all description 76 | # unit titles (such as .. function::). 77 | #add_TemplateModuleNames = True 78 | 79 | # If true, sectionauthor and moduleauthor directives will be shown in the 80 | # output. They are ignored by default. 81 | #show_authors = False 82 | 83 | # The name of the Pygments (syntax highlighting) style to use. 84 | pygments_style = 'sphinx' 85 | 86 | # A list of ignored prefixes for module index sorting. 87 | #modindex_common_prefix = [] 88 | 89 | 90 | # -- Options for HTML output --------------------------------------------------- 91 | 92 | # The theme to use for HTML and HTML Help pages. See the documentation for 93 | # a list of builtin themes. 94 | html_theme = 'default' 95 | 96 | # Theme options are theme-specific and customize the look and feel of a theme 97 | # further. For a list of options available for each theme, see the 98 | # documentation. 99 | #html_theme_options = {} 100 | 101 | # Add any paths that contain custom themes here, relative to this directory. 102 | #html_theme_path = [] 103 | 104 | # The name for this set of Sphinx documents. If None, it defaults to 105 | # " v documentation". 106 | #html_title = None 107 | 108 | # A shorter title for the navigation bar. Default is the same as html_title. 109 | #html_short_title = None 110 | 111 | # The name of an image file (relative to this directory) to place at the top 112 | # of the sidebar. 113 | #html_logo = None 114 | 115 | # The name of an image file (within the static path) to use as favicon of the 116 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 117 | # pixels large. 118 | #html_favicon = None 119 | 120 | # Add any paths that contain custom static files (such as style sheets) here, 121 | # relative to this directory. They are copied after the builtin static files, 122 | # so a file named "default.css" will overwrite the builtin "default.css". 123 | html_static_path = ['_static'] 124 | 125 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 126 | # using the given strftime format. 127 | #html_last_updated_fmt = '%b %d, %Y' 128 | 129 | # If true, SmartyPants will be used to convert quotes and dashes to 130 | # typographically correct entities. 131 | #html_use_smartypants = True 132 | 133 | # Custom sidebar templates, maps document names to template names. 134 | #html_sidebars = {} 135 | 136 | # Additional templates that should be rendered to pages, maps page names to 137 | # template names. 138 | #html_additional_pages = {} 139 | 140 | # If false, no module index is generated. 141 | #html_domain_indices = True 142 | 143 | # If false, no index is generated. 144 | #html_use_index = True 145 | 146 | # If true, the index is split into individual pages for each letter. 147 | #html_split_index = False 148 | 149 | # If true, links to the reST sources are added to the pages. 150 | #html_show_sourcelink = True 151 | 152 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 153 | #html_show_sphinx = True 154 | 155 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 156 | #html_show_copyright = True 157 | 158 | # If true, an OpenSearch description file will be output, and all pages will 159 | # contain a tag referring to it. The value of this option must be the 160 | # base URL from which the finished HTML is served. 161 | #html_use_opensearch = '' 162 | 163 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 164 | #html_file_suffix = None 165 | 166 | # Output file base name for HTML help builder. 167 | htmlhelp_basename = 'TemplateClassdoc' 168 | 169 | 170 | # -- Options for LaTeX output -------------------------------------------------- 171 | 172 | # The paper size ('letter' or 'a4'). 173 | #latex_paper_size = 'letter' 174 | 175 | # The font size ('10pt', '11pt' or '12pt'). 176 | #latex_font_size = '10pt' 177 | 178 | # Grouping the document tree into LaTeX files. List of tuples 179 | # (source start file, target name, title, author, documentclass [howto/manual]). 180 | latex_documents = [ 181 | ('index', 'SplitRSData.tex', u'SplitRSData Documentation', 182 | u'Youssef Harby', 'manual'), 183 | ] 184 | 185 | # The name of an image file (relative to this directory) to place at the top of 186 | # the title page. 187 | #latex_logo = None 188 | 189 | # For "manual" documents, if this is true, then toplevel headings are parts, 190 | # not chapters. 191 | #latex_use_parts = False 192 | 193 | # If true, show page references after internal links. 194 | #latex_show_pagerefs = False 195 | 196 | # If true, show URL addresses after external links. 197 | #latex_show_urls = False 198 | 199 | # Additional stuff for the LaTeX preamble. 200 | #latex_preamble = '' 201 | 202 | # Documents to append as an appendix to all manuals. 203 | #latex_appendices = [] 204 | 205 | # If false, no module index is generated. 206 | #latex_domain_indices = True 207 | 208 | 209 | # -- Options for manual page output -------------------------------------------- 210 | 211 | # One entry per manual page. List of tuples 212 | # (source start file, name, description, authors, manual section). 213 | man_pages = [ 214 | ('index', 'TemplateClass', u'SplitRSData Documentation', 215 | [u'Youssef Harby'], 1) 216 | ] 217 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/help/source/index.rst: -------------------------------------------------------------------------------- 1 | .. SplitRSData documentation master file, created by 2 | sphinx-quickstart on Sun Feb 12 17:11:03 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to SplitRSData's documentation! 7 | ============================================ 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | Indices and tables 15 | ================== 16 | 17 | * :ref:`genindex` 18 | * :ref:`modindex` 19 | * :ref:`search` 20 | 21 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/i18n/af.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @default 5 | 6 | 7 | Good morning 8 | Goeie more 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepbands/deep-learning-datasets-maker/4b3c81e25f1a2eee08567fc874287ac1804af0f5/deep-learning-datasets-maker/icon.png -------------------------------------------------------------------------------- /deep-learning-datasets-maker/metadata.txt: -------------------------------------------------------------------------------- 1 | # This file contains metadata for your plugin. 2 | 3 | # This file should be included when you package your plugin.# Mandatory items: 4 | 5 | [general] 6 | name=Deep Learning Datasets Maker 7 | qgisMinimumVersion=3.0 8 | description=tools to handle raster and vector data to split it into small pieces equaled in size for machine learning datasets 9 | version=0.2.2 10 | author=deepbands (Youssef Harby and Yizhou Chen) 11 | email=youssef_harby@yahoo.com 12 | 13 | about=tools to handle raster and vector data to split it into small pieces equaled in size for machine learning datasets. Divide remote sensing images and their labels into data sets of specified size. (512×512 for example) 14 | 15 | tracker=https://github.com/deepbands/deep-learning-datasets-maker/issues 16 | repository=https://github.com/deepbands/deep-learning-datasets-maker 17 | # End of mandatory metadata 18 | 19 | # Recommended items: 20 | 21 | hasProcessingProvider=no 22 | # Uncomment the following line and add your changelog: 23 | # changelog= 24 | 25 | # Tags are comma separated with spaces allowed 26 | tags=Datasets Maker, remote sensing, satellite, artificial intelligence, machine learning, deep learning, feature extraction, classification, digitizing, forest, forestry, roads, building detection, construction detection, agricultural field detection 27 | 28 | homepage=https://github.com/deepbands/deep-learning-datasets-maker 29 | category=Plugins 30 | icon=icon.png 31 | # experimental flag 32 | experimental=True 33 | 34 | # deprecated flag (applies to the whole plugin, not just a single version) 35 | deprecated=False 36 | 37 | # Since QGIS 3.8, a comma separated list of plugins to be installed 38 | # (or upgraded) can be specified. 39 | # Check the documentation for more information. 40 | plugin_dependencies=Cython, scikit-image, pycocotools, Pillow 41 | 42 | Category of the plugin: Raster, Vector, Database or Web 43 | # category= 44 | 45 | # If the plugin can run on QGIS Server. 46 | server=False 47 | 48 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/pb_tool.cfg: -------------------------------------------------------------------------------- 1 | #/*************************************************************************** 2 | # SplitRSData 3 | # 4 | # Configuration file for plugin builder tool (pb_tool) 5 | # Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ 6 | # ------------------- 7 | # begin : 2021-12-08 8 | # copyright : (C) 2021 by Youssef Harby 9 | # email : youssef_harby@yahoo.com 10 | # ***************************************************************************/ 11 | # 12 | #/*************************************************************************** 13 | # * * 14 | # * This program is free software; you can redistribute it and/or modify * 15 | # * it under the terms of the GNU General Public License as published by * 16 | # * the Free Software Foundation; either version 2 of the License, or * 17 | # * (at your option) any later version. * 18 | # * * 19 | # ***************************************************************************/ 20 | # 21 | # 22 | # You can install pb_tool using: 23 | # pip install http://geoapt.net/files/pb_tool.zip 24 | # 25 | # Consider doing your development (and install of pb_tool) in a virtualenv. 26 | # 27 | # For details on setting up and using pb_tool, see: 28 | # http://g-sherman.github.io/plugin_build_tool/ 29 | # 30 | # Issues and pull requests here: 31 | # https://github.com/g-sherman/plugin_build_tool: 32 | # 33 | # Sane defaults for your plugin generated by the Plugin Builder are 34 | # already set below. 35 | # 36 | # As you add Python source files and UI files to your plugin, add 37 | # them to the appropriate [files] section below. 38 | 39 | [plugin] 40 | # Name of the plugin. This is the name of the directory that will 41 | # be created in .qgis2/python/plugins 42 | name: split_rs_data 43 | 44 | # Full path to where you want your plugin directory copied. If empty, 45 | # the QGIS default path will be used. Don't include the plugin name in 46 | # the path. 47 | plugin_path: 48 | 49 | [files] 50 | # Python files that should be deployed with the plugin 51 | python_files: __init__.py split_rs_data.py split_rs_data_dialog.py 52 | 53 | # The main dialog file that is loaded (not compiled) 54 | main_dialog: split_rs_data_dialog_base.ui 55 | 56 | # Other ui files for dialogs you create (these will be compiled) 57 | compiled_ui_files: 58 | 59 | # Resource file(s) that will be compiled 60 | resource_files: resources.qrc 61 | 62 | # Other files required for the plugin 63 | extras: metadata.txt icon.png 64 | 65 | # Other directories to be deployed with the plugin. 66 | # These must be subdirectories under the plugin directory 67 | extra_dirs: 68 | 69 | # ISO code(s) for any locales (translations), separated by spaces. 70 | # Corresponding .ts files must exist in the i18n directory 71 | locales: 72 | 73 | [help] 74 | # the built help directory that should be deployed with the plugin 75 | dir: help/build/html 76 | # the name of the directory to target in the deployed plugin 77 | target: help 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/plugin_upload.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | """This script uploads a plugin package to the plugin repository. 4 | Authors: A. Pasotti, V. Picavet 5 | git sha : $TemplateVCSFormat 6 | """ 7 | 8 | import sys 9 | import getpass 10 | import xmlrpc.client 11 | from optparse import OptionParser 12 | 13 | standard_library.install_aliases() 14 | 15 | # Configuration 16 | PROTOCOL = 'https' 17 | SERVER = 'plugins.qgis.org' 18 | PORT = '443' 19 | ENDPOINT = '/plugins/RPC2/' 20 | VERBOSE = False 21 | 22 | 23 | def main(parameters, arguments): 24 | """Main entry point. 25 | 26 | :param parameters: Command line parameters. 27 | :param arguments: Command line arguments. 28 | """ 29 | address = "{protocol}://{username}:{password}@{server}:{port}{endpoint}".format( 30 | protocol=PROTOCOL, 31 | username=parameters.username, 32 | password=parameters.password, 33 | server=parameters.server, 34 | port=parameters.port, 35 | endpoint=ENDPOINT) 36 | print("Connecting to: %s" % hide_password(address)) 37 | 38 | server = xmlrpc.client.ServerProxy(address, verbose=VERBOSE) 39 | 40 | try: 41 | with open(arguments[0], 'rb') as handle: 42 | plugin_id, version_id = server.plugin.upload( 43 | xmlrpc.client.Binary(handle.read())) 44 | print("Plugin ID: %s" % plugin_id) 45 | print("Version ID: %s" % version_id) 46 | except xmlrpc.client.ProtocolError as err: 47 | print("A protocol error occurred") 48 | print("URL: %s" % hide_password(err.url, 0)) 49 | print("HTTP/HTTPS headers: %s" % err.headers) 50 | print("Error code: %d" % err.errcode) 51 | print("Error message: %s" % err.errmsg) 52 | except xmlrpc.client.Fault as err: 53 | print("A fault occurred") 54 | print("Fault code: %d" % err.faultCode) 55 | print("Fault string: %s" % err.faultString) 56 | 57 | 58 | def hide_password(url, start=6): 59 | """Returns the http url with password part replaced with '*'. 60 | 61 | :param url: URL to upload the plugin to. 62 | :type url: str 63 | 64 | :param start: Position of start of password. 65 | :type start: int 66 | """ 67 | start_position = url.find(':', start) + 1 68 | end_position = url.find('@') 69 | return "%s%s%s" % ( 70 | url[:start_position], 71 | '*' * (end_position - start_position), 72 | url[end_position:]) 73 | 74 | 75 | if __name__ == "__main__": 76 | parser = OptionParser(usage="%prog [options] plugin.zip") 77 | parser.add_option( 78 | "-w", "--password", dest="password", 79 | help="Password for plugin site", metavar="******") 80 | parser.add_option( 81 | "-u", "--username", dest="username", 82 | help="Username of plugin site", metavar="user") 83 | parser.add_option( 84 | "-p", "--port", dest="port", 85 | help="Server port to connect to", metavar="80") 86 | parser.add_option( 87 | "-s", "--server", dest="server", 88 | help="Specify server name", metavar="plugins.qgis.org") 89 | options, args = parser.parse_args() 90 | if len(args) != 1: 91 | print("Please specify zip file.\n") 92 | parser.print_help() 93 | sys.exit(1) 94 | if not options.server: 95 | options.server = SERVER 96 | if not options.port: 97 | options.port = PORT 98 | if not options.username: 99 | # interactive mode 100 | username = getpass.getuser() 101 | print("Please enter user name [%s] :" % username, end=' ') 102 | 103 | res = input() 104 | if res != "": 105 | options.username = res 106 | else: 107 | options.username = username 108 | if not options.password: 109 | # interactive mode 110 | options.password = getpass.getpass() 111 | main(options, args) 112 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/pylintrc: -------------------------------------------------------------------------------- 1 | [MASTER] 2 | 3 | # Specify a configuration file. 4 | #rcfile= 5 | 6 | # Python code to execute, usually for sys.path manipulation such as 7 | # pygtk.require(). 8 | #init-hook= 9 | 10 | # Profiled execution. 11 | profile=no 12 | 13 | # Add files or directories to the blacklist. They should be base names, not 14 | # paths. 15 | ignore=CVS 16 | 17 | # Pickle collected data for later comparisons. 18 | persistent=yes 19 | 20 | # List of plugins (as comma separated values of python modules names) to load, 21 | # usually to register additional checkers. 22 | load-plugins= 23 | 24 | 25 | [MESSAGES CONTROL] 26 | 27 | # Enable the message, report, category or checker with the given id(s). You can 28 | # either give multiple identifier separated by comma (,) or put this option 29 | # multiple time. See also the "--disable" option for examples. 30 | #enable= 31 | 32 | # Disable the message, report, category or checker with the given id(s). You 33 | # can either give multiple identifiers separated by comma (,) or put this 34 | # option multiple times (only on the command line, not in the configuration 35 | # file where it should appear only once).You can also use "--disable=all" to 36 | # disable everything first and then reenable specific checks. For example, if 37 | # you want to run only the similarities checker, you can use "--disable=all 38 | # --enable=similarities". If you want to run only the classes checker, but have 39 | # no Warning level messages displayed, use"--disable=all --enable=classes 40 | # --disable=W" 41 | # see http://stackoverflow.com/questions/21487025/pylint-locally-defined-disables-still-give-warnings-how-to-suppress-them 42 | disable=locally-disabled,C0103 43 | 44 | 45 | [REPORTS] 46 | 47 | # Set the output format. Available formats are text, parseable, colorized, msvs 48 | # (visual studio) and html. You can also give a reporter class, eg 49 | # mypackage.mymodule.MyReporterClass. 50 | output-format=text 51 | 52 | # Put messages in a separate file for each module / package specified on the 53 | # command line instead of printing them on stdout. Reports (if any) will be 54 | # written in a file name "pylint_global.[txt|html]". 55 | files-output=no 56 | 57 | # Tells whether to display a full report or only the messages 58 | reports=yes 59 | 60 | # Python expression which should return a note less than 10 (10 is the highest 61 | # note). You have access to the variables errors warning, statement which 62 | # respectively contain the number of errors / warnings messages and the total 63 | # number of statements analyzed. This is used by the global evaluation report 64 | # (RP0004). 65 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) 66 | 67 | # Add a comment according to your evaluation note. This is used by the global 68 | # evaluation report (RP0004). 69 | comment=no 70 | 71 | # Template used to display messages. This is a python new-style format string 72 | # used to format the message information. See doc for all details 73 | #msg-template= 74 | 75 | 76 | [BASIC] 77 | 78 | # Required attributes for module, separated by a comma 79 | required-attributes= 80 | 81 | # List of builtins function names that should not be used, separated by a comma 82 | bad-functions=map,filter,apply,input 83 | 84 | # Regular expression which should only match correct module names 85 | module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ 86 | 87 | # Regular expression which should only match correct module level names 88 | const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ 89 | 90 | # Regular expression which should only match correct class names 91 | class-rgx=[A-Z_][a-zA-Z0-9]+$ 92 | 93 | # Regular expression which should only match correct function names 94 | function-rgx=[a-z_][a-z0-9_]{2,30}$ 95 | 96 | # Regular expression which should only match correct method names 97 | method-rgx=[a-z_][a-z0-9_]{2,30}$ 98 | 99 | # Regular expression which should only match correct instance attribute names 100 | attr-rgx=[a-z_][a-z0-9_]{2,30}$ 101 | 102 | # Regular expression which should only match correct argument names 103 | argument-rgx=[a-z_][a-z0-9_]{2,30}$ 104 | 105 | # Regular expression which should only match correct variable names 106 | variable-rgx=[a-z_][a-z0-9_]{2,30}$ 107 | 108 | # Regular expression which should only match correct attribute names in class 109 | # bodies 110 | class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ 111 | 112 | # Regular expression which should only match correct list comprehension / 113 | # generator expression variable names 114 | inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ 115 | 116 | # Good variable names which should always be accepted, separated by a comma 117 | good-names=i,j,k,ex,Run,_ 118 | 119 | # Bad variable names which should always be refused, separated by a comma 120 | bad-names=foo,bar,baz,toto,tutu,tata 121 | 122 | # Regular expression which should only match function or class names that do 123 | # not require a docstring. 124 | no-docstring-rgx=__.*__ 125 | 126 | # Minimum line length for functions/classes that require docstrings, shorter 127 | # ones are exempt. 128 | docstring-min-length=-1 129 | 130 | 131 | [MISCELLANEOUS] 132 | 133 | # List of note tags to take in consideration, separated by a comma. 134 | notes=FIXME,XXX,TODO 135 | 136 | 137 | [TYPECHECK] 138 | 139 | # Tells whether missing members accessed in mixin class should be ignored. A 140 | # mixin class is detected if its name ends with "mixin" (case insensitive). 141 | ignore-mixin-members=yes 142 | 143 | # List of classes names for which member attributes should not be checked 144 | # (useful for classes with attributes dynamically set). 145 | ignored-classes=SQLObject 146 | 147 | # When zope mode is activated, add a predefined set of Zope acquired attributes 148 | # to generated-members. 149 | zope=no 150 | 151 | # List of members which are set dynamically and missed by pylint inference 152 | # system, and so shouldn't trigger E0201 when accessed. Python regular 153 | # expressions are accepted. 154 | generated-members=REQUEST,acl_users,aq_parent 155 | 156 | 157 | [VARIABLES] 158 | 159 | # Tells whether we should check for unused import in __init__ files. 160 | init-import=no 161 | 162 | # A regular expression matching the beginning of the name of dummy variables 163 | # (i.e. not used). 164 | dummy-variables-rgx=_$|dummy 165 | 166 | # List of additional names supposed to be defined in builtins. Remember that 167 | # you should avoid to define new builtins when possible. 168 | additional-builtins= 169 | 170 | 171 | [FORMAT] 172 | 173 | # Maximum number of characters on a single line. 174 | max-line-length=80 175 | 176 | # Regexp for a line that is allowed to be longer than the limit. 177 | ignore-long-lines=^\s*(# )??$ 178 | 179 | # Allow the body of an if to be on the same line as the test if there is no 180 | # else. 181 | single-line-if-stmt=no 182 | 183 | # List of optional constructs for which whitespace checking is disabled 184 | no-space-check=trailing-comma,dict-separator 185 | 186 | # Maximum number of lines in a module 187 | max-module-lines=1000 188 | 189 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 190 | # tab). 191 | indent-string=' ' 192 | 193 | 194 | [SIMILARITIES] 195 | 196 | # Minimum lines number of a similarity. 197 | min-similarity-lines=4 198 | 199 | # Ignore comments when computing similarities. 200 | ignore-comments=yes 201 | 202 | # Ignore docstrings when computing similarities. 203 | ignore-docstrings=yes 204 | 205 | # Ignore imports when computing similarities. 206 | ignore-imports=no 207 | 208 | 209 | [IMPORTS] 210 | 211 | # Deprecated modules which should not be used, separated by a comma 212 | deprecated-modules=regsub,TERMIOS,Bastion,rexec 213 | 214 | # Create a graph of every (i.e. internal and external) dependencies in the 215 | # given file (report RP0402 must not be disabled) 216 | import-graph= 217 | 218 | # Create a graph of external dependencies in the given file (report RP0402 must 219 | # not be disabled) 220 | ext-import-graph= 221 | 222 | # Create a graph of internal dependencies in the given file (report RP0402 must 223 | # not be disabled) 224 | int-import-graph= 225 | 226 | 227 | [DESIGN] 228 | 229 | # Maximum number of arguments for function / method 230 | max-args=5 231 | 232 | # Argument names that match this expression will be ignored. Default to name 233 | # with leading underscore 234 | ignored-argument-names=_.* 235 | 236 | # Maximum number of locals for function / method body 237 | max-locals=15 238 | 239 | # Maximum number of return / yield for function / method body 240 | max-returns=6 241 | 242 | # Maximum number of branch for function / method body 243 | max-branches=12 244 | 245 | # Maximum number of statements in function / method body 246 | max-statements=50 247 | 248 | # Maximum number of parents for a class (see R0901). 249 | max-parents=7 250 | 251 | # Maximum number of attributes for a class (see R0902). 252 | max-attributes=7 253 | 254 | # Minimum number of public methods for a class (see R0903). 255 | min-public-methods=2 256 | 257 | # Maximum number of public methods for a class (see R0904). 258 | max-public-methods=20 259 | 260 | 261 | [CLASSES] 262 | 263 | # List of interface methods to ignore, separated by a comma. This is used for 264 | # instance to not check methods defines in Zope's Interface base class. 265 | ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by 266 | 267 | # List of method names used to declare (i.e. assign) instance attributes. 268 | defining-attr-methods=__init__,__new__,setUp 269 | 270 | # List of valid names for the first argument in a class method. 271 | valid-classmethod-first-arg=cls 272 | 273 | # List of valid names for the first argument in a metaclass class method. 274 | valid-metaclass-classmethod-first-arg=mcs 275 | 276 | 277 | [EXCEPTIONS] 278 | 279 | # Exceptions that will emit a warning when being caught. Defaults to 280 | # "Exception" 281 | overgeneral-exceptions=Exception 282 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/resources.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Resource object code 4 | # 5 | # Created by: The Resource Compiler for PyQt5 (Qt v5.15.2) 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore 10 | 11 | qt_resource_data = b"\ 12 | \x00\x00\x05\x6d\ 13 | \x89\ 14 | \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ 15 | \x00\x00\x18\x00\x00\x00\x18\x08\x06\x00\x00\x00\xe0\x77\x3d\xf8\ 16 | \x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\ 17 | \x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\ 18 | \x79\x71\xc9\x65\x3c\x00\x00\x03\x81\x69\x54\x58\x74\x58\x4d\x4c\ 19 | \x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\ 20 | \x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\ 21 | \x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\ 22 | \x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\ 23 | \x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\ 24 | \x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\ 25 | \x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\ 26 | \x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\ 27 | \x43\x6f\x72\x65\x20\x36\x2e\x30\x2d\x63\x30\x30\x35\x20\x37\x39\ 28 | \x2e\x31\x36\x34\x35\x39\x30\x2c\x20\x32\x30\x32\x30\x2f\x31\x32\ 29 | \x2f\x30\x39\x2d\x31\x31\x3a\x35\x37\x3a\x34\x34\x20\x20\x20\x20\ 30 | \x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\ 31 | \x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\ 32 | \x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\ 33 | \x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\ 34 | \x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\ 35 | \x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\ 36 | \x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\ 37 | \x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\ 38 | \x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\ 39 | \x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\ 40 | \x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\ 41 | \x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\ 42 | \x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\ 43 | \x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\ 44 | \x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\ 45 | \x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\ 46 | \x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\ 47 | \x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x63\x35\x63\ 48 | \x62\x35\x37\x35\x32\x2d\x64\x34\x66\x34\x2d\x64\x31\x34\x34\x2d\ 49 | \x39\x32\x37\x38\x2d\x37\x37\x61\x33\x65\x31\x30\x62\x32\x66\x36\ 50 | \x33\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\ 51 | \x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x46\x45\x39\ 52 | \x33\x45\x30\x42\x41\x35\x39\x44\x42\x31\x31\x45\x43\x41\x43\x35\ 53 | \x31\x42\x43\x34\x36\x43\x39\x36\x36\x37\x45\x38\x30\x22\x20\x78\ 54 | \x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\ 55 | \x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x46\x45\x39\x33\x45\x30\x42\ 56 | \x39\x35\x39\x44\x42\x31\x31\x45\x43\x41\x43\x35\x31\x42\x43\x34\ 57 | \x36\x43\x39\x36\x36\x37\x45\x38\x30\x22\x20\x78\x6d\x70\x3a\x43\ 58 | \x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\ 59 | \x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x32\x32\x2e\x31\ 60 | \x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\x3c\x78\x6d\ 61 | \x70\x4d\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\ 62 | \x73\x74\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\ 63 | \x3d\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x61\x39\x61\x31\x35\x63\ 64 | \x33\x62\x2d\x33\x36\x30\x34\x2d\x35\x62\x34\x64\x2d\x62\x37\x32\ 65 | \x63\x2d\x62\x64\x33\x33\x66\x34\x35\x30\x31\x36\x61\x30\x22\x20\ 66 | \x73\x74\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\ 67 | \x3d\x22\x61\x64\x6f\x62\x65\x3a\x64\x6f\x63\x69\x64\x3a\x70\x68\ 68 | \x6f\x74\x6f\x73\x68\x6f\x70\x3a\x38\x34\x38\x30\x36\x35\x62\x66\ 69 | \x2d\x37\x62\x62\x62\x2d\x66\x62\x34\x39\x2d\x62\x62\x62\x32\x2d\ 70 | \x65\x63\x32\x33\x30\x64\x35\x66\x39\x36\x63\x35\x22\x2f\x3e\x20\ 71 | \x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\ 72 | \x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\ 73 | \x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\ 74 | \x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x25\xba\ 75 | \x90\x3e\x00\x00\x01\x82\x49\x44\x41\x54\x78\xda\xd4\x95\x31\x4b\ 76 | \xc3\x50\x10\x80\xf3\xd2\x20\x56\xac\x50\x71\xd3\x4d\x71\x10\xff\ 77 | \x80\x88\xa0\x9b\x83\x88\x2e\x8e\x3a\x6a\x5d\x9c\x14\x9c\x1c\xdd\ 78 | \x74\xe8\xe2\x1f\xf0\x67\xb8\x88\x3f\x42\x50\x54\xac\xa0\x5d\x8a\ 79 | \xa6\x06\x9a\x9a\x1a\x2f\x70\x07\xe7\x79\xc9\x4b\x0a\x0a\x3e\xf8\ 80 | \xe0\xfa\xbe\x47\xae\xb9\x77\xef\xc5\x3c\x07\xa1\x53\xbb\xbc\xae\ 81 | \xfb\xdd\x68\xd1\x35\xc6\x61\xe3\x0a\xa8\x61\xbc\x0f\x6c\x3a\xdf\ 82 | \xc7\x23\xb0\x0a\xf4\xa4\x8f\x81\xcf\x38\x7e\x38\x9d\x9f\x5e\xf7\ 83 | \x70\x6e\x12\x98\x15\x0f\x78\x61\xf1\xb8\xe2\x87\x01\x93\xe1\xcb\ 84 | \x89\x77\xf1\x47\xe4\xfc\x1c\x7c\xae\xd7\xaf\x77\x9d\x5f\x1e\x94\ 85 | \xc0\x28\xce\xa4\xc4\x85\xbc\x2b\x12\x69\xc9\xd3\x1e\x90\xcb\xd3\ 86 | \x26\xef\x01\x47\x62\xc1\x1b\x8b\x4f\x80\x73\xe1\x43\x56\x7b\xcd\ 87 | \x77\x92\x7d\xa0\x04\xb7\x96\x52\x36\x90\xc2\xde\xcb\x78\x45\x6a\ 88 | \xe9\xac\x32\x58\x3d\x25\xa8\x03\x4b\x42\x26\x07\x6d\x1b\xe3\x03\ 89 | \x60\x4b\x39\x68\x2b\x58\x26\xcd\xdf\x03\x6b\x94\x60\x0a\x98\xc9\ 90 | \x38\x68\x13\x8a\x1f\x61\xff\x5a\xf3\x43\xfc\xa0\x75\x95\xd7\xe3\ 91 | \x73\x1f\x8a\xef\x58\x7c\xf8\xa7\x07\xad\xa4\xb8\x52\x4a\xcf\x17\ 92 | \xf2\xb4\x07\x01\xf0\x2e\x16\x04\xa2\x1c\xd2\xb7\xf3\x78\x4a\xb0\ 93 | \x03\x0c\x6a\x35\xc4\x71\x8c\x9d\x26\x2f\xb3\xc8\xe6\x29\x41\xcb\ 94 | \x52\x4a\x1f\x29\xec\x29\x41\x05\x18\x50\xba\xa8\xcd\x5a\xae\x2c\ 95 | \x7c\xd2\xff\xaf\x36\x4f\x09\xce\x80\x65\xb1\xe0\x02\xd8\xc0\xf8\ 96 | \x10\xd8\x15\xfe\x0e\x98\xc3\x52\x68\xfe\x06\x58\xa0\x04\x55\x60\ 97 | \x54\x2c\xa8\xb2\xb8\xa2\x78\xdf\xe2\xc7\x78\x7b\xfd\xff\x2f\x5a\ 98 | \x3f\x07\xcd\xcb\xe3\x69\x51\x53\xb9\xcf\x9b\x2c\x6e\x29\xbe\x61\ 99 | \xf1\x4f\xc9\x75\xfd\x25\xc0\x00\x62\x9a\x6c\x88\x4b\x23\x1b\x35\ 100 | \x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\ 101 | " 102 | 103 | qt_resource_name = b"\ 104 | \x00\x07\ 105 | \x07\x3b\xe0\xb3\ 106 | \x00\x70\ 107 | \x00\x6c\x00\x75\x00\x67\x00\x69\x00\x6e\x00\x73\ 108 | \x00\x0d\ 109 | \x0d\x73\xbd\x81\ 110 | \x00\x73\ 111 | \x00\x70\x00\x6c\x00\x69\x00\x74\x00\x5f\x00\x72\x00\x73\x00\x5f\x00\x64\x00\x61\x00\x74\x00\x61\ 112 | \x00\x08\ 113 | \x0a\x61\x5a\xa7\ 114 | \x00\x69\ 115 | \x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\ 116 | " 117 | 118 | qt_resource_struct_v1 = b"\ 119 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ 120 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ 121 | \x00\x00\x00\x14\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ 122 | \x00\x00\x00\x34\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ 123 | " 124 | 125 | qt_resource_struct_v2 = b"\ 126 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ 127 | \x00\x00\x00\x00\x00\x00\x00\x00\ 128 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ 129 | \x00\x00\x00\x00\x00\x00\x00\x00\ 130 | \x00\x00\x00\x14\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ 131 | \x00\x00\x00\x00\x00\x00\x00\x00\ 132 | \x00\x00\x00\x34\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ 133 | \x00\x00\x01\x7d\xb7\x56\x1f\x57\ 134 | " 135 | 136 | qt_version = [int(v) for v in QtCore.qVersion().split('.')] 137 | if qt_version < [5, 8, 0]: 138 | rcc_version = 1 139 | qt_resource_struct = qt_resource_struct_v1 140 | else: 141 | rcc_version = 2 142 | qt_resource_struct = qt_resource_struct_v2 143 | 144 | def qInitResources(): 145 | QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) 146 | 147 | def qCleanupResources(): 148 | QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) 149 | 150 | qInitResources() 151 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icon.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/scripts/compile-strings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | LRELEASE=$1 3 | LOCALES=$2 4 | 5 | 6 | for LOCALE in ${LOCALES} 7 | do 8 | echo "Processing: ${LOCALE}.ts" 9 | # Note we don't use pylupdate with qt .pro file approach as it is flakey 10 | # about what is made available. 11 | $LRELEASE i18n/${LOCALE}.ts 12 | done 13 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/scripts/run-env-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | QGIS_PREFIX_PATH=/usr/local/qgis-2.0 4 | if [ -n "$1" ]; then 5 | QGIS_PREFIX_PATH=$1 6 | fi 7 | 8 | echo ${QGIS_PREFIX_PATH} 9 | 10 | 11 | export QGIS_PREFIX_PATH=${QGIS_PREFIX_PATH} 12 | export QGIS_PATH=${QGIS_PREFIX_PATH} 13 | export LD_LIBRARY_PATH=${QGIS_PREFIX_PATH}/lib 14 | export PYTHONPATH=${QGIS_PREFIX_PATH}/share/qgis/python:${QGIS_PREFIX_PATH}/share/qgis/python/plugins:${PYTHONPATH} 15 | 16 | echo "QGIS PATH: $QGIS_PREFIX_PATH" 17 | export QGIS_DEBUG=0 18 | export QGIS_LOG_FILE=/tmp/inasafe/realtime/logs/qgis.log 19 | 20 | export PATH=${QGIS_PREFIX_PATH}/bin:$PATH 21 | 22 | echo "This script is intended to be sourced to set up your shell to" 23 | echo "use a QGIS 2.0 built in $QGIS_PREFIX_PATH" 24 | echo 25 | echo "To use it do:" 26 | echo "source $BASH_SOURCE /your/optional/install/path" 27 | echo 28 | echo "Then use the make file supplied here e.g. make guitest" 29 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/scripts/update-strings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | LOCALES=$* 3 | 4 | # Get newest .py files so we don't update strings unnecessarily 5 | 6 | CHANGED_FILES=0 7 | PYTHON_FILES=`find . -regex ".*\(ui\|py\)$" -type f` 8 | for PYTHON_FILE in $PYTHON_FILES 9 | do 10 | CHANGED=$(stat -c %Y $PYTHON_FILE) 11 | if [ ${CHANGED} -gt ${CHANGED_FILES} ] 12 | then 13 | CHANGED_FILES=${CHANGED} 14 | fi 15 | done 16 | 17 | # Qt translation stuff 18 | # for .ts file 19 | UPDATE=false 20 | for LOCALE in ${LOCALES} 21 | do 22 | TRANSLATION_FILE="i18n/$LOCALE.ts" 23 | if [ ! -f ${TRANSLATION_FILE} ] 24 | then 25 | # Force translation string collection as we have a new language file 26 | touch ${TRANSLATION_FILE} 27 | UPDATE=true 28 | break 29 | fi 30 | 31 | MODIFICATION_TIME=$(stat -c %Y ${TRANSLATION_FILE}) 32 | if [ ${CHANGED_FILES} -gt ${MODIFICATION_TIME} ] 33 | then 34 | # Force translation string collection as a .py file has been updated 35 | UPDATE=true 36 | break 37 | fi 38 | done 39 | 40 | if [ ${UPDATE} == true ] 41 | # retrieve all python files 42 | then 43 | echo ${PYTHON_FILES} 44 | # update .ts 45 | echo "Please provide translations by editing the translation files below:" 46 | for LOCALE in ${LOCALES} 47 | do 48 | echo "i18n/"${LOCALE}".ts" 49 | # Note we don't use pylupdate with qt .pro file approach as it is flakey 50 | # about what is made available. 51 | pylupdate4 -noobsolete ${PYTHON_FILES} -ts i18n/${LOCALE}.ts 52 | done 53 | else 54 | echo "No need to edit any translation files (.ts) because no python files" 55 | echo "has been updated since the last update translation. " 56 | fi 57 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/split_rs_data.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | SplitRSData 5 | A QGIS plugin 6 | tools to handle raster and vector data to split it into small pieces equaled in size for machine learning datasets 7 | Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ 8 | ------------------- 9 | begin : 2021-12-08 10 | git sha : $Format:%H$ 11 | copyright : (C) 2021 by Youssef Harby 12 | email : youssef_harby@yahoo.com 13 | ***************************************************************************/ 14 | 15 | /*************************************************************************** 16 | * * 17 | * This program is free software; you can redistribute it and/or modify * 18 | * it under the terms of the GNU General Public License as published by * 19 | * the Free Software Foundation; either version 2 of the License, or * 20 | * (at your option) any later version. * 21 | * * 22 | ***************************************************************************/ 23 | """ 24 | from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication 25 | from qgis.PyQt.QtGui import QIcon 26 | from qgis.PyQt.QtWidgets import QAction, QFileDialog, QTabWidget 27 | from qgis.core import ( 28 | QgsMapLayerProxyModel, 29 | QgsProject, 30 | QgsProcessingFeedback, 31 | QgsMessageLog, 32 | Qgis, 33 | ) 34 | from qgis.utils import iface 35 | 36 | # import processing, tempfile 37 | 38 | # Initialize Qt resources from file resources.py 39 | from .resources import * 40 | 41 | # Import the code for the dialog 42 | from .split_rs_data_dialog import SplitRSDataDialog 43 | import os 44 | import os.path as osp 45 | from .utils import * 46 | from .utils.COCO import clip_from_file, slice, from_mask_to_coco 47 | 48 | # import argparse 49 | 50 | 51 | class SplitRSData: 52 | """QGIS Plugin Implementation.""" 53 | 54 | def __init__(self, iface): 55 | """Constructor. 56 | 57 | :param iface: An interface instance that will be passed to this class 58 | which provides the hook by which you can manipulate the QGIS 59 | application at run time. 60 | :type iface: QgsInterface 61 | """ 62 | # Save reference to the QGIS interface 63 | self.iface = iface 64 | # initialize plugin directory 65 | self.plugin_dir = os.path.dirname(__file__) 66 | # initialize locale 67 | locale = QSettings().value("locale/userLocale")[0:2] 68 | locale_path = os.path.join( 69 | self.plugin_dir, "i18n", "SplitRSData_{}.qm".format(locale) 70 | ) 71 | # print("############################3" + self.plugin_dir) 72 | 73 | if os.path.exists(locale_path): 74 | self.translator = QTranslator() 75 | self.translator.load(locale_path) 76 | QCoreApplication.installTranslator(self.translator) 77 | 78 | # Declare instance attributes 79 | self.actions = [] 80 | self.menu = self.tr(u"&deepbands") 81 | 82 | # Check if plugin was started the first time in current QGIS session 83 | # Must be set in initGui() to survive plugin reloads 84 | self.first_start = None 85 | 86 | # noinspection PyMethodMayBeStatic 87 | def tr(self, message): 88 | """Get the translation for a string using Qt translation API. 89 | 90 | We implement this ourselves since we do not inherit QObject. 91 | 92 | :param message: String for translation. 93 | :type message: str, QString 94 | 95 | :returns: Translated version of message. 96 | :rtype: QString 97 | """ 98 | # noinspection PyTypeChecker,PyArgumentList,PyCallByClass 99 | return QCoreApplication.translate("SplitRSData", message) 100 | 101 | def add_action( 102 | self, 103 | icon_path, 104 | text, 105 | callback, 106 | enabled_flag=True, 107 | add_to_menu=True, 108 | add_to_toolbar=True, 109 | status_tip=None, 110 | whats_this=None, 111 | parent=None, 112 | ): 113 | """Add a toolbar icon to the toolbar. 114 | 115 | :param icon_path: Path to the icon for this action. Can be a resource 116 | path (e.g. ':/plugins/foo/bar.png') or a normal file system path. 117 | :type icon_path: str 118 | 119 | :param text: Text that should be shown in menu items for this action. 120 | :type text: str 121 | 122 | :param callback: Function to be called when the action is triggered. 123 | :type callback: function 124 | 125 | :param enabled_flag: A flag indicating if the action should be enabled 126 | by default. Defaults to True. 127 | :type enabled_flag: bool 128 | 129 | :param add_to_menu: Flag indicating whether the action should also 130 | be added to the menu. Defaults to True. 131 | :type add_to_menu: bool 132 | 133 | :param add_to_toolbar: Flag indicating whether the action should also 134 | be added to the toolbar. Defaults to True. 135 | :type add_to_toolbar: bool 136 | 137 | :param status_tip: Optional text to show in a popup when mouse pointer 138 | hovers over the action. 139 | :type status_tip: str 140 | 141 | :param parent: Parent widget for the new action. Defaults None. 142 | :type parent: QWidget 143 | 144 | :param whats_this: Optional text to show in the status bar when the 145 | mouse pointer hovers over the action. 146 | 147 | :returns: The action that was created. Note that the action is also 148 | added to self.actions list. 149 | :rtype: QAction 150 | """ 151 | 152 | icon = QIcon(icon_path) 153 | action = QAction(icon, text, parent) 154 | action.triggered.connect(callback) 155 | action.setEnabled(enabled_flag) 156 | 157 | if status_tip is not None: 158 | action.setStatusTip(status_tip) 159 | 160 | if whats_this is not None: 161 | action.setWhatsThis(whats_this) 162 | 163 | if add_to_toolbar: 164 | # Adds plugin icon to Plugins toolbar 165 | self.iface.addToolBarIcon(action) 166 | 167 | if add_to_menu: 168 | self.iface.addPluginToMenu(self.menu, action) 169 | 170 | self.actions.append(action) 171 | 172 | return action 173 | 174 | def initGui(self): 175 | """Create the menu entries and toolbar icons inside the QGIS GUI.""" 176 | 177 | icon_path = ":/plugins/split_rs_data/icon.png" 178 | self.add_action( 179 | icon_path, 180 | text=self.tr(u"Deep Learning Datasets Maker"), 181 | callback=self.run, 182 | parent=self.iface.mainWindow(), 183 | ) 184 | 185 | # will be set False in run() 186 | self.first_start = True 187 | 188 | def unload(self): 189 | """Removes the plugin menu item and icon from QGIS GUI.""" 190 | for action in self.actions: 191 | self.iface.removePluginMenu( 192 | self.tr(u"&Deep Learning Datasets Maker"), action 193 | ) 194 | self.iface.removeToolBarIcon(action) 195 | 196 | def state_changed(self, state): 197 | """Set the visibility of mQfwLabels_InSeg 198 | 199 | Args: 200 | state (int): Output the current status of three check boxes: 201 | 0 selected 202 | 1 half selected 203 | 2 unchecked 204 | """ 205 | # if state == 2: 206 | # self.dlg.mQfwLabels_InSeg.setEnabled(True) # We also can use .setHidden(False) 207 | # self.dlg.label_7.setEnabled(True) 208 | # else : 209 | # self.dlg.mQfwLabels_InSeg.setEnabled(False) 210 | # self.dlg.label_7.setEnabled(False) 211 | 212 | def state_changed_paddle(self, state): 213 | if state == 2: 214 | self.dlg.mOpacityWidget_Training.setEnabled(True) 215 | self.dlg.mOpacityWidget_Validating.setEnabled(True) 216 | self.dlg.label_8.setEnabled(True) 217 | self.dlg.label_9.setEnabled(True) 218 | self.dlg.label_10.setEnabled(True) 219 | else: 220 | self.dlg.mOpacityWidget_Training.setEnabled(False) 221 | self.dlg.mOpacityWidget_Validating.setEnabled(False) 222 | self.dlg.label_8.setEnabled(False) 223 | self.dlg.label_9.setEnabled(False) 224 | self.dlg.label_10.setEnabled(False) 225 | 226 | def state_changed_training(self, state): 227 | Training_Set = self.dlg.mOpacityWidget_Training.opacity() 228 | Val_Set = self.dlg.mOpacityWidget_Validating.opacity() 229 | Testing_Set = self.dlg.mOpacityWidget_Testing.opacity() 230 | if Testing_Set == 0: 231 | self.dlg.mOpacityWidget_Validating.setOpacity(1.0 - Training_Set) 232 | self.dlg.mOpacityWidget_Testing.setOpacity( 233 | 1.0 - (Training_Set + Val_Set)) 234 | 235 | def run(self): 236 | """Run method that performs all the real work""" 237 | 238 | # Create the dialog with elements (after translation) and keep reference 239 | # Only create GUI ONCE in callback, so that it will only load when the plugin is started 240 | if self.first_start == True: 241 | self.first_start = False 242 | self.dlg = SplitRSDataDialog() 243 | 244 | # Fetch the currently loaded layers 245 | self.dlg.mQfwDataset.setDialogTitle("Select Output Images Files") 246 | self.dlg.mMapLayerComboBoxR.setFilters( 247 | QgsMapLayerProxyModel.RasterLayer) 248 | self.dlg.mMapLayerComboBoxV.setFilters( 249 | QgsMapLayerProxyModel.PolygonLayer) 250 | self.dlg.comboBoxImgSize.clear() 251 | self.dlg.comboBoxImgSize.addItems(["64", "128", "256", "512", "1024"]) 252 | self.dlg.comboBoxImgSize.setCurrentIndex(3) 253 | self.dlg.checkBoxInSeg.setChecked(False) 254 | self.dlg.checkBoxPaddle.setChecked(True) 255 | self.dlg.checkBoxInSeg.stateChanged.connect(self.state_changed) 256 | self.dlg.checkBoxPaddle.stateChanged.connect(self.state_changed_paddle) 257 | self.dlg.mOpacityWidget_Training.opacityChanged.connect( 258 | self.state_changed_training 259 | ) 260 | self.dlg.mOpacityWidget_Validating.opacityChanged.connect( 261 | self.state_changed_training 262 | ) 263 | 264 | # show the dialog 265 | self.dlg.show() 266 | # Run the dialog event loop 267 | result = self.dlg.exec_() 268 | # See if OK was pressed 269 | if result: 270 | currentrasterlay = ( 271 | self.dlg.mMapLayerComboBoxR.currentText() 272 | ) # Get the selected raster layer 273 | rlayers = QgsProject.instance().mapLayersByName(currentrasterlay) 274 | fn_ras = rlayers[0] 275 | currentvectorlay = ( 276 | self.dlg.mMapLayerComboBoxV.currentText() 277 | ) # Get the selected raster layer 278 | vlayers = QgsProject.instance().mapLayersByName(currentvectorlay) 279 | fn_vec = vlayers[0] 280 | SplittingSize = int(self.dlg.comboBoxImgSize.currentText()) 281 | 282 | # Log for files 283 | ras_path = str(fn_ras.dataProvider().dataSourceUri()) 284 | vec_path = str(fn_vec.dataProvider().dataSourceUri()) 285 | dataset_path = str(self.dlg.mQfwDataset.filePath()) 286 | 287 | def mkdir_p(path): 288 | if not osp.exists(path): 289 | os.makedirs(path) 290 | 291 | # PaddlePaddle Dataset Paths 292 | dataset_paddle = osp.join(dataset_path, "PaddlePaddle") 293 | mkdir_p(dataset_paddle) 294 | 295 | Ras_Paddle_path = osp.join(dataset_paddle, "rasterized/") 296 | output = osp.join( 297 | Ras_Paddle_path, currentrasterlay + "_rasterized" + ".tif" 298 | ) # Output Rasterized File 299 | image_Paddle_path = osp.join(dataset_paddle, "image/") 300 | label_Paddle_path = osp.join(dataset_paddle, "label/") 301 | InSeg_Paddle_path = osp.join(dataset_paddle, "inseg/") 302 | mkdir_p(Ras_Paddle_path) 303 | mkdir_p(image_Paddle_path) 304 | mkdir_p(label_Paddle_path) 305 | mkdir_p(InSeg_Paddle_path) 306 | 307 | feedback = QgsProcessingFeedback() 308 | feedback.pushInfo("Raster Path : " + ras_path) 309 | feedback.pushInfo("Vector Path : " + vec_path) 310 | feedback.pushInfo("Output Rasterized Path : " + output) 311 | feedback.pushInfo("Imge Splitting Size : " + str(SplittingSize)) 312 | 313 | # TODO: if shp in memory, it can't work 314 | 315 | rasterize(ras_path, vec_path, output) 316 | iface.messageBar().pushMessage( 317 | "You will find the rasterized file in " + output, 318 | level=Qgis.Info, 319 | duration=5, 320 | ) 321 | iface.addRasterLayer(output, "deepbands-datasets") 322 | 323 | fn_ras_path = fn_ras.dataProvider().dataSourceUri() 324 | splitting( 325 | fn_ras_path, 326 | image_Paddle_path, 327 | "jpg", 328 | "JPEG", 329 | "", 330 | SplittingSize, 331 | SplittingSize, 332 | currentrasterlay, 333 | ) 334 | splitting( 335 | output, 336 | label_Paddle_path, 337 | "png", 338 | "PNG", 339 | "", 340 | SplittingSize, 341 | SplittingSize, 342 | currentrasterlay, 343 | ) # should be the same name of image. vector name if needed-> currentvectorlay 344 | 345 | # ** Ins Seg with OPENCV ** 346 | 347 | # save_path_InSeg = str(self.dlg.mQfwLabels_InSeg.filePath()) 348 | # names = os.listdir(label_Paddle_path) 349 | # names = [f for f in os.listdir( 350 | # label_Paddle_path) if f.endswith(".png")] 351 | # if self.dlg.checkBoxInSeg.isChecked(): 352 | # for name in names: 353 | # label = osp.join(label_Paddle_path, name) 354 | # saver = osp.join(InSeg_Paddle_path, name) 355 | # segMaskB2I(label, saver) 356 | # else: 357 | # feedback.pushInfo( 358 | # "Option instance segmentation is not selected") 359 | 360 | # ** Ins Seg with GDAL ** 361 | 362 | color_text_path = osp.join( 363 | self.plugin_dir + "/utils/color.txt") 364 | print(color_text_path) 365 | outputRasIN = osp.join( 366 | Ras_Paddle_path, currentrasterlay + "_1_255_rasterized" + ".tif") 367 | InsSegGDALout = osp.join( 368 | Ras_Paddle_path, currentrasterlay + "_Ins_Seg_rasterized" + ".tif") 369 | 370 | if self.dlg.checkBoxInSeg.isChecked(): 371 | # for name in names: 372 | # label = osp.join(label_Paddle_path, name) 373 | # saver = osp.join(InSeg_Paddle_path, name) 374 | # segMaskB2I(label, saver) 375 | rasterizeInsSeg(ras_path, vec_path, outputRasIN, 376 | InsSegGDALout, color_text_path) 377 | splitting( 378 | InsSegGDALout, 379 | InSeg_Paddle_path, 380 | "png", 381 | "PNG", 382 | "", 383 | SplittingSize, 384 | SplittingSize, 385 | currentrasterlay, 386 | ) 387 | iface.addRasterLayer( 388 | InsSegGDALout, "deepbands-datasets-InsSeg") 389 | else: 390 | feedback.pushInfo( 391 | "Option instance segmentation is not selected") 392 | 393 | if self.dlg.checkBoxPaddle.isChecked(): 394 | # dataset_path = os.path.dirname(image_Paddle_path) 395 | Training_Set = self.dlg.mOpacityWidget_Training.opacity() 396 | Val_Set = self.dlg.mOpacityWidget_Validating.opacity() 397 | Testing_Set = self.dlg.mOpacityWidget_Testing.opacity() 398 | 399 | feedback.pushInfo(str(Training_Set+Val_Set+Testing_Set)) 400 | feedback.pushInfo(str(Training_Set)) 401 | feedback.pushInfo(str(Val_Set)) 402 | feedback.pushInfo(str(Testing_Set)) 403 | 404 | args = { 405 | "dataset_root": dataset_paddle, 406 | "images_dir_name": image_Paddle_path, 407 | "labels_dir_name": label_Paddle_path, 408 | "split": [Training_Set, Val_Set, Testing_Set], 409 | "label_class": ["__background__", "__foreground__"], 410 | "separator": " ", 411 | "format": ["jpg", "png"], 412 | "postfix": ["", ""], 413 | } 414 | generate_list(args) 415 | 416 | if self.dlg.checkBoxCOCO.isChecked(): 417 | # COCO Dataset Paths 418 | dataset_COCO = osp.join(dataset_path, "COCO") 419 | mkdir_p(dataset_COCO) 420 | Ras_COCO_path = osp.join(dataset_COCO, "image/") 421 | annotations_COCO_path = osp.join(dataset_COCO, "annotations/") 422 | mkdir_p(Ras_COCO_path) 423 | mkdir_p(annotations_COCO_path) 424 | 425 | # TODO: the cut image is not repeated, 426 | # and the cut image is used to directly generate coco format 427 | clip_from_file(SplittingSize, dataset_COCO, ras_path, vec_path) 428 | slice(dataset_COCO, train=Training_Set, 429 | eval=Val_Set, test=Testing_Set) 430 | from_mask_to_coco(dataset_COCO, 'train', 431 | "image", "annotations") 432 | from_mask_to_coco(dataset_COCO, 'eval', "image", "annotations") 433 | from_mask_to_coco(dataset_COCO, 'test', "image", "annotations") 434 | 435 | iface.messageBar().pushMessage( 436 | "You will find the dataset in " + dataset_path, 437 | level=Qgis.Success, 438 | duration=5, 439 | ) 440 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/split_rs_data_dialog.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | SplitRSDataDialog 5 | A QGIS plugin 6 | tools to handle raster and vector data to split it into small pieces equaled in size for machine learning datasets 7 | Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ 8 | ------------------- 9 | begin : 2021-12-08 10 | git sha : $Format:%H$ 11 | copyright : (C) 2021 by Youssef Harby 12 | email : youssef_harby@yahoo.com 13 | ***************************************************************************/ 14 | 15 | /*************************************************************************** 16 | * * 17 | * This program is free software; you can redistribute it and/or modify * 18 | * it under the terms of the GNU General Public License as published by * 19 | * the Free Software Foundation; either version 2 of the License, or * 20 | * (at your option) any later version. * 21 | * * 22 | ***************************************************************************/ 23 | """ 24 | 25 | import os 26 | 27 | from qgis.PyQt import uic 28 | from qgis.PyQt import QtWidgets 29 | 30 | # This loads your .ui file so that PyQt can populate your plugin with the elements from Qt Designer 31 | FORM_CLASS, _ = uic.loadUiType(os.path.join( 32 | os.path.dirname(__file__), 'split_rs_data_dialog_base.ui')) 33 | 34 | 35 | class SplitRSDataDialog(QtWidgets.QDialog, FORM_CLASS): 36 | def __init__(self, parent=None): 37 | """Constructor.""" 38 | super(SplitRSDataDialog, self).__init__(parent) 39 | # Set up the user interface from Designer through FORM_CLASS. 40 | # After self.setupUi() you can access any designer object by doing 41 | # self., and you can use autoconnect slots - see 42 | # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html 43 | # #widgets-and-dialogs-with-auto-connect 44 | self.setupUi(self) 45 | # self.tabWidget.currentChanged.connect(self.tabChanged) 46 | # tabInd = self.tabWidget.currentIndex() 47 | 48 | # def tabChanged(self): 49 | # tabIndex = self.tabWidget.currentIndex() 50 | # print ('tab was changed to', self.tabWidget.currentIndex()) -------------------------------------------------------------------------------- /deep-learning-datasets-maker/split_rs_data_dialog_base.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | SplitRSDataDialogBase 4 | 5 | 6 | 7 | 0 8 | 0 9 | 440 10 | 410 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | 21 | 440 22 | 410 23 | 24 | 25 | 26 | 27 | 440 28 | 410 29 | 30 | 31 | 32 | Deep Learning Datasets Maker 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 176 42 | 0 43 | 44 | 45 | 46 | 47 | 176 48 | 16777215 49 | 50 | 51 | 52 | Input Raster Layer 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 0 61 | 0 62 | 63 | 64 | 65 | 66 | 230 67 | 27 68 | 69 | 70 | 71 | 72 | 230 73 | 16777215 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 176 87 | 0 88 | 89 | 90 | 91 | 92 | 176 93 | 16777215 94 | 95 | 96 | 97 | Input Vector Layer 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 0 106 | 0 107 | 108 | 109 | 110 | 111 | 230 112 | 27 113 | 114 | 115 | 116 | 117 | 230 118 | 16777215 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 176 132 | 16 133 | 134 | 135 | 136 | 137 | 176 138 | 16 139 | 140 | 141 | 142 | Splitting Image Size 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 0 151 | 0 152 | 153 | 154 | 155 | 156 | 100 157 | 22 158 | 159 | 160 | 161 | 162 | 100 163 | 22 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | Qt::Horizontal 172 | 173 | 174 | QSizePolicy::Expanding 175 | 176 | 177 | 178 | 18 179 | 20 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 176 193 | 0 194 | 195 | 196 | 197 | 198 | 176 199 | 16777215 200 | 201 | 202 | 203 | Output Dataset Location 204 | 205 | 206 | 207 | 208 | 209 | 210 | QgsFileWidget::GetDirectory 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | Instance Segmentation 220 | 221 | 222 | 223 | 224 | 225 | 226 | true 227 | 228 | 229 | Export COCO 230 | 231 | 232 | 233 | 234 | 235 | 236 | false 237 | 238 | 239 | Spilit Custom Dataset and Generate File List 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | true 249 | 250 | 251 | 252 | 176 253 | 0 254 | 255 | 256 | 257 | 258 | 176 259 | 16777215 260 | 261 | 262 | 263 | Training 264 | 265 | 266 | 267 | 268 | 269 | 270 | true 271 | 272 | 273 | 0.600000000000000 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 176 286 | 0 287 | 288 | 289 | 290 | 291 | 176 292 | 16777215 293 | 294 | 295 | 296 | Validating 297 | 298 | 299 | 300 | 301 | 302 | 303 | 0.200000000000000 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 176 316 | 0 317 | 318 | 319 | 320 | 321 | 176 322 | 16777215 323 | 324 | 325 | 326 | Testing 327 | 328 | 329 | 330 | 331 | 332 | 333 | false 334 | 335 | 336 | 0.200000000000000 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 200 349 | 0 350 | 351 | 352 | 353 | <html><head/><body><p>Visit <a href="https://github.com/deepbands/deep-learning-datasets-maker"><span style=" text-decoration: underline; color:#0057ae;">deepbands GitHub</span></a></p></body></html> 354 | 355 | 356 | Qt::AutoText 357 | 358 | 359 | true 360 | 361 | 362 | true 363 | 364 | 365 | 366 | 367 | 368 | 369 | Qt::Horizontal 370 | 371 | 372 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | QgsFileWidget 383 | QWidget 384 |
qgsfilewidget.h
385 |
386 | 387 | QgsMapLayerComboBox 388 | QComboBox 389 |
qgsmaplayercombobox.h
390 |
391 | 392 | QgsOpacityWidget 393 | QWidget 394 |
qgsopacitywidget.h
395 |
396 |
397 | 398 | 399 | 400 | button_box 401 | accepted() 402 | SplitRSDataDialogBase 403 | accept() 404 | 405 | 406 | 20 407 | 20 408 | 409 | 410 | 20 411 | 20 412 | 413 | 414 | 415 | 416 | button_box 417 | rejected() 418 | SplitRSDataDialogBase 419 | reject() 420 | 421 | 422 | 20 423 | 20 424 | 425 | 426 | 20 427 | 20 428 | 429 | 430 | 431 | 432 |
433 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/__init__.py: -------------------------------------------------------------------------------- 1 | # import qgis libs so that ve set the correct sip api version 2 | import qgis # pylint: disable=W0611 # NOQA -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/qgis_interface.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """QGIS plugin implementation. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | .. note:: This source code was copied from the 'postgis viewer' application 10 | with original authors: 11 | Copyright (c) 2010 by Ivan Mincik, ivan.mincik@gista.sk 12 | Copyright (c) 2011 German Carrillo, geotux_tuxman@linuxmail.org 13 | Copyright (c) 2014 Tim Sutton, tim@linfiniti.com 14 | 15 | """ 16 | 17 | __author__ = 'tim@linfiniti.com' 18 | __revision__ = '$Format:%H$' 19 | __date__ = '10/01/2011' 20 | __copyright__ = ( 21 | 'Copyright (c) 2010 by Ivan Mincik, ivan.mincik@gista.sk and ' 22 | 'Copyright (c) 2011 German Carrillo, geotux_tuxman@linuxmail.org' 23 | 'Copyright (c) 2014 Tim Sutton, tim@linfiniti.com' 24 | ) 25 | 26 | import logging 27 | from qgis.PyQt.QtCore import QObject, pyqtSlot, pyqtSignal 28 | from qgis.core import QgsMapLayerRegistry 29 | from qgis.gui import QgsMapCanvasLayer 30 | LOGGER = logging.getLogger('QGIS') 31 | 32 | 33 | #noinspection PyMethodMayBeStatic,PyPep8Naming 34 | class QgisInterface(QObject): 35 | """Class to expose QGIS objects and functions to plugins. 36 | 37 | This class is here for enabling us to run unit tests only, 38 | so most methods are simply stubs. 39 | """ 40 | currentLayerChanged = pyqtSignal(QgsMapCanvasLayer) 41 | 42 | def __init__(self, canvas): 43 | """Constructor 44 | :param canvas: 45 | """ 46 | QObject.__init__(self) 47 | self.canvas = canvas 48 | # Set up slots so we can mimic the behaviour of QGIS when layers 49 | # are added. 50 | LOGGER.debug('Initialising canvas...') 51 | # noinspection PyArgumentList 52 | QgsMapLayerRegistry.instance().layersAdded.connect(self.addLayers) 53 | # noinspection PyArgumentList 54 | QgsMapLayerRegistry.instance().layerWasAdded.connect(self.addLayer) 55 | # noinspection PyArgumentList 56 | QgsMapLayerRegistry.instance().removeAll.connect(self.removeAllLayers) 57 | 58 | # For processing module 59 | self.destCrs = None 60 | 61 | @pyqtSlot('QStringList') 62 | def addLayers(self, layers): 63 | """Handle layers being added to the registry so they show up in canvas. 64 | 65 | :param layers: list list of map layers that were added 66 | 67 | .. note:: The QgsInterface api does not include this method, 68 | it is added here as a helper to facilitate testing. 69 | """ 70 | #LOGGER.debug('addLayers called on qgis_interface') 71 | #LOGGER.debug('Number of layers being added: %s' % len(layers)) 72 | #LOGGER.debug('Layer Count Before: %s' % len(self.canvas.layers())) 73 | current_layers = self.canvas.layers() 74 | final_layers = [] 75 | for layer in current_layers: 76 | final_layers.append(QgsMapCanvasLayer(layer)) 77 | for layer in layers: 78 | final_layers.append(QgsMapCanvasLayer(layer)) 79 | 80 | self.canvas.setLayerSet(final_layers) 81 | #LOGGER.debug('Layer Count After: %s' % len(self.canvas.layers())) 82 | 83 | @pyqtSlot('QgsMapLayer') 84 | def addLayer(self, layer): 85 | """Handle a layer being added to the registry so it shows up in canvas. 86 | 87 | :param layer: list list of map layers that were added 88 | 89 | .. note: The QgsInterface api does not include this method, it is added 90 | here as a helper to facilitate testing. 91 | 92 | .. note: The addLayer method was deprecated in QGIS 1.8 so you should 93 | not need this method much. 94 | """ 95 | pass 96 | 97 | @pyqtSlot() 98 | def removeAllLayers(self): 99 | """Remove layers from the canvas before they get deleted.""" 100 | self.canvas.setLayerSet([]) 101 | 102 | def newProject(self): 103 | """Create new project.""" 104 | # noinspection PyArgumentList 105 | QgsMapLayerRegistry.instance().removeAllMapLayers() 106 | 107 | # ---------------- API Mock for QgsInterface follows ------------------- 108 | 109 | def zoomFull(self): 110 | """Zoom to the map full extent.""" 111 | pass 112 | 113 | def zoomToPrevious(self): 114 | """Zoom to previous view extent.""" 115 | pass 116 | 117 | def zoomToNext(self): 118 | """Zoom to next view extent.""" 119 | pass 120 | 121 | def zoomToActiveLayer(self): 122 | """Zoom to extent of active layer.""" 123 | pass 124 | 125 | def addVectorLayer(self, path, base_name, provider_key): 126 | """Add a vector layer. 127 | 128 | :param path: Path to layer. 129 | :type path: str 130 | 131 | :param base_name: Base name for layer. 132 | :type base_name: str 133 | 134 | :param provider_key: Provider key e.g. 'ogr' 135 | :type provider_key: str 136 | """ 137 | pass 138 | 139 | def addRasterLayer(self, path, base_name): 140 | """Add a raster layer given a raster layer file name 141 | 142 | :param path: Path to layer. 143 | :type path: str 144 | 145 | :param base_name: Base name for layer. 146 | :type base_name: str 147 | """ 148 | pass 149 | 150 | def activeLayer(self): 151 | """Get pointer to the active layer (layer selected in the legend).""" 152 | # noinspection PyArgumentList 153 | layers = QgsMapLayerRegistry.instance().mapLayers() 154 | for item in layers: 155 | return layers[item] 156 | 157 | def addToolBarIcon(self, action): 158 | """Add an icon to the plugins toolbar. 159 | 160 | :param action: Action to add to the toolbar. 161 | :type action: QAction 162 | """ 163 | pass 164 | 165 | def removeToolBarIcon(self, action): 166 | """Remove an action (icon) from the plugin toolbar. 167 | 168 | :param action: Action to add to the toolbar. 169 | :type action: QAction 170 | """ 171 | pass 172 | 173 | def addToolBar(self, name): 174 | """Add toolbar with specified name. 175 | 176 | :param name: Name for the toolbar. 177 | :type name: str 178 | """ 179 | pass 180 | 181 | def mapCanvas(self): 182 | """Return a pointer to the map canvas.""" 183 | return self.canvas 184 | 185 | def mainWindow(self): 186 | """Return a pointer to the main window. 187 | 188 | In case of QGIS it returns an instance of QgisApp. 189 | """ 190 | pass 191 | 192 | def addDockWidget(self, area, dock_widget): 193 | """Add a dock widget to the main window. 194 | 195 | :param area: Where in the ui the dock should be placed. 196 | :type area: 197 | 198 | :param dock_widget: A dock widget to add to the UI. 199 | :type dock_widget: QDockWidget 200 | """ 201 | pass 202 | 203 | def legendInterface(self): 204 | """Get the legend.""" 205 | return self.canvas 206 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/tenbytenraster.asc: -------------------------------------------------------------------------------- 1 | NCOLS 10 2 | NROWS 10 3 | XLLCENTER 1535380.000000 4 | YLLCENTER 5083260.000000 5 | DX 10 6 | DY 10 7 | NODATA_VALUE -9999 8 | 0 1 2 3 4 5 6 7 8 9 9 | 0 1 2 3 4 5 6 7 8 9 10 | 0 1 2 3 4 5 6 7 8 9 11 | 0 1 2 3 4 5 6 7 8 9 12 | 0 1 2 3 4 5 6 7 8 9 13 | 0 1 2 3 4 5 6 7 8 9 14 | 0 1 2 3 4 5 6 7 8 9 15 | 0 1 2 3 4 5 6 7 8 9 16 | 0 1 2 3 4 5 6 7 8 9 17 | 0 1 2 3 4 5 6 7 8 9 18 | CRS 19 | NOTES 20 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/tenbytenraster.asc.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Point 4 | 5 | 6 | 7 | 9 8 | 4.5 9 | 0 10 | 2.872281323269 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/tenbytenraster.keywords: -------------------------------------------------------------------------------- 1 | title: Tenbytenraster 2 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/tenbytenraster.lic: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tim Sutton, Linfiniti Consulting CC 5 | 6 | 7 | 8 | tenbytenraster.asc 9 | 2700044251 10 | Yes 11 | Tim Sutton 12 | Tim Sutton (QGIS Source Tree) 13 | Tim Sutton 14 | This data is publicly available from QGIS Source Tree. The original 15 | file was created and contributed to QGIS by Tim Sutton. 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/tenbytenraster.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/tenbytenraster.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 0 26 | 27 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/test_init.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Tests QGIS plugin init.""" 3 | 4 | __author__ = 'Tim Sutton ' 5 | __revision__ = '$Format:%H$' 6 | __date__ = '17/10/2010' 7 | __license__ = "GPL" 8 | __copyright__ = 'Copyright 2012, Australia Indonesia Facility for ' 9 | __copyright__ += 'Disaster Reduction' 10 | 11 | import os 12 | import unittest 13 | import logging 14 | import configparser 15 | 16 | LOGGER = logging.getLogger('QGIS') 17 | 18 | 19 | class TestInit(unittest.TestCase): 20 | """Test that the plugin init is usable for QGIS. 21 | 22 | Based heavily on the validator class by Alessandro 23 | Passoti available here: 24 | 25 | http://github.com/qgis/qgis-django/blob/master/qgis-app/ 26 | plugins/validator.py 27 | 28 | """ 29 | 30 | def test_read_init(self): 31 | """Test that the plugin __init__ will validate on plugins.qgis.org.""" 32 | 33 | # You should update this list according to the latest in 34 | # https://github.com/qgis/qgis-django/blob/master/qgis-app/ 35 | # plugins/validator.py 36 | 37 | required_metadata = [ 38 | 'name', 39 | 'description', 40 | 'version', 41 | 'qgisMinimumVersion', 42 | 'email', 43 | 'author'] 44 | 45 | file_path = os.path.abspath(os.path.join( 46 | os.path.dirname(__file__), os.pardir, 47 | 'metadata.txt')) 48 | LOGGER.info(file_path) 49 | metadata = [] 50 | parser = configparser.ConfigParser() 51 | parser.optionxform = str 52 | parser.read(file_path) 53 | message = 'Cannot find a section named "general" in %s' % file_path 54 | assert parser.has_section('general'), message 55 | metadata.extend(parser.items('general')) 56 | 57 | for expectation in required_metadata: 58 | message = ('Cannot find metadata "%s" in metadata source (%s).' % ( 59 | expectation, file_path)) 60 | 61 | self.assertIn(expectation, dict(metadata), message) 62 | 63 | if __name__ == '__main__': 64 | unittest.main() 65 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/test_qgis_environment.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Tests for QGIS functionality. 3 | 4 | 5 | .. note:: This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | """ 11 | __author__ = 'tim@linfiniti.com' 12 | __date__ = '20/01/2011' 13 | __copyright__ = ('Copyright 2012, Australia Indonesia Facility for ' 14 | 'Disaster Reduction') 15 | 16 | import os 17 | import unittest 18 | from qgis.core import ( 19 | QgsProviderRegistry, 20 | QgsCoordinateReferenceSystem, 21 | QgsRasterLayer) 22 | 23 | from .utilities import get_qgis_app 24 | QGIS_APP = get_qgis_app() 25 | 26 | 27 | class QGISTest(unittest.TestCase): 28 | """Test the QGIS Environment""" 29 | 30 | def test_qgis_environment(self): 31 | """QGIS environment has the expected providers""" 32 | 33 | r = QgsProviderRegistry.instance() 34 | self.assertIn('gdal', r.providerList()) 35 | self.assertIn('ogr', r.providerList()) 36 | self.assertIn('postgres', r.providerList()) 37 | 38 | def test_projection(self): 39 | """Test that QGIS properly parses a wkt string. 40 | """ 41 | crs = QgsCoordinateReferenceSystem() 42 | wkt = ( 43 | 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",' 44 | 'SPHEROID["WGS_1984",6378137.0,298.257223563]],' 45 | 'PRIMEM["Greenwich",0.0],UNIT["Degree",' 46 | '0.0174532925199433]]') 47 | crs.createFromWkt(wkt) 48 | auth_id = crs.authid() 49 | expected_auth_id = 'EPSG:4326' 50 | self.assertEqual(auth_id, expected_auth_id) 51 | 52 | # now test for a loaded layer 53 | path = os.path.join(os.path.dirname(__file__), 'tenbytenraster.asc') 54 | title = 'TestRaster' 55 | layer = QgsRasterLayer(path, title) 56 | auth_id = layer.crs().authid() 57 | self.assertEqual(auth_id, expected_auth_id) 58 | 59 | if __name__ == '__main__': 60 | unittest.main() 61 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/test_resources.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Resources test. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | """ 10 | 11 | __author__ = 'youssef_harby@yahoo.com' 12 | __date__ = '2021-12-08' 13 | __copyright__ = 'Copyright 2021, Youssef Harby' 14 | 15 | import unittest 16 | 17 | from qgis.PyQt.QtGui import QIcon 18 | 19 | 20 | 21 | class SplitRSDataDialogTest(unittest.TestCase): 22 | """Test rerources work.""" 23 | 24 | def setUp(self): 25 | """Runs before each test.""" 26 | pass 27 | 28 | def tearDown(self): 29 | """Runs after each test.""" 30 | pass 31 | 32 | def test_icon_png(self): 33 | """Test we can click OK.""" 34 | path = ':/plugins/SplitRSData/icon.png' 35 | icon = QIcon(path) 36 | self.assertFalse(icon.isNull()) 37 | 38 | if __name__ == "__main__": 39 | suite = unittest.makeSuite(SplitRSDataResourcesTest) 40 | runner = unittest.TextTestRunner(verbosity=2) 41 | runner.run(suite) 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/test_split_rs_data_dialog.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Dialog test. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | """ 10 | 11 | __author__ = 'youssef_harby@yahoo.com' 12 | __date__ = '2021-12-08' 13 | __copyright__ = 'Copyright 2021, Youssef Harby' 14 | 15 | import unittest 16 | 17 | from qgis.PyQt.QtGui import QDialogButtonBox, QDialog 18 | 19 | from split_rs_data_dialog import SplitRSDataDialog 20 | 21 | from utilities import get_qgis_app 22 | QGIS_APP = get_qgis_app() 23 | 24 | 25 | class SplitRSDataDialogTest(unittest.TestCase): 26 | """Test dialog works.""" 27 | 28 | def setUp(self): 29 | """Runs before each test.""" 30 | self.dialog = SplitRSDataDialog(None) 31 | 32 | def tearDown(self): 33 | """Runs after each test.""" 34 | self.dialog = None 35 | 36 | def test_dialog_ok(self): 37 | """Test we can click OK.""" 38 | 39 | button = self.dialog.button_box.button(QDialogButtonBox.Ok) 40 | button.click() 41 | result = self.dialog.result() 42 | self.assertEqual(result, QDialog.Accepted) 43 | 44 | def test_dialog_cancel(self): 45 | """Test we can click cancel.""" 46 | button = self.dialog.button_box.button(QDialogButtonBox.Cancel) 47 | button.click() 48 | result = self.dialog.result() 49 | self.assertEqual(result, QDialog.Rejected) 50 | 51 | if __name__ == "__main__": 52 | suite = unittest.makeSuite(SplitRSDataDialogTest) 53 | runner = unittest.TextTestRunner(verbosity=2) 54 | runner.run(suite) 55 | 56 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/test_translations.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Safe Translations Test. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | """ 10 | from .utilities import get_qgis_app 11 | 12 | __author__ = 'ismailsunni@yahoo.co.id' 13 | __date__ = '12/10/2011' 14 | __copyright__ = ('Copyright 2012, Australia Indonesia Facility for ' 15 | 'Disaster Reduction') 16 | import unittest 17 | import os 18 | 19 | from qgis.PyQt.QtCore import QCoreApplication, QTranslator 20 | 21 | QGIS_APP = get_qgis_app() 22 | 23 | 24 | class SafeTranslationsTest(unittest.TestCase): 25 | """Test translations work.""" 26 | 27 | def setUp(self): 28 | """Runs before each test.""" 29 | if 'LANG' in iter(os.environ.keys()): 30 | os.environ.__delitem__('LANG') 31 | 32 | def tearDown(self): 33 | """Runs after each test.""" 34 | if 'LANG' in iter(os.environ.keys()): 35 | os.environ.__delitem__('LANG') 36 | 37 | def test_qgis_translations(self): 38 | """Test that translations work.""" 39 | parent_path = os.path.join(__file__, os.path.pardir, os.path.pardir) 40 | dir_path = os.path.abspath(parent_path) 41 | file_path = os.path.join( 42 | dir_path, 'i18n', 'af.qm') 43 | translator = QTranslator() 44 | translator.load(file_path) 45 | QCoreApplication.installTranslator(translator) 46 | 47 | expected_message = 'Goeie more' 48 | real_message = QCoreApplication.translate("@default", 'Good morning') 49 | self.assertEqual(real_message, expected_message) 50 | 51 | 52 | if __name__ == "__main__": 53 | suite = unittest.makeSuite(SafeTranslationsTest) 54 | runner = unittest.TextTestRunner(verbosity=2) 55 | runner.run(suite) 56 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/test/utilities.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Common functionality used by regression tests.""" 3 | 4 | import sys 5 | import logging 6 | 7 | 8 | LOGGER = logging.getLogger('QGIS') 9 | QGIS_APP = None # Static variable used to hold hand to running QGIS app 10 | CANVAS = None 11 | PARENT = None 12 | IFACE = None 13 | 14 | 15 | def get_qgis_app(): 16 | """ Start one QGIS application to test against. 17 | 18 | :returns: Handle to QGIS app, canvas, iface and parent. If there are any 19 | errors the tuple members will be returned as None. 20 | :rtype: (QgsApplication, CANVAS, IFACE, PARENT) 21 | 22 | If QGIS is already running the handle to that app will be returned. 23 | """ 24 | 25 | try: 26 | from qgis.PyQt import QtGui, QtCore 27 | from qgis.core import QgsApplication 28 | from qgis.gui import QgsMapCanvas 29 | from .qgis_interface import QgisInterface 30 | except ImportError: 31 | return None, None, None, None 32 | 33 | global QGIS_APP # pylint: disable=W0603 34 | 35 | if QGIS_APP is None: 36 | gui_flag = True # All test will run qgis in gui mode 37 | #noinspection PyPep8Naming 38 | QGIS_APP = QgsApplication(sys.argv, gui_flag) 39 | # Make sure QGIS_PREFIX_PATH is set in your env if needed! 40 | QGIS_APP.initQgis() 41 | s = QGIS_APP.showSettings() 42 | LOGGER.debug(s) 43 | 44 | global PARENT # pylint: disable=W0603 45 | if PARENT is None: 46 | #noinspection PyPep8Naming 47 | PARENT = QtGui.QWidget() 48 | 49 | global CANVAS # pylint: disable=W0603 50 | if CANVAS is None: 51 | #noinspection PyPep8Naming 52 | CANVAS = QgsMapCanvas(PARENT) 53 | CANVAS.resize(QtCore.QSize(400, 400)) 54 | 55 | global IFACE # pylint: disable=W0603 56 | if IFACE is None: 57 | # QgisInterface is a stub implementation of the QGIS plugin interface 58 | #noinspection PyPep8Naming 59 | IFACE = QgisInterface(CANVAS) 60 | 61 | return QGIS_APP, CANVAS, IFACE, PARENT 62 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/COCO/__init__.py: -------------------------------------------------------------------------------- 1 | from .shape_to_coco import clip_from_file, slice, from_mask_to_coco -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/COCO/pycococreatortools/__init__.py: -------------------------------------------------------------------------------- 1 | from .pycococreatortools import * -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/COCO/pycococreatortools/pycococreatortools.py: -------------------------------------------------------------------------------- 1 | import re 2 | import datetime 3 | import numpy as np 4 | from itertools import groupby 5 | from pycocotools import mask 6 | from skimage import measure 7 | from PIL import Image 8 | 9 | 10 | def convert(text): return int(text) if text.isdigit() else text.lower() 11 | 12 | 13 | def natrual_key(key): return [convert(c) for c in re.split('([0-9]+)', key)] 14 | 15 | 16 | def resize_binary_mask(array, new_size): 17 | image = Image.fromarray(array.astype(np.uint8)*255) 18 | image = image.resize(new_size) 19 | return np.asarray(image).astype(np.bool_) 20 | 21 | 22 | def close_contour(contour): 23 | if not np.array_equal(contour[0], contour[-1]): 24 | contour = np.vstack((contour, contour[0])) 25 | return contour 26 | 27 | 28 | def binary_mask_to_rle(binary_mask): 29 | rle = {'counts': [], 'size': list(binary_mask.shape)} 30 | counts = rle.get('counts') 31 | for i, (value, elements) in enumerate(groupby(binary_mask.ravel(order='F'))): 32 | if i == 0 and value == 1: 33 | counts.append(0) 34 | counts.append(len(list(elements))) 35 | 36 | return rle 37 | 38 | 39 | def binary_mask_to_polygon(binary_mask, tolerance=0): 40 | """Converts a binary mask to COCO polygon representation 41 | 42 | Args: 43 | binary_mask: a 2D binary numpy array where '1's represent the object 44 | tolerance: Maximum distance from original points of polygon to approximated 45 | polygonal chain. If tolerance is 0, the original coordinate array is returned. 46 | 47 | """ 48 | polygons = [] 49 | # pad mask to close contours of shapes which start and end at an edge 50 | padded_binary_mask = np.pad( 51 | binary_mask, pad_width=1, mode='constant', constant_values=0) 52 | contours = measure.find_contours(padded_binary_mask, 0.5) 53 | contours = np.subtract(contours, 1) 54 | for contour in contours: 55 | contour = close_contour(contour) 56 | contour = measure.approximate_polygon(contour, tolerance) 57 | if len(contour) < 3: 58 | continue 59 | contour = np.flip(contour, axis=1) 60 | segmentation = contour.ravel().tolist() 61 | # after padding and subtracting 1 we may get -0.5 points in our segmentation 62 | segmentation = [0 if i < 0 else i for i in segmentation] 63 | polygons.append(segmentation) 64 | 65 | return polygons 66 | 67 | 68 | def create_image_info(image_id, file_name, image_size, 69 | date_captured=datetime.datetime.utcnow().isoformat(' '), 70 | license_id=1, coco_url="", flickr_url=""): 71 | 72 | image_info = { 73 | "id": image_id, 74 | "file_name": file_name, 75 | "width": image_size[0], 76 | "height": image_size[1], 77 | "date_captured": date_captured, 78 | "license": license_id, 79 | "coco_url": coco_url, 80 | "flickr_url": flickr_url 81 | } 82 | 83 | return image_info 84 | 85 | 86 | def create_annotation_info(annotation_id, image_id, category_info, binary_mask, 87 | image_size=None, tolerance=2, bounding_box=None): 88 | 89 | if image_size is not None: 90 | binary_mask = resize_binary_mask(binary_mask, image_size) 91 | 92 | binary_mask_encoded = mask.encode( 93 | np.asfortranarray(binary_mask.astype(np.uint8))) 94 | 95 | area = mask.area(binary_mask_encoded) 96 | if area < 1: 97 | return None 98 | 99 | if bounding_box is None: 100 | bounding_box = mask.toBbox(binary_mask_encoded) 101 | 102 | if category_info["is_crowd"]: 103 | is_crowd = 1 104 | segmentation = binary_mask_to_rle(binary_mask) 105 | else: 106 | is_crowd = 0 107 | segmentation = binary_mask_to_polygon(binary_mask, tolerance) 108 | if not segmentation: 109 | return None 110 | 111 | annotation_info = { 112 | "id": annotation_id, 113 | "image_id": image_id, 114 | "category_id": category_info["id"], 115 | "iscrowd": is_crowd, 116 | "area": area.tolist(), 117 | "bbox": bounding_box.tolist(), 118 | "segmentation": segmentation, 119 | "width": binary_mask.shape[1], 120 | "height": binary_mask.shape[0], 121 | } 122 | 123 | return annotation_info 124 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/COCO/shape_to_coco.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import datetime 4 | import json 5 | import os 6 | import re 7 | import fnmatch 8 | from PIL import Image 9 | import numpy as np 10 | from .pycococreatortools import * 11 | from .tif_process import * 12 | from .slice_dataset import slice 13 | 14 | # root path for saving the tif and shp file. 15 | ROOT = r'./example_data/original_data' 16 | img_path = 'img' 17 | shp_path = 'shp' 18 | # root path for saving the mask. 19 | ROOT_DIR = ROOT + '/dataset' 20 | IMAGE_DIR = os.path.join(ROOT_DIR, "image") 21 | ANNOTATION_DIR = os.path.join(ROOT_DIR, "annotations") 22 | 23 | clip_size = 512 24 | 25 | INFO = { 26 | "description": "Image Dataset", 27 | "url": "", 28 | "version": "0.1.0", 29 | "year": 2021, 30 | "contributor": "", 31 | "date_created": datetime.datetime.utcnow().isoformat(' ') 32 | } 33 | 34 | LICENSES = [ 35 | { 36 | "id": 1, 37 | "name": "", 38 | "url": "" 39 | } 40 | ] 41 | 42 | CATEGORIES = [ 43 | { 44 | 'id': 1, 45 | 'name': 'image', 46 | 'supercategory': 'building', 47 | }, 48 | ] 49 | 50 | def filter_for_jpeg(root, files): 51 | # file_types = ['*.jpeg', '*.jpg'] 52 | file_types = ['*.tiff', '*.tif'] 53 | file_types = r'|'.join([fnmatch.translate(x) for x in file_types]) 54 | files = [os.path.join(root, f) for f in files] 55 | files = [f for f in files if re.match(file_types, f)] 56 | 57 | return files 58 | 59 | def filter_for_annotations(root, files, image_filename): 60 | # file_types = ['*.png'] 61 | file_types = ['*.tif'] 62 | file_types = r'|'.join([fnmatch.translate(x) for x in file_types]) 63 | basename_no_extension = os.path.splitext(os.path.basename(image_filename))[0] 64 | # file_name_prefix = basename_no_extension + '.*' 65 | files = [os.path.join(root, f) for f in files] 66 | files = [f for f in files if re.match(file_types, f)] 67 | # files = [f for f in files if re.match(file_name_prefix, os.path.splitext(os.path.basename(f))[0])] 68 | files = [f for f in files if basename_no_extension == os.path.splitext(os.path.basename(f))[0].split('_', 1)[0]] 69 | 70 | return files 71 | 72 | def from_mask_to_coco(root, MARK, IMAGE, ANNOTATION): 73 | ROOT_DIR = root + '/' + MARK 74 | IMAGE_DIR = ROOT_DIR + '/' + IMAGE 75 | ANNOTATION_DIR = ROOT_DIR + '/' + ANNOTATION 76 | if os.path.exists(ROOT_DIR): 77 | coco_output = { 78 | "info": INFO, 79 | "licenses": LICENSES, 80 | "categories": CATEGORIES, 81 | "images": [], 82 | "annotations": [] 83 | } 84 | 85 | image_id = 1 86 | segmentation_id = 1 87 | 88 | # filter for jpeg images 89 | for root, _, files in os.walk(IMAGE_DIR): 90 | image_files = filter_for_jpeg(root, files) 91 | 92 | # go through each image 93 | for image_filename in image_files: 94 | image = Image.open(image_filename) 95 | image_info = create_image_info( 96 | image_id, os.path.basename(image_filename), image.size) 97 | coco_output["images"].append(image_info) 98 | 99 | # filter for associated png annotations 100 | for root, _, files in os.walk(ANNOTATION_DIR): 101 | annotation_files = filter_for_annotations(root, files, image_filename) 102 | 103 | # go through each associated annotation 104 | for annotation_filename in annotation_files: 105 | 106 | print(annotation_filename) 107 | class_id = [x['id'] for x in CATEGORIES if x['name'] in annotation_filename][0] 108 | 109 | category_info = {'id': class_id, 'is_crowd': 'crowd' in image_filename} 110 | binary_mask = np.asarray(Image.open(annotation_filename) 111 | .convert('1')).astype(np.uint8) 112 | 113 | annotation_info = create_annotation_info( 114 | segmentation_id, image_id, category_info, binary_mask, 115 | image.size, tolerance=2) 116 | 117 | if annotation_info is not None: 118 | coco_output["annotations"].append(annotation_info) 119 | 120 | segmentation_id = segmentation_id + 1 121 | 122 | image_id = image_id + 1 123 | 124 | with open('{}/instances_image_{}2019.json'.format(ROOT_DIR, MARK), 'w') as output_json_file: 125 | json.dump(coco_output, output_json_file) 126 | else: 127 | print(ROOT_DIR + ' does not exit!') 128 | 129 | def main(): 130 | clip_from_file(clip_size, ROOT, img_path, shp_path) 131 | slice(ROOT_DIR, train=0.6, eval=0.2, test=0.2) 132 | from_mask_to_coco(ROOT_DIR, 'train', "image", "annotations") 133 | from_mask_to_coco(ROOT_DIR, 'eval', "image", "annotations") 134 | from_mask_to_coco(ROOT_DIR, 'test', "image", "annotations") 135 | 136 | if __name__ == "__main__": 137 | main() 138 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/COCO/slice_dataset.py: -------------------------------------------------------------------------------- 1 | import os 2 | import numpy as np 3 | import shutil 4 | import re 5 | import fnmatch 6 | 7 | ann_path = 'annotations' 8 | img_path = 'image' 9 | 10 | def filter_for_annotations(root, files, image_filename): 11 | # file_types = ['*.png'] 12 | file_types = ['*.tif'] 13 | file_types = r'|'.join([fnmatch.translate(x) for x in file_types]) 14 | basename_no_extension = os.path.splitext(os.path.basename(image_filename))[0] 15 | # file_name_prefix = basename_no_extension + '.*' 16 | files = [os.path.join(root, f) for f in files] 17 | files = [f for f in files if re.match(file_types, f)] 18 | # files = [f for f in files if re.match(file_name_prefix, os.path.splitext(os.path.basename(f))[0])] 19 | files = [f for f in files if basename_no_extension == os.path.splitext(os.path.basename(f))[0].split('_', 1)[0]] 20 | 21 | return files 22 | 23 | def copy_data(input_path, id, num, mark = 'train'): 24 | if num != 0: 25 | list = os.listdir(input_path + '/' + img_path) 26 | ann_list = os.listdir(input_path + '/' + ann_path) 27 | if not os.path.isdir(input_path + '/' + mark + '/' + img_path): 28 | os.makedirs(input_path + '/' + mark + '/' + img_path) 29 | if not os.path.isdir(input_path + '/' + mark + '/' + ann_path): 30 | os.makedirs(input_path + '/' + mark + '/' + ann_path) 31 | 32 | for i in range(num): 33 | shutil.copy(input_path + '/' + img_path + '/' + list[id[i]], input_path + '/' + mark + '/' + img_path 34 | + '/' + list[id[i]]) 35 | print('From src: ' + img_path + '/' + list[id[i]] + ' =>dst:' + '/' + mark + '/' + img_path 36 | + '/' + list[id[i]]) 37 | annotation_files = filter_for_annotations(input_path, ann_list, list[id[i]]) 38 | for j in range(len(annotation_files)): 39 | shutil.copy(input_path + '/' + ann_path + '/' + os.path.basename(annotation_files[j]), 40 | input_path + '/' + mark + '/' + ann_path + '/' + os.path.basename(annotation_files[j])) 41 | 42 | f = open(input_path + '/' + mark + '/' + mark + '.txt', 'w') 43 | f.write(str(id)) 44 | f.close() 45 | 46 | def slice(input_path, train=0.8, eval=0.2, test=0.0): 47 | """ 48 | slice the dataset into training, eval and test sub_dataset. 49 | :param input_path: path to the original dataset. 50 | :param train: the ratio of the training subset. 51 | :param eval: the ratio of the eval subset. 52 | :param test: the ratio of the test subset. 53 | """ 54 | list = os.listdir(input_path + '/' + img_path) 55 | ann_list = os.listdir(input_path + '/' + ann_path) 56 | num_list = len(list) 57 | n_train = int(num_list * train) 58 | if test == 0: 59 | n_eval = num_list - n_train 60 | n_test = 0 61 | else: 62 | n_eval = int(num_list * eval) 63 | n_test = num_list - n_train - n_eval 64 | 65 | img_id = np.arange(num_list) 66 | np.random.shuffle(img_id) 67 | train_id, eval_id, test_id = img_id[:n_train], img_id[n_train: n_train+n_eval], img_id[n_train+n_eval:] 68 | copy_data(input_path, train_id, n_train, 'train') 69 | copy_data(input_path, eval_id, n_eval, 'eval') 70 | copy_data(input_path, test_id, n_test, 'test') 71 | 72 | if __name__ == '__main__': 73 | input_path = r'./example_data/original_data/dataset' 74 | # slice(input_path, train=0.6, eval=0.2, test=0.2) 75 | slice(input_path) 76 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/COCO/tif_process.py: -------------------------------------------------------------------------------- 1 | # Date:2019.04.10 2 | # Author: DuncanChen 3 | # A tool implementation on gdal and geotool API 4 | # functions: 5 | # 1. get mask raster with shapefile 6 | # 2. clip raster and shapefile with grid 7 | 8 | import os 9 | import numpy as np 10 | import glob 11 | from PIL import Image, ImageDraw 12 | try: 13 | from osgeo import gdal, ogr, gdalnumeric 14 | except ImportError: 15 | import gdal 16 | import ogr 17 | import gdalnumeric 18 | 19 | gdal.UseExceptions() 20 | 21 | 22 | class GeoTiff(object): 23 | def __init__(self, tif_path): 24 | """ 25 | A tool for Remote Sensing Image 26 | Args: 27 | tif_path: tif path 28 | Examples:: 29 | >>> tif = GeoTif('xx.tif') 30 | # if you want to clip tif with grid reserved geo reference 31 | >>> tif.clip_tif_with_grid(512, 'out_dir') 32 | # if you want to clip tif with shape file 33 | >>> tif.clip_tif_with_shapefile('shapefile.shp', 'save_path.tif') 34 | # if you want to mask tif with shape file 35 | >>> tif.mask_tif_with_shapefile('shapefile.shp', 'save_path.tif') 36 | """ 37 | self.dataset = gdal.Open(tif_path) 38 | self.bands_count = self.dataset.RasterCount 39 | # get each band 40 | self.bands = [self.dataset.GetRasterBand( 41 | i + 1) for i in range(self.bands_count)] 42 | self.col = self.dataset.RasterXSize 43 | self.row = self.dataset.RasterYSize 44 | self.geotransform = self.dataset.GetGeoTransform() 45 | self.src_path = tif_path 46 | self.mask = None 47 | self.mark = None 48 | 49 | def get_left_top(self): 50 | return self.geotransform[3], self.geotransform[0] 51 | 52 | def get_pixel_height_width(self): 53 | return abs(self.geotransform[5]), abs(self.geotransform[1]) 54 | 55 | def __getitem__(self, *args): 56 | """ 57 | 58 | Args: 59 | *args: range, an instance of tuple, ((start, stop, step), (start, stop, step)) 60 | 61 | Returns: 62 | res: image block , array ,[bands......, height, weight] 63 | 64 | """ 65 | if isinstance(args[0], tuple) and len(args[0]) == 2: 66 | # get params 67 | start_row, end_row = args[0][0].start, args[0][0].stop 68 | start_col, end_col = args[0][1].start, args[0][1].stop 69 | start_row = 0 if start_row is None else start_row 70 | start_col = 0 if start_col is None else start_col 71 | num_row = self.row if end_row is None else (end_row - start_row) 72 | num_col = self.col if end_col is None else (end_col - start_col) 73 | # dataset read image array 74 | res = self.dataset.ReadAsArray( 75 | start_col, start_row, num_col, num_row) 76 | return res 77 | else: 78 | raise NotImplementedError('the param should be [a: b, c: d] !') 79 | 80 | def clip_tif_with_grid(self, clip_size, begin_id, out_dir): 81 | """ 82 | clip image with grid 83 | Args: 84 | clip_size: int 85 | out_dir: str 86 | 87 | Returns: 88 | 89 | """ 90 | if not os.path.exists(out_dir): 91 | # check the dir 92 | os.makedirs(out_dir) 93 | print('create dir', out_dir) 94 | 95 | row_num = int(self.row / clip_size) 96 | col_num = int(self.col / clip_size) 97 | 98 | gtiffDriver = gdal.GetDriverByName('GTiff') 99 | if gtiffDriver is None: 100 | raise ValueError("Can't find GeoTiff Driver") 101 | 102 | count = 1 103 | for i in range(row_num): 104 | for j in range(col_num): 105 | # if begin_id+i*col_num+j in self.mark: 106 | # continue 107 | clipped_image = np.array( 108 | self[i * clip_size: (i + 1) * clip_size, j * clip_size: (j + 1) * clip_size]) 109 | clipped_image = clipped_image.astype(np.int8) 110 | 111 | try: 112 | save_path = os.path.join( 113 | out_dir, '%d.tif' % (begin_id+i*col_num+j)) 114 | save_image_with_georef(clipped_image, gtiffDriver, 115 | self.dataset, j*clip_size, i*clip_size, save_path) 116 | print('clip successfully! (%d/%d)' % 117 | (count, row_num * col_num)) 118 | count += 1 119 | except Exception: 120 | raise IOError('clip failed!%d' % count) 121 | 122 | return row_num * col_num 123 | 124 | def clip_mask_with_grid(self, clip_size, begin_id, out_dir): 125 | """ 126 | clip mask with grid 127 | Args: 128 | clip_size: int 129 | out_dir: str 130 | 131 | Returns: 132 | 133 | """ 134 | if not os.path.exists(out_dir): 135 | # check the dir 136 | os.makedirs(out_dir) 137 | print('create dir', out_dir) 138 | 139 | row_num = int(self.row / clip_size) 140 | col_num = int(self.col / clip_size) 141 | 142 | gtiffDriver = gdal.GetDriverByName('GTiff') 143 | if gtiffDriver is None: 144 | raise ValueError("Can't find GeoTiff Driver") 145 | 146 | # self.mark = [] 147 | 148 | count = 1 149 | for i in range(row_num): 150 | for j in range(col_num): 151 | clipped_image = np.array( 152 | self.mask[0, i * clip_size: (i + 1) * clip_size, j * clip_size: (j + 1) * clip_size]) 153 | ins_list = np.unique(clipped_image) 154 | # if len(ins_list) <= 1: 155 | # self.mark.append(begin_id+i*col_num+j) 156 | # continue 157 | ins_list = ins_list[1:] 158 | for id in range(len(ins_list)): 159 | bg_img = np.zeros((clipped_image.shape)).astype(np.int8) 160 | if ins_list[id] > 0: 161 | bg_img[np.where(clipped_image == ins_list[id])] = 255 162 | try: 163 | save_path = os.path.join(out_dir, '%d_%s_%d.tif' % ( 164 | begin_id+i*col_num+j, 'image', id)) 165 | save_image_with_georef(bg_img, gtiffDriver, 166 | self.dataset, j*clip_size, i*clip_size, save_path) 167 | print('clip mask successfully! (%d/%d)' % 168 | (count, row_num * col_num)) 169 | count += 1 170 | except Exception: 171 | raise IOError('clip failed!%d' % count) 172 | 173 | def world2Pixel(self, x, y): 174 | """ 175 | Uses a gdal geomatrix (gdal.GetGeoTransform()) to calculate 176 | the pixel location of a geospatial coordinate 177 | """ 178 | ulY, ulX = self.get_left_top() 179 | distY, distX = self.get_pixel_height_width() 180 | 181 | pixel_x = abs(int((x - ulX) / distX)) 182 | pixel_y = abs(int((ulY - y) / distY)) 183 | pixel_y = self.row if pixel_y > self.row else pixel_y 184 | pixel_x = self.col if pixel_x > self.col else pixel_x 185 | return pixel_x, pixel_y 186 | 187 | def mask_tif_with_shapefile(self, shapefile_path, label=255): 188 | """ 189 | mask tif with shape file, supported point, line, polygon and multi polygons 190 | Args: 191 | shapefile_path: 192 | save_path: 193 | label: 194 | 195 | Returns: 196 | 197 | """ 198 | driver = ogr.GetDriverByName('ESRI Shapefile') 199 | dataSource = driver.Open(shapefile_path, 0) 200 | if dataSource is None: 201 | raise IOError('could not open!') 202 | gtiffDriver = gdal.GetDriverByName('GTiff') 203 | if gtiffDriver is None: 204 | raise ValueError("Can't find GeoTiff Driver") 205 | 206 | layer = dataSource.GetLayer(0) 207 | # # Convert the layer extent to image pixel coordinates 208 | minX, maxX, minY, maxY = layer.GetExtent() 209 | ulX, ulY = self.world2Pixel(minX, maxY) 210 | 211 | # initialize mask drawing 212 | rasterPoly = Image.new("I", (self.col, self.row), 0) 213 | rasterize = ImageDraw.Draw(rasterPoly) 214 | 215 | feature_num = layer.GetFeatureCount() # get poly count 216 | for i in range(feature_num): 217 | points = [] # store points 218 | pixels = [] # store pixels 219 | feature = layer.GetFeature(i) 220 | geom = feature.GetGeometryRef() 221 | feature_type = geom.GetGeometryName() 222 | 223 | if feature_type == 'POLYGON' or 'MULTIPOLYGON': 224 | # multi polygon operation 225 | # 1. use label to mask the max polygon 226 | # 2. use -label to mask the other polygon 227 | for j in range(geom.GetGeometryCount()): 228 | sub_polygon = geom.GetGeometryRef(j) 229 | if feature_type == 'MULTIPOLYGON': 230 | sub_polygon = sub_polygon.GetGeometryRef(0) 231 | for p_i in range(sub_polygon.GetPointCount()): 232 | px = sub_polygon.GetX(p_i) 233 | py = sub_polygon.GetY(p_i) 234 | points.append((px, py)) 235 | 236 | for p in points: 237 | origin_pixel_x, origin_pixel_y = self.world2Pixel( 238 | p[0], p[1]) 239 | # the pixel in new image 240 | new_pixel_x, new_pixel_y = origin_pixel_x, origin_pixel_y 241 | pixels.append((new_pixel_x, new_pixel_y)) 242 | 243 | rasterize.polygon(pixels, i+1) 244 | pixels = [] 245 | points = [] 246 | if feature_type != 'MULTIPOLYGON': 247 | label = -abs(label) 248 | 249 | # restore the label value 250 | label = abs(label) 251 | else: 252 | for j in range(geom.GetPointCount()): 253 | px = geom.GetX(j) 254 | py = geom.GetY(j) 255 | points.append((px, py)) 256 | 257 | for p in points: 258 | origin_pixel_x, origin_pixel_y = self.world2Pixel( 259 | p[0], p[1]) 260 | # the pixel in new image 261 | new_pixel_x, new_pixel_y = origin_pixel_x, origin_pixel_y 262 | pixels.append((new_pixel_x, new_pixel_y)) 263 | 264 | feature.Destroy() # delete feature 265 | 266 | if feature_type == 'LINESTRING': 267 | rasterize.line(pixels, i+1) 268 | if feature_type == 'POINT': 269 | # pixel x, y 270 | rasterize.point(pixels, i+1) 271 | 272 | mask = np.array(rasterPoly) 273 | self.mask = mask[np.newaxis, :] # extend an axis to three 274 | 275 | def clip_tif_and_shapefile(self, clip_size, begin_id, shapefile_path, out_dir): 276 | self.mask_tif_with_shapefile(shapefile_path) 277 | self.clip_mask_with_grid( 278 | clip_size=clip_size, begin_id=begin_id, out_dir=out_dir + '/annotations') 279 | pic_id = self.clip_tif_with_grid( 280 | clip_size=clip_size, begin_id=begin_id, out_dir=out_dir + '/image') 281 | return pic_id 282 | 283 | 284 | def channel_first_to_last(image): 285 | """ 286 | 287 | Args: 288 | image: 3-D numpy array of shape [channel, width, height] 289 | 290 | Returns: 291 | new_image: 3-D numpy array of shape [height, width, channel] 292 | """ 293 | new_image = np.transpose(image, axes=[1, 2, 0]) 294 | return new_image 295 | 296 | 297 | def channel_last_to_first(image): 298 | """ 299 | 300 | Args: 301 | image: 3-D numpy array of shape [channel, width, height] 302 | 303 | Returns: 304 | new_image: 3-D numpy array of shape [height, width, channel] 305 | """ 306 | new_image = np.transpose(image, axes=[2, 0, 1]) 307 | return new_image 308 | 309 | 310 | def save_image_with_georef(image, driver, original_ds, offset_x=0, offset_y=0, save_path=None): 311 | """ 312 | 313 | Args: 314 | save_path: str, image save path 315 | driver: gdal IO driver 316 | image: an instance of ndarray 317 | original_ds: a instance of data set 318 | offset_x: x location in data set 319 | offset_y: y location in data set 320 | 321 | Returns: 322 | 323 | """ 324 | # get Geo Reference 325 | ds = gdalnumeric.OpenArray(image) 326 | gdalnumeric.CopyDatasetInfo(original_ds, ds, xoff=offset_x, yoff=offset_y) 327 | driver.CreateCopy(save_path, ds) 328 | # write by band 329 | clip = image.astype(np.int8) 330 | # write the dataset 331 | if len(image.shape) == 3: 332 | for i in range(image.shape[0]): 333 | ds.GetRasterBand(i + 1).WriteArray(clip[i]) 334 | else: 335 | ds.GetRasterBand(1).WriteArray(clip) 336 | del ds 337 | 338 | 339 | def define_ref_predict(tif_dir, mask_dir, save_dir): 340 | """ 341 | define reference for raster referred to a geometric raster. 342 | Args: 343 | tif_dir: the dir to save referenced raster 344 | mask_dir: 345 | save_dir: 346 | 347 | Returns: 348 | 349 | """ 350 | tif_list = glob.glob(os.path.join(tif_dir, '*.tif')) 351 | 352 | mask_list = glob.glob(os.path.join(mask_dir, '*.png')) 353 | mask_list += (glob.glob(os.path.join(mask_dir, '*.jpg'))) 354 | mask_list += (glob.glob(os.path.join(mask_dir, '*.tif'))) 355 | 356 | tif_list.sort() 357 | mask_list.sort() 358 | 359 | os.makedirs(save_dir, exist_ok=True) 360 | gtiffDriver = gdal.GetDriverByName('GTiff') 361 | if gtiffDriver is None: 362 | raise ValueError("Can't find GeoTiff Driver") 363 | for i in range(len(tif_list)): 364 | save_name = tif_list[i].split('\\')[-1] 365 | save_path = os.path.join(save_dir, save_name) 366 | tif = GeoTiff(tif_list[i]) 367 | mask = np.array(Image.open(mask_list[i])) 368 | mask = channel_last_to_first(mask) 369 | save_image_with_georef( 370 | mask, gtiffDriver, tif.dataset, save_path=save_path) 371 | 372 | 373 | class GeoShaplefile(object): 374 | def __init__(self, file_path=""): 375 | self.file_path = file_path 376 | self.layer = "" 377 | self.minX, self.maxX, self.minY, self.maxY = (0, 0, 0, 0) 378 | self.feature_type = "" 379 | self.feature_num = 0 380 | self.open_shapefile() 381 | 382 | def open_shapefile(self): 383 | driver = ogr.GetDriverByName('ESRI Shapefile') 384 | dataSource = driver.Open(self.file_path, 0) 385 | if dataSource is None: 386 | raise IOError('could not open!') 387 | gtiffDriver = gdal.GetDriverByName('GTiff') 388 | if gtiffDriver is None: 389 | raise ValueError("Can't find GeoTiff Driver") 390 | 391 | self.layer = dataSource.GetLayer(0) 392 | self.minX, self.maxX, self.minY, self.maxY = self.layer.GetExtent() 393 | self.feature_num = self.layer.GetFeatureCount() # get poly count 394 | if self.feature_num > 0: 395 | polygon = self.layer.GetFeature(0) 396 | geom = polygon.GetGeometryRef() 397 | # feature type 398 | self.feature_type = geom.GetGeometryName() 399 | 400 | # def clip_from_file(clip_size, root, img_path, shp_path): 401 | # img_list = os.listdir(root + '/' + img_path) 402 | # n_img = len(img_list) 403 | # pic_id = 0 404 | # for i in range(n_img): 405 | # tif = GeoTiff(root + '/' + img_path + '/' + img_list[i]) 406 | # img_id = img_list[i].split('.', 1)[0] 407 | # pic_num = tif.clip_tif_and_shapefile(clip_size, pic_id, root + '/' + shp_path + '/' + img_id + '/' + img_id + '.shp', root + '/dataset') 408 | # pic_id += pic_num 409 | 410 | 411 | def clip_from_file(clip_size, root, img_path, shp_path): 412 | tif = GeoTiff(img_path) 413 | tif.clip_tif_and_shapefile(clip_size, 0, shp_path, root) 414 | 415 | 416 | if __name__ == '__main__': 417 | root = r'./example_data/original_data' 418 | img_path = 'img' 419 | shp_path = 'shp' 420 | clip_from_file(512, root, img_path, shp_path) 421 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/COCO/visualize_coco.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import pylab 4 | import os 5 | from pycocotools.coco import COCO 6 | import skimage.io as io 7 | 8 | ROOT_DIR = r'./example_data/original_data/dataset/eval' 9 | image_directory = os.path.join(ROOT_DIR, "image") 10 | annotation_file = os.path.join(ROOT_DIR, "instances_image_eval2019.json") 11 | 12 | example_coco = COCO(annotation_file) 13 | 14 | category_ids = example_coco.getCatIds(catNms=['square']) 15 | image_ids = example_coco.getImgIds(catIds=category_ids) 16 | image_data = example_coco.loadImgs(image_ids[0])[0] 17 | 18 | image = io.imread(image_directory + '/' + image_data['file_name']) 19 | plt.imshow(image) 20 | plt.axis('off') 21 | pylab.rcParams['figure.figsize'] = (8.0, 10.0) 22 | annotation_ids = example_coco.getAnnIds( 23 | imgIds=image_data['id'], catIds=category_ids, iscrowd=None) 24 | annotations = example_coco.loadAnns(annotation_ids) 25 | example_coco.showAnns(annotations) 26 | plt.show() 27 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .checkPIP import checkPIP 2 | from .rasterize import rasterize 3 | from .splitting import splitting 4 | from .paddlepaddle_split_dataset_list import generate_list 5 | from .intSegGDAL import rasterizeInsSeg -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/checkPIP.py: -------------------------------------------------------------------------------- 1 | def checkPIP(): 2 | import subprocess 3 | try: 4 | import Cython 5 | except ImportError: 6 | subprocess.check_call( 7 | ["python3", '-m', 'pip', 'install', 'Cython']) 8 | 9 | try: 10 | import skimage 11 | except ImportError: 12 | subprocess.check_call( 13 | ["python3", '-m', 'pip', 'install', 'scikit-image']) 14 | 15 | try: 16 | import PIL 17 | except ImportError: 18 | subprocess.check_call( 19 | ["python3", '-m', 'pip', 'install', 'Pillow']) 20 | 21 | 22 | try: 23 | import pycocotools 24 | except ImportError: 25 | subprocess.check_call( 26 | ["python3", '-m', 'pip', 'install', 'pycocotools']) 27 | checkPIP() -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/color.txt: -------------------------------------------------------------------------------- 1 | 1 0 0 0 255 2 | 2 174 156 191 234 3 | 3 159 195 134 7 4 | 4 176 204 34 208 5 | 5 125 139 142 98 6 | 6 188 245 68 132 7 | 7 161 56 236 184 8 | 8 153 203 248 159 9 | 9 111 61 187 52 10 | 10 157 211 10 208 11 | 11 208 133 122 59 12 | 12 100 181 247 85 13 | 13 148 32 17 85 14 | 14 252 30 108 156 15 | 15 45 224 220 205 16 | 16 96 101 230 53 17 | 17 195 30 110 195 18 | 18 166 5 57 119 19 | 19 29 223 147 66 20 | 20 121 189 102 26 21 | 21 23 106 51 176 22 | 22 8 148 209 197 23 | 23 71 30 190 84 24 | 24 202 80 111 107 25 | 25 221 156 118 181 26 | 26 170 187 101 209 27 | 27 87 82 127 75 28 | 28 194 223 148 71 29 | 29 252 197 110 215 30 | 30 211 39 195 183 31 | 31 235 6 163 36 32 | 32 25 28 60 190 33 | 33 230 28 167 43 34 | 34 71 127 254 202 35 | 35 44 19 197 5 36 | 36 111 153 80 234 37 | 37 88 0 131 61 38 | 38 92 103 225 122 39 | 39 167 180 69 123 40 | 40 133 122 235 109 41 | 41 19 100 177 59 42 | 42 206 127 103 15 43 | 43 248 106 179 93 44 | 44 129 207 93 123 45 | 45 14 246 163 23 46 | 46 13 243 37 65 47 | 47 29 25 220 161 48 | 48 204 86 181 33 49 | 49 48 183 192 35 50 | 50 6 232 225 247 51 | 51 83 205 148 159 52 | 52 181 105 78 105 53 | 53 215 116 200 208 54 | 54 222 63 108 75 55 | 55 227 99 106 216 56 | 56 74 205 59 102 57 | 57 55 14 231 228 58 | 58 220 133 46 232 59 | 59 190 216 142 136 60 | 60 191 68 26 191 61 | 61 125 55 250 231 62 | 62 212 249 108 154 63 | 63 98 58 177 238 64 | 64 72 236 131 178 65 | 65 157 218 168 178 66 | 66 154 131 233 132 67 | 67 145 248 215 13 68 | 68 60 111 3 99 69 | 69 120 83 164 5 70 | 70 16 112 138 157 71 | 71 181 118 217 29 72 | 72 158 152 43 19 73 | 73 72 30 13 78 74 | 74 222 0 27 232 75 | 75 240 245 30 80 76 | 76 181 232 193 97 77 | 77 36 182 74 166 78 | 78 18 159 222 134 79 | 79 76 18 201 22 80 | 80 167 192 14 242 81 | 81 225 75 19 85 82 | 82 210 241 238 28 83 | 83 121 169 145 124 84 | 84 239 127 129 241 85 | 85 99 198 124 142 86 | 86 245 220 198 219 87 | 87 43 91 206 177 88 | 88 215 128 129 225 89 | 89 224 223 21 237 90 | 90 167 200 16 55 91 | 91 25 188 201 217 92 | 92 197 30 138 224 93 | 93 208 102 64 150 94 | 94 196 142 31 218 95 | 95 88 206 70 206 96 | 96 214 92 56 51 97 | 97 95 105 199 224 98 | 98 50 241 66 250 99 | 99 50 96 139 152 100 | 100 70 243 160 235 101 | 101 217 160 204 127 102 | 102 242 219 152 92 103 | 103 114 104 84 193 104 | 104 190 192 120 112 105 | 105 222 93 237 238 106 | 106 4 39 31 253 107 | 107 123 109 186 236 108 | 108 88 167 231 194 109 | 109 182 207 20 58 110 | 110 31 205 38 252 111 | 111 53 43 51 126 112 | 112 203 88 41 85 113 | 113 64 113 143 189 114 | 114 228 2 89 18 115 | 115 220 164 126 176 116 | 116 27 190 251 137 117 | 117 92 240 185 47 118 | 118 116 23 243 192 119 | 119 79 234 8 229 120 | 120 248 183 140 158 121 | 121 152 225 26 96 122 | 122 213 188 251 89 123 | 123 46 176 50 190 124 | 124 208 10 229 220 125 | 125 122 15 8 9 126 | 126 113 88 134 238 127 | 127 84 17 242 26 128 | 128 73 34 152 125 129 | 129 43 64 166 202 130 | 130 40 36 39 9 131 | 131 254 90 135 218 132 | 132 35 90 241 44 133 | 133 66 220 169 234 134 | 134 187 171 105 160 135 | 135 96 187 219 69 136 | 136 206 130 128 65 137 | 137 153 244 244 134 138 | 138 33 101 157 112 139 | 139 247 225 23 121 140 | 140 41 165 124 184 141 | 141 125 164 2 36 142 | 142 123 1 57 135 143 | 143 21 224 72 141 144 | 144 252 246 105 80 145 | 145 223 234 157 99 146 | 146 247 48 69 210 147 | 147 205 204 216 11 148 | 148 173 87 122 85 149 | 149 125 166 242 230 150 | 150 72 113 131 161 151 | 151 8 79 20 182 152 | 152 14 235 30 28 153 | 153 211 102 250 118 154 | 154 145 107 162 171 155 | 155 209 83 203 179 156 | 156 60 49 0 159 157 | 157 79 187 115 153 158 | 158 104 159 248 206 159 | 159 106 45 60 130 160 | 160 138 249 220 102 161 | 161 232 132 77 139 162 | 162 234 27 112 79 163 | 163 41 50 45 0 164 | 164 174 24 69 156 165 | 165 94 241 56 220 166 | 166 96 111 32 21 167 | 167 102 82 79 2 168 | 168 72 205 223 69 169 | 169 113 24 239 232 170 | 170 198 50 12 213 171 | 171 132 132 79 31 172 | 172 138 87 13 29 173 | 173 9 206 26 160 174 | 174 87 21 52 81 175 | 175 233 57 73 97 176 | 176 37 114 229 202 177 | 177 131 30 133 141 178 | 178 182 231 50 99 179 | 179 88 187 44 173 180 | 180 148 36 101 223 181 | 181 217 235 175 114 182 | 182 240 167 45 116 183 | 183 113 108 145 246 184 | 184 113 85 77 110 185 | 185 19 75 116 214 186 | 186 46 123 67 220 187 | 187 240 227 237 86 188 | 188 80 86 76 229 189 | 189 66 34 1 163 190 | 190 229 113 213 58 191 | 191 245 65 194 190 192 | 192 123 213 168 99 193 | 193 162 10 89 84 194 | 194 157 112 100 186 195 | 195 49 75 131 80 196 | 196 25 240 35 58 197 | 197 107 145 51 47 198 | 198 27 123 206 148 199 | 199 218 137 217 201 200 | 200 115 139 110 253 201 | 201 197 243 158 99 202 | 202 101 141 175 70 203 | 203 190 196 105 81 204 | 204 233 158 183 154 205 | 205 44 163 168 53 206 | 206 243 243 47 175 207 | 207 53 154 175 201 208 | 208 214 245 226 233 209 | 209 226 186 246 103 210 | 210 247 110 199 113 211 | 211 233 42 44 139 212 | 212 101 76 234 195 213 | 213 200 158 162 86 214 | 214 78 21 139 53 215 | 215 13 144 8 174 216 | 216 94 92 225 40 217 | 217 80 153 126 127 218 | 218 201 58 2 61 219 | 219 81 233 246 168 220 | 220 38 40 242 157 221 | 221 178 238 94 138 222 | 222 71 246 122 16 223 | 223 186 121 190 18 224 | 224 119 46 21 9 225 | 225 44 143 169 63 226 | 226 77 65 13 3 227 | 227 252 250 91 132 228 | 228 221 0 218 229 229 | 229 66 253 35 32 230 | 230 147 212 205 120 231 | 231 188 7 68 76 232 | 232 152 174 185 173 233 | 233 88 244 193 14 234 | 234 95 77 217 43 235 | 235 223 145 71 243 236 | 236 57 38 45 50 237 | 237 3 205 253 96 238 | 238 0 81 146 193 239 | 239 211 177 213 161 240 | 240 212 36 237 4 241 | 241 129 25 176 128 242 | 242 1 142 72 11 243 | 243 174 42 194 30 244 | 244 51 147 2 9 245 | 245 82 149 9 121 246 | 246 175 117 23 37 247 | 247 140 102 6 91 248 | 248 247 155 236 190 249 | 249 73 24 187 148 250 | 250 239 137 140 99 251 | 251 99 22 67 39 252 | 252 57 141 88 219 253 | 253 131 48 94 157 254 | 254 90 227 135 125 255 | 255 49 227 160 113 256 | nv 255 255 255 255 257 | 258 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/intSegGDAL.py: -------------------------------------------------------------------------------- 1 | try: 2 | from osgeo import gdal, ogr 3 | import random 4 | except: 5 | import gdal 6 | import ogr 7 | 8 | 9 | def rasterizeInsSeg(ras_path, vec_path, outputRasIN, InsSegGDALout, color_text_path): 10 | driver = ogr.GetDriverByName("ESRI Shapefile") 11 | ras_ds = gdal.Open(ras_path) 12 | vec_ds = driver.Open(vec_path, 1) 13 | 14 | lyr = vec_ds.GetLayer() 15 | geot = ras_ds.GetGeoTransform() 16 | proj = ras_ds.GetProjection() # Get the projection from original tiff (fn_ras) 17 | 18 | layerdefinition = lyr.GetLayerDefn() 19 | feature = ogr.Feature(layerdefinition) 20 | 21 | schema = [] 22 | for n in range(layerdefinition.GetFieldCount()): 23 | fdefn = layerdefinition.GetFieldDefn(n) 24 | schema.append(fdefn.name) 25 | yy = feature.GetFieldIndex("MLDS") 26 | if yy < 0: 27 | print("MLDS field not found, we will create one for you and make all values to 1") 28 | else: 29 | lyr.DeleteField(yy) 30 | # lyr.ResetReading() 31 | new_field = ogr.FieldDefn("MLDS", ogr.OFTInteger) 32 | lyr.CreateField(new_field) 33 | feature_count = lyr.GetFeatureCount() 34 | for feature in lyr: 35 | for col in range(feature_count): 36 | col = random.randint(1, 255) 37 | feature.SetField("MLDS", col) 38 | lyr.SetFeature(feature) 39 | feature = None 40 | 41 | # isAttributeOn = att_field_input if att_field_input != '' else first_att_field 42 | # pixelsizeX = 0.2 if ras_ds.RasterXSize < 0.2 else ras_ds.RasterXSize 43 | # pixelsizeY = -0.2 if ras_ds.RasterYSize < -0.2 else ras_ds.RasterYSize 44 | 45 | drv_tiff = gdal.GetDriverByName("GTiff") 46 | chn_ras_ds = drv_tiff.Create( 47 | outputRasIN, ras_ds.RasterXSize, ras_ds.RasterYSize, 1, gdal.GDT_Byte) 48 | 49 | # Set the projection from original tiff (fn_ras) to the rasterized tiff 50 | chn_ras_ds.SetGeoTransform(geot) 51 | chn_ras_ds.SetProjection(proj) 52 | chn_ras_ds.FlushCache() 53 | 54 | gdal.RasterizeLayer(chn_ras_ds, [1], lyr, burn_values=[ 55 | 1], options=["ATTRIBUTE=MLDS"]) 56 | 57 | # Change No Data Value to 0 58 | # chn_ras_ds.GetRasterBand(1).SetNoDataValue(0) 59 | chn_ras_ds = None 60 | # lyr.DeleteField(yy) # delete field 61 | vec_ds = None 62 | 63 | gdal.DEMProcessing(InsSegGDALout, outputRasIN, 'color-relief', 64 | colorFilename=color_text_path, computeEdges=False) 65 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/paddlepaddle_split_dataset_list.py: -------------------------------------------------------------------------------- 1 | # coding: utf8 2 | # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | import glob 17 | import os.path 18 | # import argparse 19 | import warnings 20 | import numpy as np 21 | 22 | # TODO: assign command line argument to variable 23 | 24 | 25 | def get_files(path, format, postfix): 26 | pattern = '*%s.%s' % (postfix, format) 27 | 28 | search_files = os.path.join(path, pattern) 29 | search_files2 = os.path.join(path, "*", pattern) # 包含子目录 30 | search_files3 = os.path.join(path, "*", "*", pattern) # 包含三级目录 31 | 32 | filenames = glob.glob(search_files) 33 | filenames2 = glob.glob(search_files2) 34 | filenames3 = glob.glob(search_files3) 35 | 36 | filenames = filenames + filenames2 + filenames3 37 | 38 | return sorted(filenames) 39 | 40 | 41 | def generate_list(args): 42 | separator = args["separator"] 43 | dataset_root = args["dataset_root"] 44 | # if sum(args["split"]) != 1.0: 45 | # raise ValueError("The sum of the division ratios must be 1") 46 | 47 | file_list = os.path.join(dataset_root, 'labels.txt') 48 | with open(file_list, "w") as f: 49 | for label_class in args["label_class"]: 50 | # print(label_class) # test 51 | f.write(label_class + '\n') 52 | 53 | image_dir = os.path.join(dataset_root, args["images_dir_name"]) 54 | label_dir = os.path.join(dataset_root, args["labels_dir_name"]) 55 | image_files = get_files(image_dir, args["format"][0], args["postfix"][0]) 56 | label_files = get_files(label_dir, args["format"][1], args["postfix"][1]) 57 | if not image_files: 58 | warnings.warn("No files in {}".format(image_dir)) 59 | num_images = len(image_files) 60 | 61 | if not label_files: 62 | warnings.warn("No files in {}".format(label_dir)) 63 | num_label = len(label_files) 64 | 65 | if num_images != num_label and num_label > 0: 66 | raise Exception("Number of images = {} number of labels = {} \n" 67 | "Either number of images is equal to number of labels, " 68 | "or number of labels is equal to 0.\n" 69 | "Please check your dataset!".format( 70 | num_images, num_label)) 71 | 72 | image_files = np.array(image_files) 73 | label_files = np.array(label_files) 74 | state = np.random.get_state() 75 | np.random.shuffle(image_files) 76 | np.random.set_state(state) 77 | np.random.shuffle(label_files) 78 | 79 | start = 0 80 | num_split = len(args["split"]) 81 | dataset_name = ['train', 'val', 'test'] 82 | for i in range(num_split): 83 | dataset_split = dataset_name[i] 84 | print("Creating {}.txt...".format(dataset_split)) 85 | if args["split"][i] > 1.0 or args["split"][i] < 0: 86 | raise ValueError( 87 | "{} dataset percentage should be 0~1.".format(dataset_split)) 88 | 89 | file_list = os.path.join(dataset_root, dataset_split + '.txt') 90 | with open(file_list, "w") as f: 91 | num = round(args["split"][i] * num_images) 92 | end = start + num 93 | if i == num_split - 1: 94 | end = num_images 95 | for item in range(start, end): 96 | left = image_files[item].replace(dataset_root, '') 97 | if left[0] == os.path.sep: 98 | left = left.lstrip(os.path.sep) 99 | 100 | try: 101 | right = label_files[item].replace(dataset_root, '') 102 | if right[0] == os.path.sep: 103 | right = right.lstrip(os.path.sep) 104 | line = left + separator + right + '\n' 105 | except: 106 | line = left + '\n' 107 | 108 | f.write(line.replace("\\", "/")) 109 | # print(line) # test 110 | start = end 111 | 112 | 113 | # if __name__ == '__main__': 114 | # args = parse_args() 115 | # generate_list(args) 116 | -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/rasterize.py: -------------------------------------------------------------------------------- 1 | try: 2 | from osgeo import gdal, ogr 3 | except: 4 | import gdal, ogr 5 | 6 | def rasterize(ras_path, vec_path, output): 7 | driver = ogr.GetDriverByName("ESRI Shapefile") 8 | ras_ds = gdal.Open(ras_path) 9 | vec_ds = driver.Open(vec_path, 1) 10 | 11 | lyr = vec_ds.GetLayer() 12 | geot = ras_ds.GetGeoTransform() 13 | proj = ras_ds.GetProjection() # Get the projection from original tiff (fn_ras) 14 | 15 | layerdefinition = lyr.GetLayerDefn() 16 | feature = ogr.Feature(layerdefinition) 17 | 18 | schema = [] 19 | for n in range(layerdefinition.GetFieldCount()): 20 | fdefn = layerdefinition.GetFieldDefn(n) 21 | schema.append(fdefn.name) 22 | yy = feature.GetFieldIndex("MLDS") 23 | if yy < 0: 24 | print("MLDS field not found, we will create one for you and make all values to 1") 25 | else: 26 | lyr.DeleteField(yy) 27 | # lyr.ResetReading() 28 | new_field = ogr.FieldDefn("MLDS", ogr.OFTInteger) 29 | lyr.CreateField(new_field) 30 | for feature in lyr: 31 | feature.SetField("MLDS", 1) 32 | lyr.SetFeature(feature) 33 | feature = None 34 | 35 | # isAttributeOn = att_field_input if att_field_input != '' else first_att_field 36 | # pixelsizeX = 0.2 if ras_ds.RasterXSize < 0.2 else ras_ds.RasterXSize 37 | # pixelsizeY = -0.2 if ras_ds.RasterYSize < -0.2 else ras_ds.RasterYSize 38 | 39 | drv_tiff = gdal.GetDriverByName("GTiff") 40 | chn_ras_ds = drv_tiff.Create( 41 | output, ras_ds.RasterXSize, ras_ds.RasterYSize, 1, gdal.GDT_Byte) 42 | 43 | # Set the projection from original tiff (fn_ras) to the rasterized tiff 44 | chn_ras_ds.SetGeoTransform(geot) 45 | chn_ras_ds.SetProjection(proj) 46 | chn_ras_ds.FlushCache() 47 | 48 | gdal.RasterizeLayer(chn_ras_ds, [1], lyr, burn_values=[1], options=["ATTRIBUTE=MLDS"]) 49 | 50 | # Change No Data Value to 0 51 | # chn_ras_ds.GetRasterBand(1).SetNoDataValue(0) 52 | chn_ras_ds = None 53 | # lyr.DeleteField(yy) # delete field 54 | vec_ds = None -------------------------------------------------------------------------------- /deep-learning-datasets-maker/utils/splitting.py: -------------------------------------------------------------------------------- 1 | try: 2 | from osgeo import gdal 3 | except: 4 | import gdal 5 | 6 | import os.path as osp 7 | import math 8 | 9 | # Start Splitting 10 | def splitting(fn_ras, cdpath, frmt_ext, imgfrmat, scaleoptions, needed_out_x, needed_out_y, file_name): 11 | ds = gdal.Open(fn_ras) 12 | gt = ds.GetGeoTransform() 13 | 14 | # get coordinates of upper left corner 15 | xmin = gt[0] 16 | ymax = gt[3] 17 | resx = gt[1] 18 | res_y = gt[5] 19 | resy = abs(res_y) 20 | 21 | # round up to nearst int 22 | xnotround = ds.RasterXSize / needed_out_x 23 | xround = math.ceil(xnotround) 24 | ynotround = ds.RasterYSize / needed_out_y 25 | yround = math.ceil(ynotround) 26 | 27 | # pixel to meter - 512×10×0.18 28 | pixtomX = needed_out_x * xround * resx 29 | pixtomy = needed_out_y * yround * resy 30 | # size of a single tile 31 | xsize = pixtomX / xround 32 | ysize = pixtomy / yround 33 | # create lists of x and y coordinates 34 | xsteps = [xmin + xsize * i for i in range(xround + 1)] 35 | ysteps = [ymax - ysize * i for i in range(yround + 1)] 36 | 37 | # loop over min and max x and y coordinates 38 | for i in range(xround): 39 | for j in range(yround): 40 | xmin = xsteps[i] 41 | xmax = xsteps[i + 1] 42 | ymax = ysteps[j] 43 | ymin = ysteps[j + 1] 44 | 45 | # use gdal warp 46 | # gdal.WarpOptions(outputType=gdal.gdalconst.GDT_Byte) 47 | # gdal.Warp("ds"+str(i)+str(j)+".tif", ds, 48 | # outputBounds = (xmin, ymin, xmax, ymax), dstNodata = -9999) 49 | 50 | # or gdal translate to subset the input raster 51 | gdal.Translate(osp.join(cdpath, \ 52 | (str(file_name) + "-" + str(j) + "-" + str(i) + "." + frmt_ext)), 53 | ds, 54 | projWin=(abs(xmin), abs(ymax), abs(xmax), abs(ymin)), 55 | xRes=resx, 56 | yRes=-resy, 57 | outputType=gdal.gdalconst.GDT_Byte, 58 | format=imgfrmat, 59 | scaleParams=[[scaleoptions]]) 60 | 61 | # close the open dataset!!! 62 | ds = None -------------------------------------------------------------------------------- /docs/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepbands/deep-learning-datasets-maker/4b3c81e25f1a2eee08567fc874287ac1804af0f5/docs/img/logo.png -------------------------------------------------------------------------------- /docs/img/logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepbands/deep-learning-datasets-maker/4b3c81e25f1a2eee08567fc874287ac1804af0f5/docs/img/logo2.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Cython 2 | scikit-image 3 | pycocotools 4 | Pillow --------------------------------------------------------------------------------