Saravanan666/pypi-org huggingface dataset:
Package: clip2classdist
Clip2ClassDistClip2ClassDist is a Python script that analyzes image classes by leveraging OpenAI's CLIP model to generate image embeddings. It computes the center and radius of clusters formed by embeddings, the distribution of dot products within each class, and the average, minimum, and maximum dot products between different classes.The script takes a list of image folders as input, with each folder representing a distinct image class. It uses the specified CLIP model to create normalized embeddings for each image in the folders. The script then analyzes the embeddings using the Faiss library for efficient similarity search and clustering.InstallationClone the repository:gitclonehttps://github.com/ternaus/clip2classdist.gitInstall the required dependencies:pipinstall-rrequirements.txtUsageThe main script compute.py can be executed with the following command:Copycode
pythonclip2class_dist/compute.py--clip_modelMODEL_NAME--image_foldersCLASS_NAME_1FOLDER_PATH_1CLASS_NAME_2FOLDER_PATH_2[--deviceDEVICE]Arguments:--clip_model: Name of the CLIP model to use (e.g.,ViT-B/32). Where allowed models:ViT-B/32RN50RN101RN50x4RN50x16ViT-B/16RN50x64ViT-L/14ViT-L/14@336px--image_folders: List of pairs containing class names and corresponding folder paths containing images. Each pair should be separated by a space, and pairs should be space-separated as well (e.g., "dogs /path/to/dog_images cats /path/to/cat_images").--device (optional): Device to run the model on (default: "cpu"). Set to "cuda" if you have a compatible GPU.Example usage:pythonclip2class_dist/compute.py--clip_modelViT-B/32--image_foldersdogs/path/to/dog_imagescats/path/to/cat_images--devicecpuOutputThe script will output the following information:Cluster centers for each class.Cluster radii for each class.Dot product distributions within each class.Average dot product between different classes.Minimum dot product between different classes.Maximum dot product between different classes.Example output:Clustercenters:{'dogs':array([...]),'cats':array([...])}Clusterradii:{'dogs':0.2384927,'cats':0.27184734}Dotproductdistributions:{'dogs':array([...]),'cats':array([...])}Averagedotproductbetweenclasses:0.19983745
Minimumdotproductbetweenclasses:0.01759241
Maximumdotproductbetweenclasses:0.38273957LicenseThis project is released under the MIT License.
Package: clipable
clipableWhen we copy cells from spreadsheet or excel, clipboard change to markdown format using clipable.How to install$ pip install clipableHow to useCopy table from spreadsheet, csv etc.Open terminal, then run clipable.(if you will copy csv, run clipable -f csv)Paste to textarea.space separated formatclipablecsv formatclipable -f csvtsv formatclipable -f tsvLICENSEApache 2.0
Package: cli-parser
CLI ParserSimple Chained Command ParserThis tool will allow you to create a simple command hierarchy to execute from the command line.Examplefromcli_parserimportcommand,CliParser,ParentCommand,CommandExceptionget=ParentCommand('get')@commanddefproduct(x,y):returnx*y@commanddefsum(x,y):returnx+yget.add_sub_cmds(product,sum)parser=CliParser([get])whileTrue:in_=input("Enter command:\n==> ")try:response=parser.process_response(in_)print(response)exceptCommandException:passExecute your script from the command line:Enter command:
==> get product 5 10
50

Enter command:
==> get sum 10 20
30

Enter command:
==> q

