Photo Tagger imbues your photo collection with the smarts of AI by automatically generating searchable tags based on the content of each image. Checkout the Live Demo.
If you don't already have conda, install conda Take some time to learn about conda:
You can clone this repository, install all dependencies and try it in your browser quite easily:
git clone https://github.com/PhotoTagger/django-initial.git
cd django-initial
conda env create -n photoTaggerEnv -f=./environment.yml
source activate photoTaggerEnv
python manage.py migrate
python manage.py runserver
To set up your environment, you need to create a one-time environment variable for making requests to cloudinary For access to one of the keys, please contact an administrator of the repo or create your own account on cloudinary
-
Setup the
CLOUDINARY_URL
environment variable by copying it from the Management Console:Using zsh/bash/sh
$ export CLOUDINARY_URL=cloudinary://API-Key:API-Secret@Cloud-name
Using tcsh/csh
$ setenv CLOUDINARY_URL cloudinary://API-Key:API-Secret@Cloud-name
Using Windows command prompt/PowerShell
> set CLOUDINARY_URL=cloudinary://API-Key:API-Secret@Cloud-name
Lets agree on a short list of leading active verbs:
add: Create a capability e.g. feature, test, dependency.
delete: Remove a capability e.g. feature, test, dependency.
fix: Fix an issue e.g. bug, typo, accident, misstatement.
build: Change the build process, or tooling, or infra.
refactor: A code change that MUST be just a refactoring.
docs: Refactor of documentation, e.g. help files.
Ex: git commit -m "Add: Added API to urls.py"
Installing dependencies that were added to the environment.yml file
conda env update environment.yml
conda activate photoTaggerEnv or source activate photoTaggerEnv
Viewing current dependencies installed within an environment
conda list
Instead of doing a conda install <package>
you should manually add it to the environment.yml file and
then follow the instructions above to perform a conda update
Unit tests for a specific module only can be run using this command from the project root /django-initial:
coverage run --source='.' manage.py test imageprocessor.tagservice
This module's tests will also be included automatically as part of overall django test suite by running this command from the project root /django-initial:
coverage run --source='.' manage.py test
You can then view the the code coverage report running this command from the project root /django-initial:
coverage report -m
This API accepts one or more images and returns a list of tags for each image.
You can try the API by using this curl command.
curl -F "file=@[FULL PATH TO IMAGE FILE1]" -F "file=@[FULL PATH TO IMAGE FILE2]" http://127.0.0.1:8000/api/classify/
You can also try this API by using the postman app.
- Set the method to POST
- Set the url to http://127.0.0.1:8000/api/classify/
- On the Body tab, select form-data.
- Set the following:
- Type "file" in the key field without the quotes.
- Change the type from text to file.
- Click the Choose Files button under value and select the image you want to tag.
- Repeat the previous 3 sub-steps for each image you want to include in your request.
- Press the Send button
A successful response from this API will have an overall HTTP status code of 207 (Multistatus) and the following JSON structure. Where "results" is an array holding the individual result of each image upload operation.
"status" holds the HTTP status code associated with the individual image
"url" is the location where the image was stored in the cloud and "public_id" is its resource id
"tags" is an array of tags generated for the image.
{
"results": [
{
"status": 200,
"error_message": null,
"name": "yourimage.jpg",
"public_id": "yourimage_abcd",
"url": "http://res.cloudinary.com/yourimage_abcd.jpg",
"tags": [
"tagA",
"tagB",
"tagC"
]
},
{
"status": 415,
"error_message": "We can't process that file type. Please submit a different file",
"name": "text_file.txt",
"public_id": null,
"url": null,
"tags": []
}
]
}