Skip to content

Releases: MarxSoul55/cats_vs_dogs

Cats vs. Dogs | Official v1.0 Release

09 Sep 01:03
Compare
Choose a tag to compare

Hello World!

I will be heading to university soon, and I have a strong feeling that I won't have a lot of free time. Therefore, I'm pushing this release out before the "busy factor" accelerates. I've detailed the changes below. HAPPY CODING!

What's New in v1.0?

  • Revamped CLI.
    • Entering each necessary setting manually made the program flexible, but also tedious to use. In this version, I've brought back the simplified CLI as seen in early versions, but with a special file config.py to store necessary settings.
    • See the wiki for details.
  • Minor updates to stdout for printing predictions, training statuses, and transition states.
    • Clarifying predictions, adding max steps, and clarifying transitions from entry-point to training respectively.

Cats vs. Dogs | Unifying PyTorch & TensorFlow

02 Sep 22:24
Compare
Choose a tag to compare

Hello World!

First, a foreword.

I started this project almost a year ago, releasing my first source files on October 16th, 2017. I had dabbled in machine learning before with projects using the Keras library, but I never did anything too serious. I suppose you could say they were my "baby days" in machine learning.

When I heard that the TensorFlow library was coming to Windows, I was very excited to delve into machine learning on a lower level. When push came to shove, that force manifested itself into this program.

At the time, my goal was simple—create, train, and save a model for either further training or classification. 8 releases later, it's clear that there were some roadblocks.

Those roadblocks would've never existed if I decided, then and there, that what I had was good enough. However, when you design a bigger program, you start to think a lot about design choices, and you start to run into issues:

"What does it mean to make modular programs? Where and when should I split a big function into smaller ones? Should this functionality be a separate part, or be included with a larger group of code?"

"Should I even have a file for constants? Why not use a CLI to pass them manually as arguments to a main function? Is a serialized dictionary really the best way to pass a label?"

"Why isn't my model training well? Oh, this optimizer ended up dividing by small numbers, making the learning unstable... What about trying RMSProp instead? Or plain jane SGD with momentum?"

To make matters even more complex, a new library called PyTorch was growing popular. I had heard of its ease of use compared to TensorFlow, but I hesitated, questioning whether learning an entirely new framework was worth it (spoiler: it was).

Dealing with design choices, fixing bugs, choosing model architectures, implementing new libraries... that's led to the project here today.

It's not perfect, and I don't think it'll ever be—there's always something to refactor, always another thing to improve upon. For that reason, I doubt I'll ever actually get out of the "pre-release" stage.

That's okay. I'm still proud of where I've gotten with a field as complex as machine learning, and I know the practical experience with it—during almost a year of development—won't hurt me in the slightest. I've also learned a lot about how to structure programs effectively, and the different philosophies for doing so.

Truly, the education from this self-taught development process has been invaluable. As an incoming student to a top public university, I know I'll need it.

❤️ ❤️ ❤️ ❤️ ❤️
🐻 GO BRUINS 🐻
❤️ ❤️ ❤️ ❤️ ❤️

What's new in v0.9?

  • In v0.9, I've unified the PyTorch and TensorFlow implementations. Now, they both use the same CLI—Python's argparse. No constants.py to be found.
    • Note that some of the arguments differ in requirements and behavior across the two implementations—I go over the details in the wiki!
  • I've also included a pretrained model (for PyTorch) in this release!
    • The architecture is the same as used in the program by default—I call it "Baby ResNet", since it's essentially a lightweight version of the famous architecture.
    • It was trained via the Adam optimizer for 10 epochs using all the recommended hyperparameters as in the paper, except for a learning rate of 1E-4, since I was getting stalling errors with 1E-3.
    • The model was tested on a subset of Kaggle's test data for an accuracy of 95%.

HAPPY CODING! 😃

Cats vs. Dogs | Fixing a Grayscale Bug

18 Aug 05:24
Compare
Choose a tag to compare
Pre-release

Hello World!

This is a small release with one but very important fix.

The convert_colorspace preprocessing method had a flaw with conversion to grayscale that effectively neutered it. It turns out that, given some HxWxC image, OpenCV doesn't preserve the C (channel) dimension. This means that the image becomes a 2-dimensional HxW tensor, which breaks the code.

To fix this, I've manually expanded the dimensions via np.expand_dims(image, axis=2).

This fix is valid for both PyTorch and TensorFlow implementations.

Happy coding!

Cats vs. Dogs | Revamped CLI

18 Aug 01:07
Compare
Choose a tag to compare
Pre-release

Hello World!

In this release, I made a number of minor bug fixes and did some refactoring for cleanliness.

The only significant change is the new CLI for the PyTorch version. In the past, I relied on a module called constants to hold values necessary for training. I made that design choice out of convenience, but I now realize the choice between giving something as a function argument as opposed to invoking a value from constants was quite arbitrary on my part. In addition, constants forced me to structure the directory in a way that always conformed to its requirements.

Therefore, I've deleted constants for the PyTorch version and I've moved the responsibility for providing important values to the user for the CLI. I realize that this change can be quite annoying if one wishes to quickly run a number of commands, but I believe that flexibility it provides outweighs the cost.

I will detail this new CLI in this project's wiki page.