'Quitting Interpreter'pypi:https://pypi.org/project/cli-parser/
Package: clipass
change log0.0.0 (Active)-stable version0.1.0 (Future)-save passwords to file.
-send passwords to email.
-generate passwords without conflicts between flags order.installpip install clipasshelpclipass -hdevelopersyou can add your own flags, by adding them to the "models" folder (each flag will be a package)you can take a loog for a reference to your own flag model inside "core/base_flags/length"examplesclipass >> generates 16 random passwords, with 10 charsclipass -m 2 >> generates 2 random passwords, with 10 charsclipass -l 5 >> generates 16 random password, with 5 chars
Package: cli_passwords
cli-passwordsMakes securely getting, storing, and retrying passwords from a command line interface easy!Free software: MIT licenseDocumentation:https://cli-passwords.readthedocs.io.FeaturesGet passwords from the keyring and if it’s not there prompt the user to securely enter their password.  The password will be stored in their keyring and they will not be prompted for their password againInject passwords into functions using the process described aboveAutomatically prompt the user to re-enter their password when they inputted the incorrect oneInstallationpipinstallcli-passwordsQuick StartPrompt the user for the password and store the password in their keyring.
This password will perists untilexpire_passwordis used or the keyword
argumentrefresh=Trueis passed into the function.fromcli_passwordsimportget_password# This will prompt the user for their password on the first# use only.  Whether it's a month later or minutes later, it# will pull the password from the keyring and not prompt the user againpassword=get_password('namespace','username')Inject the password into a function and retry when the password is incorrect.
You can specify the maximum number of retries using theretrykeyword
argumentfromcli_passwordsimportretry_password@retry_password('namespace','username',exception=AuthenticationException)defmy_func(password,arguments):ifpasswordisnotcorrect:raiseAuthenticationException('The password is wrong')else:# do something with the passwordmy_func('arguments')CreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0 (2016-07-21)First release on PyPI.
Package: clip-bbox
CLIP_BBoxCLIP_BBoxis a Python library for detecting image objects with natural language text labels.Overview / AboutCLIPis a neural network, pretrained on image-text pairs, that can predict the most relevant text snippet for a given image.Given an image and a natural language text label,CLIP_BBoxwill obtain the image's spatial embedding and text label's embedding from CLIP, compute the similarity heatmap between the embeddings, then draw bounding boxes around the image regions with the highest image-text correspondences.NoteThe files for building the CLIP model (clip.py,model.py,newpad.py,simple_tokenizer.py) are third-party code from theCLIP repo. They are not included in test coverage.FeaturesThe library provides functions for the following operations:Getting and appropriately reshaping an image's spatial embedding from the CLIP model before it performs attention-poolingGetting a text snippet's embedding from CLIPComputing the similarity heatmap between an image's spatial and text embeddings from CLIPDrawing bounding boxes on an image, given a similarity heatmapInstallUse pip to install clip_bbox as a Python package:$ pip install clip-bboxUsage ExamplesCommand Line Scriptusage: python -m clip_bbox [-h] imgpath caption outpath

positional arguments:
  imgpath     path to input image
  caption     caption of input image
  outpath     path to output image displaying bounding boxes

optional arguments:
  -h, --help  show this help message and exitTo draw bounding boxes on an image based on its caption, run$ python -m clip_bbox "path/to/img.png" "caption of your image" "path/to/output_path.png"Python ModuleTo draw bounding boxes on an image based on its caption, do the following:fromclip_bboximportrun_clip_bboxrun_clip_bbox("path/to/img.png","caption of your image","path/to/output_path.png")Example OutputHere is an example output image for the caption"a camera on a tripod":
Package: clipboard
A cross platform clipboard operation library of Python. Works for Windows, Mac and Linux.Well, as I was trying to implement this, I realize that everything is included in pyperclip already:https://pypi.python.org/pypi/pyperclip/But anyway,clipboardis a better name. You are free to choose:-) I might add more features to it.Usage:import clipboard
clipboard.copy("abc")  # now the clipboard content will be string "abc"
text = clipboard.paste()  # text will have the content of clipboard
Package: clipboard-maximizer
climax:ᴄʟɪpboadᴍᴀximizer.🐙🖥️🐍➕👮🏻☃️🔧4️⃣👯‍♀️🫢📁(🚫🗃️)⏭️📋(Amͫuͧltͭiͥplaͣtͭfoͦrͬmͫpython library and command line tool for copying 𝕬𝖈𝖙𝖚𝖆𝖑 𝕱𝖎𝖑𝖊𝖘(ie, not their content)to the clipboard.)climax:ᴄʟɪpboadᴍᴀximizer.1.1. Compatibility1.2. Installation1.3. Command Line1.3.1. Python API1.4. Contributing1.5. Blah1.1. CompatibilityOS🍎🐧🪟Integration available✅✅✅Tested on device✅✅🙊[1]extra requirementsnonexclippwshmacOSandLinuxare supported and tested; the latter viaxclip(apt-get install xclip)Windowsshould be supported (I can run it on mac Powershell viapwsh), but I don't have a Windows machine to test it on.1.2. InstallationUse pip, poetry, or your favorite python package manager to install the latest version of the clipboard maximiser:clipboard_maximizer.1.3. Command LineInstall with pipx:pipxinstallclipboard_maximizerThe script is available asclimax:climax--help# show helpclimaxfile1[file2]# copy file1 and file2 to the clipboardclimaxfile1--clipboardxclip# use a specific clipboard.# xclip, powershell (custom script) and applescript# are supported).1.3.1. Python APIInstall:pipinstallclipboard_maximizerOr, if you use poetry:poetryaddclipboard_maximizerUse:fromclipboard_maximizerimportcopy_to_clipboard;# copy file to clipboardcopy_to_clipboard("file1")# use a specific clipboard (see above)copy_to_clipboard("file1",clipboard="xclip")1.4. Contributingpoetryinstall
poetryrunpytestContributions, in particular windows-related, are welcome.If you plan to turn this into a full multiplatform clipboard manager, please fork the project and do so; I'll happily transfer the name to you.1.5. BlahLicense: MIT.
Package: clipboard_memo
A command line clipboard manager written in Python.This clipboard manager is intended to be used without opening any
additional screen. Once setup the only required step is to hit a key
combination to save the current contents of the clipboard for later use.Dependenciespyperclippython package is required. This package will be automatically installed.On some Linux distros ``xclip`` package may be required.Install it
withsudoapt-getinstall xclipon Ubuntu if you cannot save memos.InstallationUsing Pypi,pip install clipboard_memoNow bind a key-combination to thecmemo_directcommand to save
memos directly with a single keystroke.For example, for Ubuntu follow the instructionshereand typecmemo_directin theCommandfield.UsageTo see the help screen type:$ cmemo -h

