Skip to content

Commit

Permalink
Fix an issue with image format
Browse files Browse the repository at this point in the history
  • Loading branch information
xl0 committed Jul 23, 2024
1 parent 203e927 commit ffec2af
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 4 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,45 @@ This is exactly the kind of image that would make for a fantastic
dataset in computer vision tasks. You could use it for all sorts of
things - cat breed classification, pose estimation, you name it.
Absolutely fascinating, isn’t it?”

## Looking at existing cells

``` python
from PIL import Image
Image.open("cat2.jpg")
```

![](index_files/figure-commonmark/cell-5-output-1.png)

``` python
# %%fr +1
# Describe the image
```

The image shows a cat sitting upright on what appears to be a
light-colored surface or floor. The cat has distinctive features typical
of an Abyssinian breed:

1. Slender, athletic build
2. Large, alert ears
3. Almond-shaped eyes
4. Reddish-brown or ruddy coat color
5. Ticked fur pattern, giving it a wild appearance

The cat is sitting in a poised, attentive posture with its tail wrapped
neatly around its body. Its gaze is directed off to the side, giving it
an alert and curious expression. The background appears to be a plain
white or light-colored wall, which contrasts nicely with the cat’s
warm-toned coat.

This image showcases the elegant and regal appearance that Abyssinian
cats are known for, highlighting their unique coat color and sleek
physique.

## Messing around

You might have noticed the `reply` added to the magic of the generated
cells. This is the only way FriendLLy distinguishes between user- and
assistant-generated cells (plus some heuristics for Markdown cells). You
can add such cells yourself, and FriendLLy will think they are
assistant-generated.
2 changes: 1 addition & 1 deletion friendlly/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.1.0"
__version__ = "0.1.1"

from .magic_cell import fr_cell
from .magic_line import fr_line
Expand Down
5 changes: 4 additions & 1 deletion friendlly/magic_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ def display_data_to_messages(dsp):

claudette_msgs = [text_msg(m) for m in messages]
if images:
claudette_msgs.append(img_msg(images[0])) # Grab only one image
image = images[0] # Grab only one image
if isinstance(image, str):
image = base64.b64decode(image)
claudette_msgs.append(img_msg(image))

return claudette_msgs

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion nbs/01_magic_cell.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@
"\n",
" claudette_msgs = [text_msg(m) for m in messages]\n",
" if images:\n",
" claudette_msgs.append(img_msg(images[0])) # Grab only one image\n",
" image = images[0] # Grab only one image\n",
" if isinstance(image, str):\n",
" image = base64.b64decode(image)\n",
" claudette_msgs.append(img_msg(image))\n",
"\n",
" return claudette_msgs\n",
"\n",
Expand Down
69 changes: 69 additions & 0 deletions nbs/index.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### Python library ###
repo = friendlly
lib_name = %(repo)s
version = 0.1.0
version = 0.1.1
min_python = 3.7
license = apache2
black_formatting = False
Expand Down

0 comments on commit ffec2af

Please sign in to comment.