Askinkaty commited on
Commit
ad8ab33
·
verified ·
1 Parent(s): 9ca80ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -8,6 +8,9 @@ from tools.visit_webpage import VisitWebpageTool
8
  import os
9
  import IPython.display as display
10
 
 
 
 
11
 
12
  from Gradio_UI import GradioUI
13
 
@@ -28,7 +31,15 @@ def generate_and_show_surfer_image(next_tide: str) -> str:
28
  prompt = f"Generate a surfer {action}"
29
  try:
30
  image_result = image_generation_tool(prompt)
31
- return image_result
 
 
 
 
 
 
 
 
32
  except Exception as e:
33
  return f"Error generating image: {str(e)}"
34
 
 
8
  import os
9
  import IPython.display as display
10
 
11
+ import io
12
+ import base64
13
+ from PIL import Image # Only needed if 'image' is a PIL Image object
14
 
15
  from Gradio_UI import GradioUI
16
 
 
31
  prompt = f"Generate a surfer {action}"
32
  try:
33
  image_result = image_generation_tool(prompt)
34
+ # return image_result
35
+ # Save the image to a byte stream
36
+ image_byte_arr = io.BytesIO()
37
+ image.save(image_byte_arr, format='JPEG')
38
+ image_byte_arr = image_byte_arr.getvalue()
39
+ base64_image = base64.b64encode(image_byte_arr).decode('utf-8')
40
+ return f'<img src="data:image/jpeg;base64,{base64_image}"/>'
41
+
42
+
43
  except Exception as e:
44
  return f"Error generating image: {str(e)}"
45