Skip to main content

Extract sections from your image by using OpenAI CLIP and Facebooks Detr implemented on HuggingFace Transformers

Project description

clipcrop

  • Extract sections of images from your image by using OpenAI's CLIP and YoloSmall implemented on HuggingFace Transformers
  • Added new capability for segmentation using CLIP and Detr segmentation models

Installation

pip install clipcrop

Clip Crop

Extract sections of images from your image by using OpenAI's CLIP and YoloSmall implemented on HuggingFace Transformers

Implementation

from clipcrop import clipcrop
cc = clipcrop.ClipCrop("/content/sample.jpg")
DFE, DM, CLIPM, CLIPP = cc.load_models()
result = cc.extract_image(DFE, DM, CLIPM, CLIPP, "text content", num=2)
# gives a list of dicitonary of top images and its relative similarity score and you can override this by setting num = 5  to get top 5 etc while initiating the class

Captcha

Solve captacha images using CLIP and Object detection models.

from clipcrop import clipcrop
# second arguement is the text prompt eg:image of cars
cc = clipcrop.ClipCrop(image_path)
#loading models, processors, feature extractors
DFE, DM, CLIPM, CLIPP = cc.load_models()
#generally keep high threshold to avoid noises
result = cc.captcha(CLIPM, CLIPP, 4)

Clip Segmentation

Segment out images using Detr Panoptic segmentation pipeline and leverage CLIP models to derive the most probable one for your query

Implementation

from clipcrop import clipcrop
clipseg = clipcrop.ClipSeg("/content/input.png", "black colored car")
segmentor, clipmodel, clipprocessor = clipseg.load_models()
result = clipseg.segment_image(segmentor, clipmodel, clipprocessor)
# gives a list of dicitonary of top images and its relative similarity score and you can override this by setting num = 5  to get top 5 etc

Remove Background

from clipcrop import clipcrop
clipseg = clipcrop.ClipSeg("/content/input.png", "black colored car")
result = clipseg.remove_background()

Other projects

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

clipcrop-2.4.5.tar.gz (7.5 kB view details)

Uploaded Source

File details

Details for the file clipcrop-2.4.5.tar.gz.

File metadata

  • Download URL: clipcrop-2.4.5.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for clipcrop-2.4.5.tar.gz
Algorithm Hash digest
SHA256 03f2470058182a6dd893a61407afb7daa73b9684993da6f6cee5a016ec730ed6
MD5 dbcb28d324af11364473a47b679bcd61
BLAKE2b-256 702f3fbe096e0deff8e30fc6b5e8cd13fc01ae673d42724a5165f7d5a787accf

See more details on using hashes here.

Provenance

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