Saravanan666/pypi-org huggingface dataset:
Package: img2rag
img2ragConvert any image into itsRegion Adjacency Graphwhich can be used for either image segmentation or to create a graph embedding of the image.InstallationSimply runpip install img2ragWhat is doesGiven an image, we segement it into morphological regions using firstFelzenszwalb segmentationfollowed by athreshold-cut. We then use the segmeneted regions to construct the following graph:Each node corresponds to a segmented region.We connect two regions if they are adjacent.This is the so-called region adjacency graph. Furthermore, we add the following node-attributes to each region:Location of the region centeriodOrientation of the regionMean and total color of the regionSize in pxThe edges contain the mean-color difference between the two regionsHow to useSimply import theRAGimageclass and initiate with any image. Then use the build in methods to access various properties.fromimg2ragimportRAGimage# We assume the image is given as a numpy array or tf.Tensor with either 2 or 3 dimensions# where the third dimension is the optional channel dimension.img_tensor=[...]# initiate RAGiamge instanceimage_rag=RAGimage(img_tensor)# RAG as a networkx attributed DiGraphimage_rag.rag# Scikit style labels of the image segementationimage_rag.labels# Adjacency matric of the RAGimage_rag.adjacency# Graph feature matrix of the RAG# (Nodes x Node-Features)image_rag.signal
Package: img2scad
img2scad - Convert images to OpenSCAD structures
<https://gitlab.com/engmark/img2scad>Default syntax:img2scad [-b|–base=N] [-l|–log] < input_fileDescription:For each pixel in the input, it will create a cube in the output. The height of
the cube corresponds to the whiteness of the corresponding pixel.If -b or –base is specified, all values will be shifted by that value. This
can be positive or negative. This can be used to output zero values.If -l or –log is specified, the logarithm of the grey values will be used for the output.Examples:img2scad < example.png > example.scadConvert example.png to example.scad.img2scad -b 1 < example.png > example.scadConvert example.png to example.scad, with a “bedrock” of height 1.img2scad -b 2 -l < example.png > example.scadConvert example.png to example.scad, taking the logarithm for the height
and preserving the black pixels.<http://www.thingiverse.com/thing:4448>Bugs:Please submit bug reports athttps://gitlab.com/engmark/img2scad/-/issues.
Package: img2sh
Img2shImg2sh is a tool to show images directly on terminal.
For color images 256 xterm color support is required. This script basically resize the image with antialliasing and quantized its colors to xterm color pallette.DemoTesting the package is super easy. Install and run.pip install img2sh --user
img2sh demo.jpegResult:Demo with interactive modeimg2sh demo.jpeg -w 80 -i

q: quit z: zoom+ x: zoom- c: reset 
arrow keys for navigation 
cmd: qFor detailed usage arguments:$ python img2sh/cli.py --help

usage: cli.py [-h] [-w WIDTH] [-i] Image

Show images directly on terminal.

positional arguments:
  Image                 the directory of the image which will be opened

optional arguments:
  -h, --help            show this help message and exit
  -w WIDTH, --width WIDTH
                        image width on the terminal
  -i, --interactive     open image in interactive modeInstallingIt can be easily install using pip.pip install img2sh --userInstalling from source:git clone https://github.com/mozanunal/img2sh
cd img2sh
pip install -r requirements.txt
python setup.py installDevelopmentSetup development environmentConda is using for environment management.conda create -n img2sh python=3.8Following command should be executed to create interactive shell in this conda environment.conda activate img2shDevelopmentIn this repo issue based development is active. For any problems or new enhancements please open a issue.Autopep8 is used for formatting.autopep8 -r -i img2sh testPylint is used for linting.pylint img2shDeploymentThe following 2 commands are required to deploy over pypi.python setup.py sdist bdist_wheel
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*LicenceMITAcknowledgesThis package is developed using:PillowcoloredContributorsmozanunal
Package: img2sketch
This is a simple Python package that converts your beautiful photos to pencil art. The transformed photo just looks like a photo which is drawn using pencil.For this package to run without any errors the following packages should be installed on your system
1)opencv-python and 2)numpyAll you have to do is just download the package aspip install img2sketchYou can use this package in your code as##usagefrom Pencil.PencilArt import img2sketch
            img2sketch("/path/of/your/original/photo.jpg", "/path/where/your/newphoto/tobe/saved.jpg")For example: I have pavan.jpg photo under /home/pavan/Desktop/pavan.jpg I want the new transfromed photo at the same folder (Desktop) as new.jpg Here my code looks likeimg2sketch("/home/pavan/Desktop/pavan.jpg", "/home/pavan/Desktop/new.jpg")After the program executes the transformed photo is saved under the path you have provided.
