a python package for loading images
Project description
loadimg
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
- thanks to @KingNish24 for improving base64 support and adding the
input_typeparameter - thanks to @Saptarshi-Bandopadhyay for supporting base64 and improving the docstrings
- thanks to @Abbhiishek for improving image naming
Project details
Release history Release notifications | RSS feed
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.4.0.tar.gz
(11.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
loadimg-0.4.0-py3-none-any.whl
(10.1 kB
view details)
File details
Details for the file loadimg-0.4.0.tar.gz.
File metadata
- Download URL: loadimg-0.4.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c648e0ceb2cbd86a8465f5491ada4bd8f7125e0ce53bf7e0608490a3b9a55f2f
|
|
| MD5 |
df49af3afbd7c78fd044ce67322f0c49
|
|
| BLAKE2b-256 |
bd1b280f3b64eaf275a6101faea7e6be1dc5f9e4e49b4aa2bdab4450caa11fe0
|
File details
Details for the file loadimg-0.4.0-py3-none-any.whl.
File metadata
- Download URL: loadimg-0.4.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
382a7ad839d52a9d017d8ebed4c1ff57fcc8935cdb47e4bcf6c1b6800d32d0d6
|
|
| MD5 |
2e736a1daa369f609572b4cfe01eaeba
|
|
| BLAKE2b-256 |
f9165234c5a02c4decbf273c61159cd2d41d26f87f82d0001b62824047595aec
|