Skip to main content

This project focuses on creating a machine learning model that classifies images of dogs and cats. The model is encapsulated within a Python package, making it easy to install and use. The package employs TensorFlow for model training and inference, while OpenCV and Pillow are utilized for image processing. It is distributed via PyPI (Python Package Index).

Project description

Project Overview: Dog-Cat Classifier Python Package

How to Use the Package:

step 1 :
pip install dogcat-classifier

step 2 :

    from dogcat_classifier.classifier import predict_image
    image_path = 'path_to_your_image.jpg'
    result = predict_image(image_path)
    print(f'The image is a {result}.')

This project focuses on creating a machine learning model that classifies images of dogs and cats. The model is encapsulated within a Python package, making it easy to install and use. The package employs TensorFlow for model training and inference, while OpenCV and Pillow are utilized for image processing. It is distributed via PyPI (Python Package Index). Project Structure:

dogcat_classifier/

dogcat_classifier/

        init.py (Marks this directory as a Python package)
        classifier.py (Contains the predict_image function and model loading logic)
        model.h5 (Pre-trained TensorFlow model)
        test_predict.py (Sample test file for predictions)

dog.jpg (Sample image for testing)

README.md (Project description and usage details)

setup.py (Configuration for building and installing the package)

requirements.txt (Project dependencies)

MANIFEST.in (Ensures non-code files are included in the package)

dist/ (Built distributions created after running build commands)--ignored

build/ (Temporary build artifacts)--ignored

*.egg-info (Metadata for the package)--ignored

Steps to Build and Distribute the Package

  1. Initialize the Project Set up the project folder with necessary files like setup.py, classifier.py, model.h5, etc., to create the Python package. The setup.py file contains metadata and dependencies, while classifier.py includes functionality for loading the trained model and classifying images.

  2. Install Dependencies Use the following command to install required packages: pip install tensorflow pillow numpy matplotlib scikit-learn opencv-python setuptools wheel twine

  3. Build the Package To build the package, run:

    python setup.py sdist bdist_wheel This command generates distributable .tar.gz and .whl files in the dist/ folder.

  4. Test the Package Locally Install the package locally to verify functionality:

    pip install . You can test it using test_predict.py, which checks the model's prediction on a sample image (dog.jpg).

  5. Upload the Package to PyPI After testing, upload the package using Twine:

    python -m twine upload dist/*

  6. Verify the Package on PyPI Once uploaded, confirm that it works by installing it from PyPI:

Why This Approach? Using python setup.py sdist bdist_wheel: This command generates distribution files required for uploading to PyPI. Uploading with Twine: Twine securely handles uploads to PyPI, ensuring proper management of package files and credentials. Commands Used Summary Install dependencies:

pip install tensorflow pillow numpy matplotlib scikit-learn opencv-python setuptools wheel twine

Build the package:

python setup.py sdist bdist_wheel

Upload to PyPI:

python -m twine upload dist/*

Install locally for testing:

pip install .

Test the package:

python test_predict.py

This structured approach ensures that you can efficiently create, distribute, and utilize a dog-cat image classifier in Python.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dogcat_classifier-0.4.tar.gz (8.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dogcat_classifier-0.4-py3-none-any.whl (8.5 MB view details)

Uploaded Python 3

File details

Details for the file dogcat_classifier-0.4.tar.gz.

File metadata

  • Download URL: dogcat_classifier-0.4.tar.gz
  • Upload date:
  • Size: 8.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for dogcat_classifier-0.4.tar.gz
Algorithm Hash digest
SHA256 b7361d762d5750a08191eee4a820988ce8e592d54935917347986d9676f3b633
MD5 4a7e3976a5bee737da114137fbc25a49
BLAKE2b-256 4b42c5514b2a766b22d6a996055216a67c8c7a37458bb543231183686122ff4a

See more details on using hashes here.

File details

Details for the file dogcat_classifier-0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for dogcat_classifier-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e7fa65e8f30dba4f551b403f76d51838a2b10e921ad206ed6a204d6f1645f380
MD5 acbb5deb7628e6bf9c035153f5f3d362
BLAKE2b-256 a3ab8ce0e48f7688531646a5657f7c08f58efa0793c3df76c159e164b1ba303e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page