Skip to main content

A Package that uses AI to give users the caption of an image

Project description

Analog Image Caption Package

This is a Python package that helps give caption to your images, it is built on the Flickr_8k Dataset and trained with the Xception pre-trained model.


How to try this package ?

This package is very easy to use and has 2 fuctions which are:

  1. extract_features() this function simply take the image and extract the features from it.
  2. generate_desc() this function now generates a description for the Image.

Demo in a flask app

@app.route("/generateCaption", methods=["POST"])
def generateCaption():
    image = request.files['image']
    img = image.read()

    # convert string of image data to uint8
    nparr = np.fromstring(img, np.uint8)
    # decode image
    img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
    img = cv2.resize(img, (224, 224))
   

    photo = extract_features(img)
    # generate description
    caption = generate_desc(model, tokenizer, photo, max_length)

   
    return render_template("results.html", image=image, caption=caption)

Demo in a python script

#import image and extract feature
photo = extract_features(img_path)
img = Image.open(img_path)
description = generate_desc(model, tokenizer, photo, max_length)
print("\n\n")
print(description)
plt.imshow(img)

Hope this helps you understand the package and use it in a project. We are currently working on more cool features and will do an update when we're done.

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

analogcaption-0.1.0.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file analogcaption-0.1.0.tar.gz.

File metadata

  • Download URL: analogcaption-0.1.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for analogcaption-0.1.0.tar.gz
Algorithm Hash digest
SHA256 378303fde9475b377e2c16efc9653f373ce36b5787534239d82a260a40345472
MD5 a6681cb4827745c80e2fabf837888714
BLAKE2b-256 f674b172de84d361ac2f54d85889eec931e86eb661c5d522ab45bbbb32230be1

See more details on using hashes here.

Supported by

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