Package: img2speech
✅DESCRIPTIONAn ITTTS (Image-to-text-to-speech) python package for integrated conversion of textual images and PDF document to human speech.
This library aims at easing the internal image preprocessing and conversion of extracted text to human speech over multiple languages.✅QUICK STARTDependenciesThis pipeline requires the dependencies which can be installed by running:pip install -r requirements.txt✅FUNCTIONSimage_to_sound(path_to_image, lang, pre_process="NO")This main function is leveraged to convert the input textual image to human speech in the language present in the text.
The function returns the intermediate text extracted and the speech generated. The speech can then be saved to a .mp3 file.Parameters:path_to_image : Defines the path to the "image" as .png or .jpg files. PDF files are also supported along with public image URLs from the internetlang : Defines the language used in the text. The list of languages supported currently include:["ENGLISH" , "HINDI", "TELUGU", "KANNADA"]pre_process(optional) : If the user would like to use our internal pre-processing pipeline for better results.For example:image_to_sound("images/image1.png","ENGLISH",pre_process="YES")ORimage_to_sound("files/text.pdf","HINDI",pre_process="YES")ORimage_to_sound("https://www.techsmith.com/blog/wp-content/uploads/2020/11/TechSmith-Blog-ExtractText.png","ENGLISH",pre_process="YES")preprocess(path_to_image):This function defines the internal pre-processing pipeline used in the package. The user could use this function to retrieve the intermediate preprocessed image before conversion to text and speech.For example:preprocess("images/image1.jpg"):MODELS USED FOR OCRAfter the input image is ensured to be of high quality, we use an efficient OCR
tool called ”EasyOCR” for conversion of textual image to human readable text.
We preferred EasyOCR over other tools like tesseract because EasyOCR provides
us with pre-trained models for various languages. They also perform well on noisy
or low-quality images. It is designed to be fast and can process multiple images
in parallel making it suitable for use.TEXT TO SPEECH CONVERSIONWe leverage ”gTTS (Google Text-to-Speech)”
to accomplish this task. ”gTTS” is a popular TTS (Text-to-Speech) engine
that uses Google’s machine learning and neural network algorithms to synthesize
natural-sounding speech from text input. We chose gTTS engine because GTTS
allows for customization of voice, pitch, speaking rate, and volume to create a more
personalized listening experienceINSTALLATIONInstall using pipFor the latest stable release:pip install img2speechUSAGEimport img2speech
text,speech = img2speech.image_to_sound("images/image1.png", "ENGLISH", "YES")
print(text) # prints text extracted by OCR model
speech.save("output.mp3") # saves the speech output as mp3 file
Package: img2svg
Convert an image to an SVG format with interactive elementsInstallationpython3-mpipinstallimg2svgUsageimg2svg--help

img2svginput.png

img2svginput.png-cconf.txt

