Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -1,22 +1,7 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
from PIL import Image
|
| 3 |
import io
|
| 4 |
-
import pyperclip
|
| 5 |
|
| 6 |
-
def load_image(
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
return
|
| 10 |
-
|
| 11 |
-
def save_caption(caption):
|
| 12 |
-
# Function can be added here to save the caption to some database
|
| 13 |
-
print(f"Saved caption: {caption}")
|
| 14 |
-
|
| 15 |
-
def copy_to_clipboard(text):
|
| 16 |
-
pyperclip.copy(text)
|
| 17 |
-
st.success("Caption copied to clipboard!")
|
| 18 |
-
|
| 19 |
-
def get_image_file_buffer(image):
|
| 20 |
-
buf = io.BytesIO()
|
| 21 |
-
image.save(buf, format='PNG')
|
| 22 |
-
return buf.getvalue()
|
|
|
|
|
|
|
| 1 |
from PIL import Image
|
| 2 |
import io
|
|
|
|
| 3 |
|
| 4 |
+
def load_image(image_file):
|
| 5 |
+
"""Load an image file and return a PIL Image object."""
|
| 6 |
+
img = Image.open(image_file)
|
| 7 |
+
return img.convert("RGB")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|