Skip to main content

a python package for loading images

Project description

loadimg

Downloads

A python package for loading and converting images

How to use

Installation

pip install loadimg

Usage

from loadimg import load_img
load_img(any_img_type_here,output_type="pil",input_type="auto") 

Supported types

  • Currently supported input types - numpy, pillow, str(both path and url), base64, auto
  • Currently supported output types - numpy, pillow, str, base64

The base64 is now compatible with most APIs, now supporting Hugging Face, OpenAI and FAL

from loadimg import load_img
from huggingface_hub import InferenceClient

# or load a local image
my_b64_img = load_img("https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg", output_type="base64" ) 

client = InferenceClient(api_key="hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

messages = [
	{
		"role": "user",
		"content": [
			{
				"type": "text",
				"text": "Describe this image in one sentence."
			},
			{
				"type": "image_url",
				"image_url": {
					"url": my_b64_img # base64 allows using images without uploading them to the web
				}
			}
		]
	}
]

stream = client.chat.completions.create(
    model="meta-llama/Llama-3.2-11B-Vision-Instruct", 
	messages=messages, 
	max_tokens=500,
	stream=True
)

for chunk in stream:
    print(chunk.choices[0].delta.content, end="")

Contributions

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

loadimg-0.3.6.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

loadimg-0.3.6-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file loadimg-0.3.6.tar.gz.

File metadata

  • Download URL: loadimg-0.3.6.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for loadimg-0.3.6.tar.gz
Algorithm Hash digest
SHA256 5054752a6905f3225a76b08d886860f342129b9caec4d1dc8e2435426d50deb2
MD5 7368ce959ae13339cd1a964dac6df7f6
BLAKE2b-256 4adad7f338b1f0e3b4bc090df08f34f4ac6b162efe6a13fc9eebff8acc3d1bdd

See more details on using hashes here.

File details

Details for the file loadimg-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: loadimg-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for loadimg-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bc1ef94855810456cec31572c2c82e7954cf41bac98ac43e4c78940d8ae81e5b
MD5 31369a4af60003daa71026adc532ae30
BLAKE2b-256 1b95f280d41e1cde334d1d44331e3fee19ed785fc03ddf7e6a17069e30c92ae4

See more details on using hashes here.

Supported by

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