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.6.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.6-py3-none-any.whl (8.5 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dogcat_classifier-0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 53f651aadf7fcb484b02d5a083af571d4c3e900352a5545c9afc24c3b8828b4f
MD5 bb7f2d6688b9b535dbf724043b370cd8
BLAKE2b-256 54edc7ffbab94a5452125fa13de28fa1c874c1b8f92a78d7142d2f16bae728de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dogcat_classifier-0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ef62ea39c12c1f03c174dd9d1a99a8cbb3391af91433a1cd2529a612c3116990
MD5 c74a3c63d564c20dfc32aec67312414e
BLAKE2b-256 655e4e120a2bf81e411d71419dccfc09f04f4c8568b83755d2be200fd7634bf7

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