Spaces:
Paused
Paused
Update app.py
Browse files
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 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|