vibs08 commited on
Commit
149bacf
·
verified ·
1 Parent(s): d79ae49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -15,6 +15,7 @@ import torch
15
  from PIL import Image
16
  from functools import partial
17
  import io
 
18
 
19
 
20
  subprocess.run(shlex.split('pip install wheel/torchmcubes-0.1.0-cp310-cp310-linux_x86_64.whl'))
@@ -94,9 +95,15 @@ def gen_pos_prompt(text):
94
  pos_prompt = json.loads(response.get('body').read())['results'][0]['outputText']
95
  return pos_prompt
96
 
97
- def encode_image_to_base64(image_path):
98
- with open(image_path, "rb") as image_file:
99
- encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
 
 
 
 
 
 
100
  return encoded_string
101
 
102
 
 
15
  from PIL import Image
16
  from functools import partial
17
  import io
18
+ from io import BytesIO
19
 
20
 
21
  subprocess.run(shlex.split('pip install wheel/torchmcubes-0.1.0-cp310-cp310-linux_x86_64.whl'))
 
95
  pos_prompt = json.loads(response.get('body').read())['results'][0]['outputText']
96
  return pos_prompt
97
 
98
+ # def encode_image_to_base64(image_path):
99
+ # with open(image_path, "rb") as image_file:
100
+ # encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
101
+ # return encoded_string
102
+
103
+ def encode_image_to_base64(image):
104
+ buffered = BytesIO()
105
+ image.save(buffered, format="PNG") # Save the image to the buffer
106
+ encoded_string = base64.b64encode(buffered.getvalue()).decode('utf-8')
107
  return encoded_string
108
 
109