img2svginput.png-cconf.txt-ooutput.svg--fill-color'#FF00FF'--fill-opacity0.5Config Formatseparate with<Tab>x   y   rx  ry  title   linkconfig.txtexample:0   0   140 720 Eudicots    https://www.baidu.com/s?wd=Eudicots
141 0   510 720 Monocots    https://www.baidu.com/s?wd=Monocots
511 0   720 720 Lycophytest https://www.baidu.com/s?wd=Lycophytest
721 0   890 720 Liverworts  https://www.baidu.com/s?wd=Liverworts
891 0   1359    720   Mosses   https://www.baidu.com/s?wd=Mosses
Package: img2tags
img2tagsTag images by usingONNX Runtime.
The current default model isSmilingWolf/wd-v1-4-moat-tagger-v2.
It works fine for anime images.Setup# For CPUpipinstall-U'img2tags[cpu]'# For GPUpipinstall-U'img2tags[gpu]'# If you use CUDA 12.2, the following packages may be neededsudoaptinstalllibcufft10libcudart11.0Run# Generate .txt fileimg2tags-iinput_dir# Generate .json file in another directory with CPU#   --offline: Do not fetch model files (You must have downloaded that model)img2tags--extjson\--cpu\-iinput_dir\-ooutput_dir\--offline# Output to a single file (JSONL)img2tags--extjsonl\--cpu\-iinput_dir\-ooutput_filename.jsonl\--offline# You can use filelistimg2tags--extjsonl\--cpu\-itarget_file_list.txt\-ooutput_filename.jsonl\--offlineThe values of default thresholds are stored inconfig.jsonin each model likethis.
You can set values in JSON format like--th {"0": 0.3, "4":0.2, "9":0.3}.LICENSEApache 2.0Some codes are based on codes in the following project.https://github.com/kohya-ss/sd-scriptsReferencesConvert onnx models to change batch size
Package: img2text
img2textA lightweight module to generate colorful ascii art from imagesTo install img2text:pipinstallimg2textHow To UseLet's use the python logo as reference:To generate an ascii imagefromimg2textimportimg_to_asciiascii_img=img_to_ascii('data/python.png',width=80)print(ascii_img)We obtain the following:Adding ColorWe can customize this further by adding color (to be shown in the console):fromimg2textimportimg_to_asciiascii_img=img_to_ascii('data/python.png',width=80,colorful=True)print(ascii_img)We obtain the following:Customizing OutputWe can reverse the intensity of the image by settingreverseto Truefromimg2textimportimg_to_asciiascii_img=img_to_ascii('https://raw.githubusercontent.com/hmiladhia/img2text/master/data/python.png',width=80,colorful=True,reverse=True)print(ascii_img)We obtain the following:We can get a slightly brighter image by adding thebrightoption which sets the characters to bold:fromimg2textimportimg_to_asciiascii_img=img_to_ascii('data/python.png',width=80,colorful=True,reverse=True,bright=True)print(ascii_img)We obtain the following:You can also change the character set by providing a custom string of characters that increase in intensity:fromimg2textimportimg_to_asciichars=r" ░▒▓█"ascii_img=img_to_ascii('https://raw.githubusercontent.com/hmiladhia/img2text/master/data/python.png',width=80,colorful=True,bright=True,chars=chars)print(ascii_img)We obtain the following:Exporting ASCII image to a fileIt's also possible to export the result to a text file, so you can print its content using thecatcommand for example
To do this all you need to do is to write the content to a file:fromimg2textimportimg_to_asciiascii_img=img_to_ascii('https://raw.githubusercontent.com/hmiladhia/img2text/master/data/python.png',width=80,colorful=True)withopen('logo.ascii','w')asf:f.write(ascii_img+'\n')or using the CLI:img2text-cw80-ologo.asciidata/python.pngAdditional OptionsCustomize the width and height by providing the number of columns/lines to useCustomize the aspect ratio by providingar_coefcoefficient. The default value is set to 2.4
but depending on the console you are using it might be interesting to try out values from [2, 3]You can add a Background Color by settingbg_colorto one of the following values:BLACKREDGREENYELLOWBLUEMAGENTACYANWHITE
Package: img2texture
img2textureCommand line utility for converting images to seamless tiles.
It overlays images with an alpha gradient.The resulting tiles can be used as textures in games, compositing and 3D modeling applications, etc.⚠️ If the images below are not displayed, check out theoriginal of this document on GitHub.Original image x4Orion galaxy by NASA/ESA, in four copies side by side.We cannot use the original image as an endless space background: the seams are visible.Converted image x4The result ofimg2texture, in four copies side by side.The image is slightly reduced in size and the edges are modified with
alpha-blending.The converted image can be tiled and panned in any
direction. It will feel endless and seamless.InstallThe easiest way is to download and extract abinary executable:for macOSfor Linuxfor WindowsOr install as a Python package:pip3installimg2textureRunCreate newseamless.jpgfromsource.jpg.img2texture/path/to/source.jpg/path/to/seamless.jpg--overlapThe--overlapoption determines how much of the image will be used to hide the seams.For example, the following command uses 25% of the width and 25% of the height
of the original image:img2texturesource.jpgseamless.jpg--overlap0.25Increasing the value makes the seam less visible. However, the image becomes smaller.Sample images⚠️ If the images below are not displayed, check out theoriginal of this document on GitHub.--overlap 0.055% of the width and 5% of the height are used to mask the seam.--overlap 0.440% of the width and 40% of the height are used to mask the seam.--tileThe--tileoption will create a 2x2 tiled version in addition to the converted image.The following command will createseamless.jpgandseamless_2x2.jpg.img2texturesource.jpgseamless.jpg--tileAll the samples on this page were created with--tile.Use programmaticallyIf you don't need CLI but need to create seamless image in your own program:fromPILimportImagefromimg2textureimportimage_to_seamless# load PIL imagesrc_image=Image.open("/path/to/source.png")# convert to seamless PIL imageresult_image=image_to_seamless(src_image,overlap=0.1)# saveresult_image.save("/path/to/result.png")overlap=0.1means 10%, andoverlap=(0.1, 0.2)means 10% horizontal, 20% vertical.LicenseCopyright © 2021Artёm iG.
Released under theMIT License.
Package: img2txt
################################################################################this is a moderately sophisticated python3.0 script fully utilizingextensions, & demonstrated to run under python2.6 via py3to2.for performance, portions of it have been inlined w/ direct C code usingscipy.weave.  the algorithm also heavily uses bitwise operations.it takes a jpg, gif... image file & outputs it in colorized ascii art.also serves dual purpose as a 3-d colorized scientific plotter in text terminals(screenshots of image conversion & 3d plot in putty terminal included)if something fails, try updating ur install of py3to2 to the latest version @:http://pypi.python.org/pypi/py3to2how to enable 256 color on putty: http://www.emacswiki.org/emacs/PuTTY#toc2how to enable 256 color on xterm: http://www.frexx.de/xterm-256-notes/img2txt is hard-coded to use lucida-console font, but courier looks ok.the screenshot shows putty w/ lucida-console 5pt.AUTHOR:kai zhukaizhu256@gmail.comREQUIREMENTS:- posix/unix os (Windows currently unsupported)- py3to2- Python Imaging Library- scipyAPI:img2txt module:- img2plaintxt - converts image file to portable plain txtu can copy & paste in documents- img2txt - converts image to high-quality colorized txtfor display on terminals supporting 256 color (putty, xterm...)- tplot3d - 3d color scientific plotterUSAGE:start up the py3to2 interpreter by typing "py3to2" in ur terminal &import img2txt:$ py3to2Python 2.6.py3to2 (r26:66714, Nov 18 2008, 00:56:43)[GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>>>>> import img2txtcreated...py3k server starting...>>> ...py3k server started w/...>>>in this example, u'll b loading the image file included w/ this distribution,"mario.jpg".  its a fairly large image, so u probably want to scale it downto 0.5 (or less):>>> colortxt = img2txt.img2txt('mario.jpg', scale = 0.5)>>> print( colortxt )... beautiful image appears ^_->>> plaintxt = img2txt.img2plaintxt('mario.jpg', scale = 0.5)>>> print( plaintxt )... rather plain b/w img -_-, but u can copy & paste it in documentsactually, the plaintxt prolly won't look well when pasted,b/c most document readers invert the color:>>> plaintxt = img2txt.img2plaintxt('mario.jpg', scale = 0.5, invert = True)>>> print( plaintxt )... b/w img w/ colors inverted.  may look funny now :/but it'll b normal when u paste it into ur documentthe 3d plotting feature is a bit more complicated.  for the time being,simply run the test.  (if u want to kno how to use it,u'll need to look @ the img2txt.tplot3d.test() method in img2txt.py)>>> img2txt.tplot3d.test()################################################################################RECENT CHANGELOG:currentfixed bug where 64bit  gets truncated to 32 on 32bit machine256 color support20081119fixed bugs in setup.py
Package: img2wav
img2wav is a simple command line utility to convert image files into audio clips
suitable for display in a spectrogram. Multiple images can be specified to
create a scrolling display.Installationimg2wav can be installed from pip:pip3 install img2wavUsageimg2wav provides a simple command line interface to generate wav files. It’s
relatively easy to tune parameters for waveform generation, allowing you to
optionally specify the delay between images, center frequency, image bandwidth,
and output file samplerate.$ img2wav -o res/hackers.wav res/images/*
[*] Writing wav file: res/hackers.wav
[*]   Center frequency: 2750hz
[*]   Bandwidth       : 4000hz
[*]   Sample rate     : 11025hz
[*]   Delay           : 2000ms
[*] Processing: res/images/glider.png
[*] Processing: res/images/hackers.bmp
[*] Processing: res/images/hacktheplanet2.bmp
[*] Processing: res/images/hacktheplanet.jpg
[+] Done
Package: img2zarr
# img2zarr[![PyPI Badge](https://img.shields.io/pypi/v/img2zarr.svg)](https://pypi.python.org/pypi/img2zarr)
[![Travis Status](https://img.shields.io/travis/hubmapconsortium/img2zarr.svg)](https://travis-ci.com/hubmapconsortium/img2zarr)Python package for converting images to zarr chunked arrays.Free software: MIT licenseDocumentation:https://img2zarr.readthedocs.io.
Package: img64
This library is a tool for converting images to base64 encoding and vice versa.It was implemented by referencingternaus/base64ToImageConverters.The referenced code didn't ensure data consistency, so this code improves that issue.This code enhances user convenience in handling both RGB and grayscale images.Installationpipinstallimg64Quick startConvert pil image to base64fromPILimportImageimportimg64image=Image.open('sample.png')base64=img64.image_to_base64(image)base64[:30]# 'iVBORw0KGgoAAAANSUhEUgAABAAAAA...'Convert numpy(opencv) image to base64importcv2importimg64image=cv2.imread('sample.png')image=cv2.cvtColor(image,cv2.COLOR_BGRA2RGBA)base64=img64.image_to_base64(image)base64[:30]# 'iVBORw0KGgoAAAANSUhEUgAABAAAAA...'Convert base64 to pil imageimportimg64base64='iVBORw0KGgoAAAANSUhEUgAABAAAAA...'image=img64.base64_to_image(base64,type='pil')type(image)# PIL.Image.ImageConvert base64 to numpy imageimportimg64base64='iVBORw0KGgoAAAANSUhEUgAABAAAAA...'image=img64.base64_to_image(base64,type='numpy')type(image)# numpy.ndarray
Package: img-ai-prep
img_ai_prepMore intelligently crop photos for ingestion to ML models.
Supports two major workflows that will be useful to produce higher quality images:resize_center_cropResize the image with the shortest side matching the desired end sizeCrop only the longer side to achieve final square image, preserving maximum content towards the centerface_center_cropResize the image with the shortest side matching the desired end sizeCrop towards detected faces in the image, preserving maximum human contentIn addition to these enhanced cropping modes, the code also supports cropping towards faces without resizing,
center cropping without resizing,
and exposes the underlyingcropandresizefunctions for use in your own workflows.There is also support for easily passing custom models for face detection, and passing custom parameters to the models.
Passing the model by argument also improves performance if you are working in a loop,
as it does not need to read the model from disk every time if passed by argument.UsageOriginal Imagenoresize_center_cropresize_center_cropface_center_cropnoresize_face_centerSimply install with pip and get to processing your images!pipinstallimg_ai_prepfromPILimportImagefromimg_ai_prepimportimg_ai_prepim=Image.open("input.jpg")newimg=img_ai_prep(im,final_size=1024,crop_mode="resize_center_crop")print(newimg.size)newimg.save("output.jpg")Advanced example script passing a custom model and parameters:importcv2fromPILimportImagefromimg_ai_prepimportimg_ai_prepif__name__=="__main__":im=Image.open("my_img.jpg")model=cv2.CascadeClassifier(cv2.data.haarcascades+"haarcascade_frontalface_alt.xml")newimg=img_ai_prep(im,final_size=1024,crop_mode="face_center_crop",model=model,min_neighbors=50,min_size=(100,100))print(newimg.size)newimg.save("my_output.jpg")
Package: imgarray
imgarray (Python)This stores 1D and 2D numpy arrays as png images. As a method of storage, not visualization (usepillowfor that).Q: Why would you ever want that?It’s somewhat, though not extremely, space-efficient.Saving and loading PNGs is supported by many languages, so all you need to do is port this library.Results look kind of funny, nothing too interesting though.Because you can.ExampleInstallationThis package requiresnumpyandpillow. They will be installed automatically if you install using pip:pipinstallimgarrayUsageUsage is very simple, there are only two functions:fromimgarrayimportsave_array_img,load_array_imgdata=randn((500,500)).astype(int16)save_array_img(data,path)data2=load_array_img(path)You can check outdemo.pyor the tests for more (not a lot more to be fair, it’s a simple tool).Notes1D arrays will be returned as 2D arrays with one unit dimension, because images are 2D.It works with most numpy data types (specifically, the ones that use a number of bytes which is a power of 2).If you remove metadata from the PNG, the file only loads correctly if the data was float64, and you’ll also get a warning.If the data has more or less than 4 bytes per value, the height of the image is scaled to match. So array shape and image shape are similar but not necessarily identical.Usage & contributionsRevised BSD License; at your own risk, you can mostly do whatever you want with this code, just don’t use my name for promotion and do keep the license file.Pull requests are welcome, especially with unit tests. Due to the great importance of this library, maintenance is not going to be high-priority.