usage: clipboard_memo <command> [<args>]
Available commands are:
    save                Save the contents of clipboard
    delete INDEX        Delete a memo of given index number
    delete -a | --all   Delete all saved memos
    ls                  List all saved memos
    yank INDEX          Copy a memo to clipboard

Save clipboard data as memos

positional arguments:
  command     Subcommand to run

optional arguments:
  -h, --help  show this help message and exitTodoMove frompickletosqlite3Add colorsShrink multi-line memosLicenseMIT
Package: clipboard-modifier
A flexible system to modify the text in a clipboard in a variety of ways.Out of the box we have:* Copy a spreadsheet and change the clipboard so that it can be pasted into a* wiki, with vertical bars (|) instead of tabs.  Modify your multi-line clipboard text so that it can be pasted into Java or Python as strings.* Modify an URL in the clipboard pointing to Amazon so that it has your Associate ID in it.* Run a shell command piping the clipboard to it and retrieving the output from it.* Force a clibpboard to text (removing formatting, etc.).* Convert a complicated url into it's python equivalent, using urlencode.* And many more...It uses wxPython and when you bring it's window to the front it modifiesthe clipboard with the currently selected utility.
Package: clipboard-monitor
clipboard_monitorClipboard Monitor will monitor the clipboard changes and trigger register events.
It's very easy to use, for details please refer below commandsUsagesimportclipboard_monitorfromPILimportImage,ImageGrabdefprint_text(text):print("got text")print(text)defprint_files(files):print("got files")print(files)defprint_image():print("got image")image=ImageGrab.grabclipboard()image.save("./test.png")clipboard_monitor.on_update(print)clipboard_monitor.on_text(print_text)clipboard_monitor.on_files(print_files)clipboard_monitor.on_image(print_image)clipboard_monitor.wait()
Package: clipboard-sync-client
跨平台剪贴板同步工具本项目是一个跨平台的剪贴板同步工具，目前仅支持文本同步移动端,可通过tasker(安卓)、快捷指令(iOS)调用api进行同步服务端dockerrun-d--restart=always-p主机端口:8080zhangkunyuan/clipboard-sync-server--access_token5577755客户端请确保系统内python3、pip均已安装linux使用教程windows使用教程
Package: clipcrop
clipcropExtract sections of images from your image by using OpenAI's CLIP and YoloSmall implemented on HuggingFace TransformersAdded new capability for segmentation using CLIP and Detr segmentation modelsInstallationpipinstallclipcropClip CropExtract sections of images from your image by using OpenAI's CLIP and YoloSmall implemented on HuggingFace TransformersImplementationfromclipcropimportclipcropcc=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 classCaptchaSolve captacha images using CLIP and Object detection models.fromclipcropimportclipcrop# second arguement is the text prompt eg:image of carscc=clipcrop.ClipCrop(image_path)#loading models, processors, feature extractorsDFE,DM,CLIPM,CLIPP=cc.load_models()#generally keep high threshold to avoid noisesresult=cc.captcha(CLIPM,CLIPP,4)Clip SegmentationSegment out images using Detr Panoptic segmentation pipeline and leverage CLIP models to derive the most probable one for your queryImplementationfromclipcropimportclipcropclipseg=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 etcRemove Backgroundfromclipcropimportclipcropclipseg=clipcrop.ClipSeg("/content/input.png","black colored car")result=clipseg.remove_background()Other projectsSnapCode : Extract code blocks from images mixed with normal textHuggingFaceInference: Inference of different uses cases of finetued models
Package: clip-gaze
clip-gazeAn art analysis tool powered by CLIP.MotivationDiffusion models (such asStable Diffusion) usedOpenAI's CLIPin order to perform textual analysis of their training data.
Precisely what these machine learning systems actually learned from their training data is
opaque.
This tool helps us understand how CLIP, and therefore the models that use CLIP,
see images.What does it do?Given an image and a series of (text) phrases it calculates therelativelikelihood of each phrase to be a good description of the image.
Note that this is not the same thing as "given a text phrase, calculate the accuracy of that phrase".An exampleLet's show it the painting"Brücke über die Marne bei Creteil" by Cézanne.
If we download the 2,175 × 1,713 pixel version of the painting and open it (e.g. usingPIL.Image.openfrom the packagepillow) asimagewe can then pass it to thegazecommand.# Assuming you have already saved the imageimportclip_gazeclip_gaze.gaze(image,clip_gaze.MOVEMENTS)Just looking at the highest probability outputs forclip_gaze.ARTISTS_BY_TRAINING_PREVALENCE,clip_gaze.Movements, andclip_gaze.SURFACESwe see:{'artist':['by paul cézanne (82%)'],'movement':['tonalism movement (16%)'],'surface':['on canvas (86%)']}So the terms "by paul cézanne", "tonalism movement", and "on canvas" are the most likely to describe the input image.For more examples and fuller documentation please see theproject's page on github.How does it work?CLIP is a tool provided by OpenAI that calculates the similarity between an image and some text.
This is a machine learning system trained on an enormous amount of data,
and that data will contain biases (intentional and unintentional).It is not a source of truth, but a useful tool to give you ideas about where to search next.This tool works by downloading CLIP onto your computer and running it locally.
This is not an easy task for all computers, especially older ones.
See the "Arguments forgaze" section of the project's README for a way to change memory load.BiasesThis software is built on a machine learning system, and the biases in this tool come in two parts:CLIP itself comes with its own biases, and we refer the user to OpenAI's own work on explaining and mitigating that biasThe lists of chosen phrasesThe lists used in this software are primarily from Wikipedia and from the training data that CLIP used.
Neither of these sources are perfect, and care should be taken when using this software to account for these biases where possible.
Although the lists are long (e.g. the list of 6000 artists) there are no claims of completeness or relative importance made.
Package: clip-interrogator
clip-interrogatorWant to figure out what a good prompt might be to create new images like an existing one? TheCLIP Interrogatoris here to get you answers!Run it!🆕 Now available as aStable Diffusion Web UI Extension! 🆕Run Version 2 on Colab, HuggingFace, and Replicate!Version 1 still available in Colab for comparing different CLIP modelsAboutTheCLIP Interrogatoris a prompt engineering tool that combines OpenAI'sCLIPand Salesforce'sBLIPto optimize text prompts to match a given image. Use the resulting prompts with text-to-image models likeStable DiffusiononDreamStudioto create cool art!Using as a libraryCreate and activate a Python virtual environmentpython3-mvenvci_env(forlinux)sourceci_env/bin/activate(forwindows).\ci_env\Scripts\activateInstall with PIP# install torch with GPU support for example:
pip3 install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu117

