Prashanthsrn commited on
Commit
becb527
·
verified ·
1 Parent(s): c5aa2e3

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +4 -19
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(uploaded_file):
7
- image_bytes = uploaded_file.read()
8
- image = Image.open(io.BytesIO(image_bytes))
9
- return image
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")