Skip to content

Commit

Permalink
Merge pull request #19 from not-lain/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
not-lain authored Jan 17, 2025
2 parents 9094bf9 + 9bad0cd commit a975fb3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Downloads](https://static.pepy.tech/badge/loadimg)](https://pepy.tech/project/loadimg)

A python package for loading images
A python package for loading and converting images

## How to use
Installation
Expand All @@ -18,7 +18,52 @@ Supported types
- Currently supported input types - numpy, pillow, str(both path and url), base64, **auto**
- Currently supported output types - numpy, pillow, str, base64

![loadimg](https://github.com/not-lain/loadimg/blob/main/loadimg.png?raw=true)

<p align="center">
<img src="https://github.com/not-lain/loadimg/blob/main/loadimg.png?raw=true">
</p>


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

```python
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

Expand Down
2 changes: 1 addition & 1 deletion src/loadimg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .utils import load_img # noqa: F401

__version__ = "0.3.5"
__version__ = "0.3.6"

0 comments on commit a975fb3

Please sign in to comment.