# install clip-interrogator
pip install clip-interrogator==0.5.5You can then use it in your scriptfromPILimportImagefromclip_interrogatorimportConfig,Interrogatorimage=Image.open(image_path).convert('RGB')ci=Interrogator(Config(clip_model_name="ViT-L-14/openai"))print(ci.interrogate(image))CLIP Interrogator uses OpenCLIP which supports many different pretrained CLIP models. For the best prompts for
Stable Diffusion 1.X useViT-L-14/openaifor clip_model_name. For Stable Diffusion 2.0 useViT-H-14/laion2b_s32b_b79kConfigurationTheConfigobject lets you configure CLIP Interrogator's processing.clip_model_name: which of the OpenCLIP pretrained CLIP models to usecache_path: path where to save precomputed text embeddingsdownload_cache: when True will download the precomputed embeddings from huggingfacechunk_size: batch size for CLIP, use smaller for lower VRAMquiet: when True no progress bars or text output will be displayedOn systems with low VRAM you can callconfig.apply_low_vram_defaults()to reduce the amount of VRAM needed (at the cost of some speed and quality). The default settings use about 6.3GB of VRAM and the low VRAM settings use about 2.7GB.See therun_cli.pyandrun_gradio.pyfor more examples on using Config and Interrogator classes.Ranking against your own list of termsfromclip_interrogatorimportConfig,Interrogator,LabelTable,load_listfromPILimportImageci=Interrogator(Config(blip_model_type=None))image=Image.open(image_path).convert('RGB')table=LabelTable(load_list('terms.txt'),'terms',ci)best_match=table.rank(ci.image_to_features(image),top_count=1)[0]print(best_match)
Package: clip-jax
CLIP-JAXThis repository is used to train customCLIP modelswith JAX:custom model architecturescustom sharding strategiestraining with constrastive loss orchunked sigmoid lossdownstream fine-tuningInstallationpipinstallclip-jaxNote: this package is currently under active development, install from source for latest version.UsageDownload training dataYou can download training data fromDataComp:# clone and install datacomp# download datapythondownload_upstream.py\--scalesmall--data_dirgs://my_bucket/datacomp/smallmetadata_dirmetadata\--image_size256--resize_modecenter_crop--skip_bbox_blurring--no_resize_only_if_bigger\--encode_formatwebp--output_formattfrecordAlternatively, you can use your own dataset. In that case you should useimg2datasetwithoutput_format="tfrecord".Train a modelUsetraining/train.pyto train a model:Here is an example command to train a model on a TPU v3-8:pythontrain.py\--assert_TPU_available\--config_name../configs/small-patch16.json--dtypefloat32\--do_train--train_foldergs://my_bucket/datacomp/small/shards\--output_dirgs://my_bucket/clip_model/$(date+"%Y%m%d%H%M%S")\--num_train_epochs10\--tokenizer_nameopenai/clip-vit-base-patch32\--batch_size_per_node4096--gradient_accumulation_steps1\--learning_rate0.00001--warmup_steps2000--lr_offset0\--optimdistributed_shampoo--beta10.9--beta20.99--weight_decay0.0\--block_size_text512--block_size_vision512--nesterov\--graft_typermsprop_normalized--preconditioning_compute_steps20\--mp_devices1--shard_shampoo_across2d\--activation_partitioning_dims1--parameter_partitioning_dims1\--loss_typesigmoid\--gradient_checkpointing\--unroll100\--logging_steps100--save_steps5000Use a trained modelRefer toutils/demo.ipynb.TODO: update demoDownstream tasksTODO:Image classification withCLIPVisionModelForImageClassificationText encoder withCLIPTextModelForFineTuningAcknowledgementsLucas Beyerfor helping with clarifications on theSigmoid Loss for Language Image Pre-Trainingpaper🤗 Hugging Face for CLIP reference implementation and training scriptsGoogleTPU Research Cloud (TRC) programfor providing computing resourcesWeights & Biasesfor providing the infrastructure for experiment tracking and model managementCitations@misc{radford2021learning,title={Learning Transferable Visual Models From Natural Language Supervision},author={Alec Radford and Jong Wook Kim and Chris Hallacy and Aditya Ramesh and Gabriel Goh and Sandhini Agarwal and Girish Sastry and Amanda Askell and Pamela Mishkin and Jack Clark and Gretchen Krueger and Ilya Sutskever},year={2021},eprint={2103.00020},archivePrefix={arXiv},primaryClass={cs.CV}}@misc{zhai2023sigmoid,title={Sigmoid Loss for Language Image Pre-Training},author={Xiaohua Zhai and Basil Mustafa and Alexander Kolesnikov and Lucas Beyer},year={2023},eprint={2303.15343},archivePrefix={arXiv},primaryClass={cs.CV}}