Regarding the TensorFlow implementation—I haven't changed the CLI for it, meaning the old constants module is still present and functioning for it. For now, PyTorch has been working very well, and I'll be prioritizing development of its version over the TensorFlow version.

Happy coding!

Cats & Dogs — Classification w/ Convolutional Neural Networks

06 Aug 21:25
Compare
Choose a tag to compare

Hello 🌎! A lot has changed with this release:

  • Before, TensorFlow was the main implementation that I used for this program. However, I've found PyTorch to be much more intuitive and easy to use. Therefore, I've made PyTorch the "official" implementation. I still support TensorFlow through a flag --implementation tensorflow when invoking the program.
  • I've significantly refactored the TensorFlow implementation and modeled the new PyTorch implementation after that refactoring. You'll find the code to be much more modular and clean.
  • I am no longer supporting classification off of URLs. It hasn't been very useful as a feature, but I will consider it in the future for v1.0.
  • I still have support for different colorspaces, image sizes, etc. but I changed the API so that it no longer relies on constants.py, but instead uses keyword parameters in the new preprocessor class ImageDataPipeline. Although inconvenient to an extent, I believe overly relying on constants.py is not ideal for code cleanliness and modularity.
  • I've modified the entry point script to be __main__.py in the package directory cats_vs_dogs. This allows the program to be called as a package—python cats_vs_dogs—which is much more intuitive to the program's operation.
  • I've put the new guide for how to use the program as part of this project's wiki, which is much more neat and organized than putting it in a long piece of prose in README.md.

Thank you for your interest in this project. Happy coding! 😃

Cats & Dogs | Classification w/ Convolutional Neural Networks

07 Apr 03:35
Compare
Choose a tag to compare

Hello 🌎 !

In this release, I changed 5 notable things:

  1. I refactored the code further to make it prettier 😊 !
  2. I fixed a dangerous bug 🐛—if the preprocessor were to encounter a file in the training directory that wasn't an image, it would crash the program in the middle of training, without saving. That's a huge issue, and I fixed it by using the os module to check the extension to ensure the preprocessor is seeing an image and not some .txt file or whatever.
  3. Previously, I had the preprocesser use CIELAB as the color space with all 3 channels as floats in [-1, 1]. I've changed the first channel 'L' to be in [0, 1] instead; since it measures intensity of whiteness, it doesn't make sense to call the lack of it (aka blackness) an inhibitory feature.
  4. I deleted an exception that checked to ensure all images fed into the preprocessor had a bit depth of 24 bits per pixel. Turns out that OpenCV handles that by default.
  5. While on the topic of color spaces... guess what I've added? That's right, support for more color spaces 🎨! You can now choose between CIELAB (which was the only one supported before), RGB, GRAYSCALE, RGB+GRAYSCALE, and HSV! The ImagePreprocessor class has a new docstring which will explain the usage of each. I've also added a relevant constant in constants.py for easy modification!

Happy classifying! ❤️

Cats & Dogs — Classification w/ Deep Convolutional Neural Networks

28 Mar 07:10
Compare
Choose a tag to compare

Hello World! 🌎

In v0.4, I haven't added any new features; rather I've done a little touching up on the code. I've edited docstrings to make things clearer, added constants to help make customization easier, and refactored certain ugly bits of code.

I have added a new file, test.py, which contains code for timing certain functions' runtimes. Yet I don't consider this to be a feature—it's just a handy tool to figure out where the bottlenecks lie.

Happy classifying! ❤️

Cats & Dogs — Training & Classifying w/ Deep Learning

26 Mar 04:29
Compare
Choose a tag to compare

Hello World! 😃

In this release, I have refactored the code to make it much more beautiful (in my opinion), and I've added three new features:

  1. You can now classify all the images in a directory (excluding subdirectories). You can access this through the CLI, but the output is quite ugly—it's simply a dictionary printed out with the print function. The reason for this ugliness is that I've only intended the CLI to be for testing purposes, so I don't bother optimizing its looks. If you want the actual dictionary (which is of format {filename: prediction}), you access it through model.classify. And of course, if you like the CLI, you're more than welcome to change the way the dictionary prints out yourself, which would be a very trivial task.
  2. You can now classify an image from a URL. Ensure that the URL points to the image by itself!
  3. I added a safety prompt that makes you confirm that you want to start training (or resume training) on a model. I added it because training replaces the parameters of the old model; if one were to mistakenly forget this, the prompt is there to protect them!

I have put directions for both new features in the new README.md.

Happy classifying! ❤️

Refactored Code w/ Training & Classifying Capabilities

20 Mar 18:55
Compare
Choose a tag to compare

The previous version, v0.1, did indeed provide the functionality it promised. However, the code's structure was suboptimal—thus hindering comprehension and modification. The new code is refactored to be much more beautiful; for example, in includes constants.py which allows easy modification of important constants like the training-directory, etc. I also changed the CLI to remove the abbreviated commands; it does take more time to type out the full commands, but I believe the clarity this change provides is important.

The code is still built around tf.train.Saver for saving and loading models. In a future release, I hope to get SavedModel working.

I'll go more in-depth with the updated interfaces in README.md. Happy classifying!

Source w/ Training & Testing Capabilities

16 Oct 22:50
Compare
Choose a tag to compare

Hello World! This is the source for cats_vs_dogs. As the title says, this source includes the ability to train and test a model.