Saravanan666/pypi-org huggingface dataset:
Package: segment-anything-onnx
segment-anything-onnxUse ONNX models for Segment Anything inference.Special thanks to:Viet-Anh NGUYENfor creating theSAM Exporterlibraries from which these files are derived.TheSegment Anythingteam at Meta AI ResearchUsage from SourceClone Segment Anything ONNX from Githubgitclonegit@github.com:whatstyle-ai/segment-anything-onnx.gitcdsegment-anything-onnx
pipinstall-e.Use theSAM Exporterto generate the ONNX modelsCopy the ONNX models to the segment-anything-onnx/models directoryPredict some maskscdsegment-anything-onnx
./demo.shUsage from pip installUse theSAM Exporterto generate the ONNX models, or obtain the ONNX models from another sourceCopy the ONNX models to a "models" directory, such as:models/sam_vit_l_0b3195.encoder.onnx
models/sam_vit_l_0b3195.decoder.onnxInstall Segment Anything ONNX using pip:pipinstallsegment-anything-onnxPredict a mask:importcv2importurllib.requestimportnumpyasnpfromsegment_anything_onnx.inferenceimportpredict_masksdefload_image(uri):if(uri.startswith('https://')oruri.startswith('http://')):req=urllib.request.urlopen(uri)arr=np.asarray(bytearray(req.read()),dtype=np.uint8)img=cv2.imdecode(arr,-1)# 'Load it as it is'returnimgelse:returncv2.imread(uri)# uri is just a local file pathencoder_model_path='./models/sam_vit_l_0b3195.encoder.onnx'decoder_model_path='./models/sam_vit_l_0b3195.decoder.onnx'image=load_image('https://raw.githubusercontent.com/whatstyle-ai/segment-anything-onnx/main/examples/laura.jpg')prompt=[{'type':'point','data':[1750,300],'label':0},{'type':'rectangle','data':[611,655,2712,4500]}]options={'show':True,'output':'./output/laura-L.png'}predict_masks(encoder_model_path,decoder_model_path,image,prompt,options)
Package: segmentation
Fast Mixture Model SegmentationFast mixture model segmentation used in Boone and Andrews labsPython requirementsNumpyCythonscikit-imageInstallationCreate a virtual environment (optional)$virtualenv-ppython3segmentation-env
$sourcesegmentation-env/bin/activateInstall python requirements (needed to build the package)$pipinstallnumpycythonInstall our library (pulls in all other dependencies)$pipinstallsegmentationUsage exampleimportsegmentationassegfromskimage.ioimportimreadimage=imread('./001001000.tiff',plugin='tifffile')[1]# Read channel 1 of a tiff/flexim=seg.blur_frame(image)# gaussian blursegmented,_=seg.mixture_model(im,debug=True)# second return argument is currently unusedlabels=seg.watershed(im,segmented)
Package: segmentation-mask-overlay
Segmentation mask overlayIf you ever wonder to overlay your segmentations onto a picture in the smoothiest way, you're in a right place.Installationpip install segmentation-mask-overlayDescriptionHere you can take your segmentation map, put on an image individually or in a company. If you have a bunch of them, they will blend if touch each other.You can even name them one by one, providing labels.That's it! As simple as is. Now you are completely ready to laminate images with your segmentation.How to useimportmatplotlib.pyplotaspltimportnumpyasnpfromPILimportImagefromsegmentation_mask_overlayimportoverlay_masks# [Example] Load imageimage=Image.open("cat.jpg").convert("L")image=np.array(image)# [Example] Mimic list of masksmasks=[]foriinnp.linspace(0,image.shape[1],10,dtype="int"):mask=np.zeros(image.shape,dtype="bool")mask[i:i+100,i:i+200]=1masks.append(mask)# [Optional] prepare labelsmask_labels=[f"Mask_{i}"foriinrange(len(masks))]# [Optional] prepare colorscmap=plt.cm.tab20(np.arange(len(mask_labels)))[...,:-1]# Laminate your image!fig=array=overlay_masks(image,np.stack(masks,-1),mask_labels,return_type="mpl")# Do with that image whatever you want to do.fig.savefig("cat_masked.png",bbox_inches="tight",dpi=300)CHANGELOGv0.4.4:Dropped mandatory label arg inoverlay_masks()Added one-channel binary masks handling inoverlay_masks()
Package: segmentation-refinement
Segmentation RefinementThis is an easy-to-use package version of the CVPR2020 paperCascadePSP. It can refines a binary input segmentation of an image. For details, please refer to the complete repository linked above and the paper.InstallationThrough pip:pipinstallsegmentation-refinementor locally,pipinstall-e.UsageThe code has been tested on Ubuntu with PyTorch 1.4.importcv2importtimeimportmatplotlib.pyplotaspltimportsegmentation_refinementasrefineimage=cv2.imread('test/aeroplane.jpg')mask=cv2.imread('test/aeroplane.png',cv2.IMREAD_GRAYSCALE)# model_path can also be specified here# This step takes some time to load the modelrefiner=refine.Refiner(device='cuda:0')# device can also be 'cpu'# Fast - Global step only.# Smaller L -> Less memory usage; faster in fast mode.output=refiner.refine(image,mask,fast=False,L=900)plt.imshow(output)plt.show()The pre-trained model will be downloaded automatically.Output (4.77s):Output (fast, 0.45s):
Package: segmentation-skeleton-metrics
segmentation-skeleton-metricsPython package for performing a skeleton-based evaluation of a predicted segmentation of neural arbors. This tool detects topological mistakes (i.e. splits and merges) in the predicted segmentation by comparing the ground truth skeleton to it. Once this comparison is complete, several statistics (e.g. edge accuracy, split count, merge count) are computed and returned in a dictionary.UsageHere is a simple example of evaluating a predicted segmentation. Note that this package supports a number of different input types, see documentation for details.importosfromaind_segmentation_evaluation.evaluateimportrun_evaluationfromaind_segmentation_evaluation.conversionsimportvolume_to_graphfromtifffileimportimreadif__name__=="__main__":# Initializationsdata_dir="./resources"target_graphs_dir=os.path.join(data_dir,"target_graphs")path_to_target_labels=os.path.join(data_dir,"target_labels.tif")pred_labels=imread(os.path.join(data_dir,"pred_labels.tif"))pred_graphs=volume_to_graph(pred_labels)# Evaluationstats=run_evaluation(target_graphs_dir,path_to_target_labels,pred_graphs,pred_labels,filetype="tif",output="tif",output_dir=data_dir,permute=[2,1,0],scale=[1.101,1.101,1.101],)# Write out resultsprint("Graph-based evaluation...")forkeyinstats.keys():print("{}:{}".format(key,stats[key])InstallationTo use the software, in the root directory, runpipinstall-e.To develop the code, runpipinstall-e.[dev]To install this package from PyPI, runpipinstallaind-segmentation-evaluationPull requestsFor internal members, please create a branch. For external members, please fork the repository and open a pull request from the fork. We'll primarily useAngularstyle for commit messages. Roughly, they should follow the pattern:<type>(<scope>): <short summary>where scope (optional) describes the packages affected by the code changes and type (mandatory) is one of:build: Changes that affect build tools or external dependencies (example scopes: pyproject.toml, setup.py)ci: Changes to our CI configuration files and scripts (examples: .github/workflows/ci.yml)docs: Documentation only changesfeat: A new featurefix: A bugfixperf: A code change that improves performancerefactor: A code change that neither fixes a bug nor adds a featuretest: Adding missing tests or correcting existing tests
Package: segmenteverygrain
segmenteverygrainDescription'segmenteverygrain' is a Python package that aims to detect grains (or grain-like objects) in images. The goal is to develop an ML model that does a reasonably good job at detecting most of the grains in a photo, so that it will be useful for determining grain size and grain shape, a common task in geomorphology and sedimentary geology. 'segmenteverygrain' relies on theSegment Anything Model (SAM), developed by Meta, for getting high-quality outlines of the grains. However, SAM requires prompts for every object detected and, when used in 'everything' mode, it tends to be slow and results in many overlapping masks and non-grain (background) objects. To deal with these issues, 'segmenteverygrain' relies on a Unet-style, patch-based convolutional neural network to create a first-pass segmentation which is then used as a set of prompts for the SAM-based segmentation. Some of the grains will be missed with this approach, but the segmentations that are created tend to be of high quality.'segmenteverygrain' also includes a set of functions that make it possible to clean up the segmentation results: delete and merge objects by clicking on them, and adding grains that were not segmented automatically. The QC-d masks can be saved and added to a dataset of grain images (see the 'images' folder). These images then can be used to improve the Unet model. Many of the images used in the dataset are from thesedinetproject.This iswork in progress.Requirementsnumpymatplotlibscipypandaspillowscikit-imageopencv-pythonnetworkxrasterioshapelytensorflowpytorchsegment-anythingtqdmInstallationpip install segmenteverygrainGetting startedSee theSegment_every_grain.ipynbnotebook for an example of how the models can be loaded and used for segmenting an image and QC-ing the result.TheTrain_seg_unet_model.ipynbnotebook goes through the steps needed to create, train, and test the Unet model.TheSegment_every_grain_colab.ipynbhas been adjusted so that the segmentation can be tested in Google Colab. That said, the interactivity in Colab is not as smooth as in a local notebook.AcknowledgementsThanks to Danny Stockli, Nick Howes, Jake Covault, Matt Malkowski, Raymond Luong, and Sergey Fomel for discussions and/or helping with generating training data. Funding for this work came from theQuantitative Clastics Laboratory industrial consortiumat the Bureau of Economic Geology, The University of Texas at Austin.Licensesegmenteverygrain is licensed under theApache License 2.0.
Package: segment-image
segment_imageAbstractA lib can be used to segment imagehttps://pypi.org/project/segment-image/The first version just has k_means algorithm.installpython >= 3.6install$ pip install segment-imagehow to usecv2need to be installed bypip install opencv-pythonKmeansimport segment_image
import cv2

