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.3.6.tar.gz
(9.3 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
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5054752a6905f3225a76b08d886860f342129b9caec4d1dc8e2435426d50deb2
|
|
| MD5 |
7368ce959ae13339cd1a964dac6df7f6
|
|
| BLAKE2b-256 |
4adad7f338b1f0e3b4bc090df08f34f4ac6b162efe6a13fc9eebff8acc3d1bdd
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc1ef94855810456cec31572c2c82e7954cf41bac98ac43e4c78940d8ae81e5b
|
|
| MD5 |
31369a4af60003daa71026adc532ae30
|
|
| BLAKE2b-256 |
1b95f280d41e1cde334d1d44331e3fee19ed785fc03ddf7e6a17069e30c92ae4
|