Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,19 @@ RUN locale-gen ${LANGUAGE} \
#==============================
# Set up TensorFlow / TensorPy
#==============================
COPY docker/docker_install.sh /TensorPy/docker_install.sh
COPY download_imagenet.py /TensorPy/download_imagenet.py
COPY classify.py /TensorPy/classify.py
COPY third_party/docker/docker_install.sh /TensorPy/docker_install.sh
COPY requirements.txt /TensorPy/
COPY setup.py /TensorPy/
COPY tensorpy /TensorPy/tensorpy/
COPY examples /TensorPy/examples/
COPY sample_images /TensorPy/sample_images/
COPY test_classify_image.sh /TensorPy/
COPY docker /TensorPy/docker/
COPY docker/run_docker_test.sh /TensorPy/
RUN cd /TensorPy && ls && ./docker/docker_install.sh
COPY third_party/docker /TensorPy/third_party/docker/
COPY third_party/docker/run_docker_test.sh /TensorPy/
RUN cd /TensorPy && ls && ./third_party/docker/docker_install.sh
RUN cd /TensorPy && pip install -r requirements.txt

#===================
# Create entrypoint
#===================
COPY docker/docker-entrypoint.sh /
COPY third_party/docker/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/bin/bash"]
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@

[![pypi](https://img.shields.io/pypi/v/tensorpy.svg)](https://pypi.python.org/pypi/tensorpy) [![Python version](https://img.shields.io/badge/python-2.7-22AADD.svg "Python version")](https://docs.python.org/2/) [![MIT License](http://img.shields.io/badge/license-MIT-22BBCC.svg "MIT License")](https://github.com/TensorPy/TensorPy/blob/master/LICENSE) [![Join the chat at https://gitter.im/TensorPy/Lobby](https://badges.gitter.im/TensorPy/TensorPy.svg)](https://gitter.im/TensorPy/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

**Making TensorFlow easier to use with Python**
**Image Classification with TensorFlow made easy!**

You can use TensorPy to classify images by simply passing a URL. [TensorFlow](https://www.tensorflow.org/) image recognition does the hard work.
You can use TensorPy to classify images by simply passing a URL on the command line, or by using TensorPy in your Python program. **[TensorFlow](https://www.tensorflow.org/)** does all the image-recognition work.

TensorPy also simplifies TensorFlow installation by automating several setup steps into a single script (See **[install.sh](https://github.com/TensorPy/TensorPy/blob/master/install.sh)** for details).

### Setup Instructions for Mac and Ubuntu/Linux
See **[help_docs/how_tensorpy_works.md](https://github.com/TensorPy/TensorPy/blob/master/help_docs/how_tensorpy_works.md)** for a detailed explanation of how TensorPy works.

(**Windows & Docker users**: See the [Docker ReadMe](https://github.com/TensorPy/TensorPy/blob/master/docker/ReadMe.md) for running on a Docker machine. Windows requires Docker to run TensorFlow.)

## Setup Steps for Mac & Ubuntu/Linux

(**Windows & Docker users**: See the **[Docker ReadMe](https://github.com/TensorPy/TensorPy/blob/master/third_party/docker/ReadMe.md)** for running on a Docker machine. Windows requires Docker to run TensorFlow.)

#### **Step 1:** Create and activate a virtual environment named "tensorpy"

Expand All @@ -23,9 +27,9 @@ git clone https://github.com/TensorPy/TensorPy.git
cd TensorPy
```

#### **Step 3:** Install TensorPy, TensorFlow, and ImageNet
#### **Step 3:** Install TensorPy, TensorFlow, and ImageNet/Inception

One script installs them all. (See [install.sh](https://github.com/TensorPy/TensorPy/blob/master/install.sh) for details.)
The **[install.sh](https://github.com/TensorPy/TensorPy/blob/master/install.sh)** script installs everything you need:

```bash
./install.sh
Expand All @@ -36,18 +40,24 @@ One script installs them all. (See [install.sh](https://github.com/TensorPy/Tens
Classify a single image from a URL:

```bash
classify "https://raw.githubusercontent.com/TensorPy/TensorPy/master/sample_images/happy_animal.jpg"
classify "https://raw.githubusercontent.com/TensorPy/TensorPy/master/examples/images/happy_animal.jpg"
```

Classify all images on a web page:

```bash
classify "https://github.com/TensorPy/TensorPy/tree/master/sample_images"
classify "https://github.com/TensorPy/TensorPy/tree/master/examples/images"
```

Classify a single image from a URL from within a Python program: (See [test_python_classify.py](https://github.com/TensorPy/TensorPy/blob/master/examples/test_python_classify.py) for details.)
Classify a single image from a URL from within a Python program: (See **[test_python_classify.py](https://github.com/TensorPy/TensorPy/blob/master/examples/test_python_classify.py)** for details.)

```bash
cd examples
python test_python_classify.py
```

____________

### Future Work:

Eventually, the headline will change from "Image Classification with TensorFlow made easy!" to "Machine Learning with TensorFlow made easy!" once I expand on TensorPy to make other features of TensorFlow easier too. Stay tuned for updates!
8 changes: 0 additions & 8 deletions docker/run_docker_test.sh

This file was deleted.

15 changes: 15 additions & 0 deletions examples/images/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### Here are some cool animals!

**(For testing image recognition)**

File names are purposely made ambiguous to demonstrate that classifications are based on the image itself and not the image name. Classifications aren't always perfect: "water_animal.jpg" is an image of a dolphin, but TensorFlow classifies it as a type of shark. TensorFlow's neural net model can be trained to perform better (more on that later!).

![](https://raw.githubusercontent.com/TensorPy/TensorPy/master/examples/images/bird_animal.jpg "Animal")

![](https://raw.githubusercontent.com/TensorPy/TensorPy/master/examples/images/cat_animal.jpg "Animal")

![](https://raw.githubusercontent.com/TensorPy/TensorPy/master/examples/images/happy_animal.jpg "Animal")

![](https://raw.githubusercontent.com/TensorPy/TensorPy/master/examples/images/reptile_animal.jpg "Animal")

![](https://raw.githubusercontent.com/TensorPy/TensorPy/master/examples/images/water_animal.jpg "Animal")
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion examples/test_classify_image.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
classify "https://raw.githubusercontent.com/TensorPy/TensorPy/master/sample_images/happy_animal.jpg"
classify "https://raw.githubusercontent.com/TensorPy/TensorPy/master/examples/images/happy_animal.jpg"
2 changes: 1 addition & 1 deletion examples/test_classify_page.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
classify "https://github.com/TensorPy/TensorPy/tree/master/sample_images"
classify "https://github.com/TensorPy/TensorPy/tree/master/examples/images"
2 changes: 1 addition & 1 deletion examples/test_python_classify.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tensorpy import image_base

result = image_base.classify(
"https://raw.githubusercontent.com/TensorPy/TensorPy/master/sample_images/happy_animal.jpg") # noqa
"https://raw.githubusercontent.com/TensorPy/TensorPy/master/examples/images/happy_animal.jpg") # noqa
print("\nBest match classification:\n%s\n" % result)
7 changes: 7 additions & 0 deletions help_docs/how_tensorpy_works.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### How TensorPy Works (Detailed Explanation)

Once TensorPy is installed with [install.sh](https://github.com/TensorPy/TensorPy/blob/master/install.sh), a command called "classify" is added to your command line, which takes a URL as input. When called, TensorPy determines if that URL links to an image or a web image. If it's an image, TensorPy downloads the image to a new folder called "downloads_folder". From there, the image is converted to a JPEG. Then, the image is fed to the local [tensorpy/classify_image.py](https://github.com/TensorPy/TensorPy/blob/master/tensorpy/classify_image.py) which tells TensorFlow to use the ImageNet Inception database to classify the image and print out the result.

If the "classify" command is called with a web page as input, then all images on that page (up to the limit defined in [tensorpy/settings.py](https://github.com/TensorPy/TensorPy/blob/master/tensorpy/settings.py)) will get downloaded to "downloads_folder", where TensorPy does the work listed above per image, with the exception of images smaller than the minimum size defined in tensorpy/settings.py (currently 50x50 pixels). Images that are too small will be skipped because results have shown that icons and other tiny images get extremely poor classification results.

You can also use TensorPy to classify images from within a Python program. (See the example to learn how: [examples/test_python_classify.py](https://github.com/TensorPy/TensorPy/blob/master/examples/test_python_classify.py))
15 changes: 0 additions & 15 deletions sample_images/ReadMe.md

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='tensorpy',
version='1.0.5',
version='1.0.6',
url='http://tensorpy.com',
author='Michael Mintz',
author_email='@mintzworld',
Expand Down
2 changes: 1 addition & 1 deletion tensorpy/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def download_and_classify_image(image_url):


def main():
expected_arg = "[PAGE_URL or IMAGE_URL]"
expected_arg = "[A valid PAGE_URL or IMAGE_URL]"
num_args = len(sys.argv)
if num_args < 2 or num_args > 2:
print "\n* INVALID RUN COMMAND! * Usage:"
Expand Down
3 changes: 3 additions & 0 deletions third_party/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Third-Party / Integrations

This folder contains TensorPy integrations
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ echo "Initializing TensorFlow setup on an Ubuntu Docker machine..."
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
pip install $TF_BINARY_URL
echo "Downloading ImageNet (image database for classifying images)..."
python download_imagenet.py
python tensorpy/download_imagenet.py
exit
8 changes: 8 additions & 0 deletions third_party/docker/run_docker_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e
# Run example test from inside Docker image
cd /TensorPy/
echo "Running example test: Classify a single image from a URL."
echo "classify https://raw.githubusercontent.com/TensorPy/TensorPy/master/examples/images/happy_animal.jpg"
classify "https://raw.githubusercontent.com/TensorPy/TensorPy/master/examples/images/happy_animal.jpg"
exec "$@"