Geraldine commited on
Commit
5e2a1a2
·
verified ·
1 Parent(s): 9341f28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -39,11 +39,14 @@ def generate_embeddings(text):
39
  embeddings = model.encode(sentences)
40
  return embeddings
41
 
42
- def describe_image(image):
43
- # Convert the image to the format expected by the model
44
- image_path = array_to_image_path(image)
45
- with open(image_path, "rb") as f:
46
- image = base64.b64encode(f.read()).decode("utf-8")
 
 
 
47
 
48
  messages = [
49
  {
 
39
  embeddings = model.encode(sentences)
40
  return embeddings
41
 
42
+ def describe_image(image_array):
43
+ if image_array is None:
44
+ raise ValueError("No image provided. Please upload an image before submitting.")
45
+ # Convert numpy array to PIL Image
46
+ image = Image.fromarray(np.uint8(image_array))
47
+ buffered = io.BytesIO()
48
+ image.save(buffered, format="PNG") # Change format as needed
49
+ img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
50
 
51
  messages = [
52
  {