img = cv2.imread("./sample_imgs/lena.png")
k = 2 # number of segments
k_means = segment_image.Kmeans(img, k)
iteration = 10
convergence_radius = 1e-6
k_means.run(iteration, convergence_radius)gvf_snake (The speed is so slow, so I use smallmax_iteration_gvfandmax_iteration_gvf. if you want to get great results, pleas adjust them)import segment_image
import cv2

img = cv2.imread("./sample_imgs/star.png")
max_iteration_gvf = 10
max_iteration_snake = 10
gvf_snake = segment_image.GVFSnake(img, max_iteration_gvf, max_iteration_snake)
gvf_snake.run(save=True)examplehttps://github.com/MyDuan/segment_image/blob/main/examples/example_of_kmeans.pyhttps://github.com/MyDuan/segment_image/blob/main/examples/example_of_gvf_snake.pyresults:kmeans:gvf_snake
Package: segmentio
Segment is the simplest way to integrate segmentio into your application.
One API allows you to turn on any other segmentio service. No more learning
new APIs, repeated code, and wasted development time.This is a copy of the official library that renames the analytics module
segmentio.This client wraps the the Segment REST API (https://segment.com).Documentation and more details athttps://github.com/jamiemccrindle/segmentioandhttps://github.com/segmentio/analytics-python
Package: segments
segmentsThe segments package provides Unicode Standard tokenization routines and orthography segmentation,
implementing the linear algorithm described in the orthography profile specification fromThe Unicode Cookbook(Moran and Cysouw 2018).Command line usageCreate a text file:$ echo "aäaaöaaüaa" > text.txtNow look at the profile:$ cat text.txt | segments profile
Grapheme        frequency       mapping
a       7       a
ä       1       ä
ü       1       ü
ö       1       öWrite the profile to a file:$ cat text.txt | segments profile > profile.prfEdit the profile:$ more profile.prf
Grapheme        frequency       mapping
aa      0       x
a       7       a
ä       1       ä
ü       1       ü
ö       1       öNow tokenize the text without profile:$ cat text.txt | segments tokenize
a ä a a ö a a ü a aAnd with profile:$ cat text.txt | segments --profile=profile.prf tokenize
a ä aa ö aa ü aa

$ cat text.txt | segments --mapping=mapping --profile=profile.prf tokenize
a ä x ö x ü xAPI>>>fromsegmentsimportProfile,Tokenizer>>>t=Tokenizer()>>>t('abcd')'a b c d'>>>prf=Profile({'Grapheme':'ab','mapping':'x'},{'Grapheme':'cd','mapping':'y'})>>>print(prf)Graphememappingabxcdy>>>t=Tokenizer(profile=prf)>>>t('abcd')'ab cd'>>>t('abcd',column='mapping')'x y'
Package: segment-studio
AboutSegment Studio is an application that allows users to send in batches of image files that will be automatically be segmented and return the masks for each image, from here the user is able to label the data, edit/clean up the masks and such. After the image processing in complete the user can extract the masks to use for the creation of their desired ML models.InstallationMake sure you have upgraded version of pipLinux/MAC OSpython3 -m pip install --upgrade pipInstall using pippip install segment-studioOpen Python in terminalpython3Run the Editorfrom segment_studio import segment_studio
Package: segment-torch
UNET SEGMENTATION PYTORCHInstallationpipinstallsegment-torchUsagefromsegment_torch.unetimportUNetfromtorchimportnndevice="cuda"config=dict(in_channels=3,out_channels=1,hiddens=[4,8,16,32],dropouts=[0,0.15,0.15,0.15],# hiddensmaxpools=2,# hiddens - 1kernel_sizes=3,# 2*hiddens + 3*hiddens + 2paddings='same',# 2*hiddens + 3*hiddens + 2strides=1,# 2*hiddens + 3*hiddensdilation=1,criterion=nn.BCELoss(),output_activation=nn.Sigmoid(),activation=nn.ReLU(),dimensions=2,device=device)unet=UNet(**config)Different ways to define configs# 0. None: default values are usedkernel_sizes=None# 1. Single value or tuple: all layers have the same valuekernel_sizes=3kernel_sizes=(3,3)# 2. Lists of valuesencooder_kernel_sizes=[3,3,3,3]decoder_kernel_sizes=[3,3,3,3,3]kernel_sizes=[encooder_kernel_sizes,decoder_kernel_sizes]
Package: segment-tree
Segment Tree with range operationsThis is a general implementation of a segment tree for Python 3.Semigroup range operations in O(logN) timeBuilt-in support formax,min,sumoperationsExtensible to support more semigroup operationsLimited support for multidimensional treesPython 2 is not currently supportedInstallationpip3 installsegment-treeSegment Tree (one-dimensional)Basic usagefromsegment_treeimport*array=[3,1,5,3,13,7,2,7,2]tree=SegmentTree(array)t.query(1,3,"sum")# 9t.update(0,10)# [10, 1, 5, 3, 13, 7, 2, 7, 2]t.query(0,8,"min")# 0t.update(2,-1)# [10, 1, -1, 3, 13, 7, 2, 0, 2]t.query(0,2,"min")# -1Updates on rangesfromsegment_treeimport*array=[1,2,3,4,5]t=SegmentTree(array)t.update_range(0,2,6)# 6 6 6 4 5t.update_range(1,4,2)# 6 2 2 2 2t.query(0,3,"min")# 2Multidimensional Segment Tree (alpha version, might have bugs)Basic usagefromsegment_treeimport*a=[[[1,2],[1,3]],[[-1,-2],[-1,-3]]]tree=MultidimensionalSegmentTree(a)tree.query([(0,1),(0,0),(0,0)],max)# 1tree.query([(1,1),(0,1),(0,1)],sum)# -7tree.query([(0,1),(1,1),(0,1)],min)# -3TestsExecutepython3 setup.py testto run tests.
Package: segmenttreenode
segmenttreenode-------------------------------------------------------------------link: https://pypi.python.org/pypi/segmenttreenodeData structure for Segment Tree.-------------------------------------------------------------------Install:Use 'pip' or 'easy_install' to install the package.sudo pip install segmenttreenodesudo easy_install segmenttreenode-------------------------------------------------------------------Usage:In Python File:from segmenttreenode import SegmentTreeNodearr = [1, 3, 5, 7, 9, 11]root = SegmentTreeNode.SegmentTreeNode(arr, 0, len(arr) - 1)# Use this segment tree through the root.# ... ...-------------------------------------------------------------------Explanation:There are three necessary arguments toinitialize a segment tree node instance from SegmetTreeNode class.[1] one dimensional list[2] start index[3] end index
Package: segnn-jax
Steerable E(3) GNN in jaxReimplementation ofSEGNNin jax. Original work by Johannes Brandstetter, Rob Hesselink, Elise van der Pol, Erik Bekkers and Max Welling.Why jax?40-50% fasterinference and training compared to theoriginal torch implementation. Also JAX-MD.Installationpython -m pip install segnn-jaxOr clone this repository and build locallypython -m pip install -e .GPU supportUpgradejaxto the gpu versionpip install --upgrade "jax[cuda]>=0.4.6" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.htmlValidationN-body (charged and gravity) and QM9 datasets are included for completeness from the original paper.ResultsCharged is on 5 bodies, gravity on 100 bodies. QM9 has graphs of variable sizes, so in jax samples are padded to the maximum size. Loss is MSE for Charged and Gravity and MAE for QM9.Times are remeasured on Quadro RTX 4000,model onlyon batches of 100 graphs, in (global) single precision.torch (original)jax (ours)LossInference [ms]LossInference [ms]charged (position).004321.22.00453.77gravity (position).26560.55.26441.72QM9 (alpha).066*82.53.082105.98*** rerun on same conditions** padded (naive)Validation installThe experiments are only included in the github repo, so it needs to be cloned first.git clone https://github.com/gerkone/segnn-jaxThey are adapted from the original implementation, so additionallytorchandtorch_geometricare needed (cpu versions are enough).python -m pip install -r experiments/requirements.txtDatasetsQM9 is automatically downloaded and processed when running the respective experiment.The N-body datasets have to be generated locally from the directoryexperiments/nbody/data(it will take some time, especially n-bodygravity)Charged dataset (5 bodies, 10000 training samples)python3 -u generate_dataset.py --simulation=charged --seed=43Gravity dataset (100 bodies, 10000 training samples)python3 -u generate_dataset.py --simulation=gravity --n-balls=100 --seed=43NotesOnjax<=0.4.6, thejit-pjitmerge can be deactivated making traning faster (on nbody). This looks like an issue with dataloading and the validation training loop implementation and it does not affect SEGNN.export JAX_JIT_PJIT_API_MERGE=0UsageN-body (charged)python validate.py --dataset=charged --epochs=200 --max-samples=3000 --lmax-hidden=1 --lmax-attributes=1 --layers=4 --units=64 --norm=none --batch-size=100 --lr=5e-3 --weight-decay=1e-12N-body (gravity)python validate.py --dataset=gravity --epochs=100 --target=pos --max-samples=10000 --lmax-hidden=1 --lmax-attributes=1 --layers=4 --units=64 --norm=none --batch-size=100 --lr=5e-3 --weight-decay=1e-12 --neighbours=5 --n-bodies=100QM9python validate.py --dataset=qm9 --epochs=1000 --target=alpha --lmax-hidden=2 --lmax-attributes=3 --layers=7 --units=128 --norm=instance --batch-size=128 --lr=5e-4 --weight-decay=1e-8 --lr-scheduling(configurations used in validation)Acknowledgmentse3nn_jaxmade this reimplementation possible.Artur ToshevandJohannes Brandsetter, for support.
Package: segno-pil
Segno PIL – Segno plugin for creating PIL/Pillow images from QR CodesThisSegnoplugin converts a
(Micro) QR Code to a PIL/Pillow Image.This plugin is not required to write PNG, EPS or PDF files. Segno’s native
implementations usually generate smaller files in less time. This plugin
might be useful to modify the QR Codes (i.e. rotate or blur) or to save the
QR codes in an image format which is not supported by Segno.Usage:>>>importsegno>>>qr=segno.make("One, two, three, four, one, two""Let me tell you how it will be""There's one for you, nineteen for me")>>>img=qr.to_pil()# Greyscale image, default scale>>>img.save('example.png')>>>qr.to_pil(scale=10).show()# Show img with scale 10>>># Different scale>>>img=qr.to_pil(scale=3)>>>img.save('example-2.png')>>># Different scale and change module color>>>img=qr.to_pil(scale=3,dark='darkblue')>>>img.save('example-3.png')>>># Different scale and change dark and light module colors>>>img=qr.to_pil(scale=3,dark='#36c',light=None)>>>img.save('example-4.png')>>># Invert the example above>>>img=qr.to_pil(scale=3,dark=None,light='#36c')>>>img.save('example-5.png')>>># Save JPEG>>>qr.to_pil(scale=3,dark='#36c',light='yellow').convert('RGB').save('example-6.jpg')>>>rotated_img=img.rotate(3,expand=True)>>>rotated_img.convert('RGB').save('example-7.jpg')>>># Multiple module colors>>>qr=segno.make('Yellow Submarine',version=7,error='h')>>>img=qr.to_pil(scale=4,dark='darkred',data_dark='darkorange',data_light='yellow')>>>img.save('yellow-submarine.png')Changes1.0.0 – 2020-08-07Support for multiple module colorsSupport for Segno’s API >= 1.0.0API breaking changes:Changed parameter “color” to “dark” and “background” to “light”
to match Segno’s APIRemoved “mode” parameter0.1.6 – 2016-09-19Fixed Python packaging0.1.5 – 2016-08-24Adapt Segno’s 0.1.6 API changes.0.1.4 – 2016-08-16Updated docs0.1.3 – 2016-08-14Initial release
Package: segno-quark
Segno Quark: Plugin for creating more advanced (or less usefull) QR Code SVG documentsThis (experimental)Segnoplugin changes the default SVG output in
different ways (i.e. applying SVG filters).Tested under PyPy, Python 2.7 and Python 3.4. Unlike Segno itself, this
package does not work with Python 2.6.InstallationUsepipto install this quark from PyPI:$ pip install segno-quarkUsageOnce installed, the quark is automatically detected asSegnoplugin and
therefore available viaqrcode.to_XXX(...).Available convertersAll converters use the same keyword parameters as Segno’s SVG serializer,
seesegno.QRCode.save()for details.ETreeCreates a SVG QR Code and returns the SVG document asxml.etree.ElementTree.Usage:to_etreeThis converter provides no additional keyword arguments.PacmanCreates a QR Code with a smiley (and optional ghosts).Usage:to_pacmanKeywordDescriptionpacman_colorColor of the smiley, default:#fc0dot_colorColor of the dots which the smiley should eat, default:#fc0ghostsNumber of ghosts, default:5. If set to0, no ghost
appears. Note: Setting this to a very high value may cause
an infinite loop iff number of ghosts > number of available
dark modules. Additionally, the QR Code may not be readable
by common QR Code decoders.
The positions of the ghosts are choosen at random.ghost_colorsA tuple of colors which the ghosts may get. Default:('#ff0c13','#f2aeaf', '#1bb1e6', '#f97e16')Not all colors may be used, the colors for the ghosts are
choosen at random.Example:>>>importsegno>>>qr=segno.make_qr('Ob-La-Di, Ob-La-Da')>>>qr.to_pacman('obladioblada.svg',scale=10,ghosts=7)Result:GlowCreates a QR Code with a “glow” effect.Usage:to_glowKeywordDescriptionfilter_idIndicates the id of the filter, default:segno-glowdeviationIndicates the standard deviation for the blur operation,
default:.6Example:>>>importsegno>>>qr=segno.make_qr('Ob-La-Di, Ob-La-Da')>>>qr.to_glow('obladioblada.svg',scale=10,color='darkblue')Result:BlurCreates a QR Code with a “blur” effect.Usage:to_blurKeywordDescriptionfilter_idIndicates the id of the filter, default:segno-blurdeviationIndicates the standard deviation for the blur operation,
default:.3Example:>>>importsegno>>>qr=segno.make_qr('Ob-La-Di, Ob-La-Da')>>>qr.to_blur('obladioblada.svg',scale=10,color='darkred')Result:Changes0.1.1 – 2016-08-18Initial release