-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update llama file * test spirit-lm * add gradio ui * choose vision server * progres- sarvam1 * update -steps --------- Co-authored-by: sachin <>
- Loading branch information
1 parent
8a53f6c
commit 64c1ff9
Showing
7 changed files
with
6,884 additions
and
6,871 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from PIL import Image | ||
import base64 | ||
import io | ||
from ollama import Client | ||
def image_to_base64(image_path): | ||
# Open the image file | ||
with Image.open(image_path) as img: | ||
# Create a BytesIO object to hold the image data | ||
buffered = io.BytesIO() | ||
# Save the image to the BytesIO object in a specific format (e.g., PNG) | ||
img.save(buffered, format="PNG") | ||
# Get the byte data from the BytesIO object | ||
img_bytes = buffered.getvalue() | ||
# Encode the byte data to base64 | ||
img_base64 = base64.b64encode(img_bytes).decode('utf-8') | ||
return img_base64 | ||
|
||
|
||
def test_code(): | ||
image_path = '/home/gaganyatri/Downloads/books-rec-1.jpeg' # Replace with your image path | ||
base64_image = image_to_base64(image_path) | ||
client = Client(host='http://localhost:21434') | ||
response = client.chat( | ||
model="x/llama3.2-vision:latest", | ||
messages=[{ | ||
"role": "user", | ||
"content": "Describe this image?", | ||
"images": [base64_image] | ||
}], | ||
) | ||
|
||
# Extract the model's response about the image | ||
cleaned_text = response['message']['content'].strip() | ||
print(f"Model Response: {cleaned_text}") | ||
# Example usage | ||
|
||
test_code() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
anyio==4.6.2.post1 | ||
certifi==2024.8.30 | ||
exceptiongroup==1.2.2 | ||
h11==0.14.0 | ||
httpcore==1.0.6 | ||
httpx==0.27.2 | ||
idna==3.10 | ||
ollama==0.3.3 | ||
pillow==11.0.0 | ||
sniffio==1.3.1 | ||
typing_extensions==4.12.2 |
Oops, something went wrong.