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

Uploaded Python 3

File details

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

File metadata

  • Download URL: dogcat_classifier-0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 92bb7e9faa53e35a80599795ff921bd6bdaef9f05092718d7b89528eb49a90f7
MD5 fb18fb62d1a9ae13a1f89fb3725c6373
BLAKE2b-256 d679c95a58a5e2592858e0ed4acdc17d2a1a67fad5324ce8e3a8303f61140988

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dogcat_classifier-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 74666dc34a9c7fe0a14eadd31bcd69fdc6dd0b9d7de4bac64306bf575d082ba5
MD5 53e8d8cd56a5774e37ddb2add2114511
BLAKE2b-256 f6503886a892fe4e71a1075ae0152351a71a9341d995197e88e501e0d91391f6

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