Michael Yang
commited on
Commit
•
87d41a6
1
Parent(s):
fcfdc97
base 64 conversion
Browse files- generation.py +8 -3
generation.py
CHANGED
@@ -10,6 +10,8 @@ from shared import model_dict, sam_model_dict, DEFAULT_SO_NEGATIVE_PROMPT, DEFAU
|
|
10 |
import gc
|
11 |
from io import BytesIO
|
12 |
import base64
|
|
|
|
|
13 |
|
14 |
verbose = False
|
15 |
|
@@ -212,9 +214,12 @@ def run(
|
|
212 |
gc.collect()
|
213 |
torch.cuda.empty_cache()
|
214 |
|
215 |
-
|
216 |
-
|
217 |
-
|
|
|
|
|
|
|
218 |
|
219 |
return images[0], so_img_list, img_str
|
220 |
|
|
|
10 |
import gc
|
11 |
from io import BytesIO
|
12 |
import base64
|
13 |
+
import pickle
|
14 |
+
import codecs
|
15 |
|
16 |
verbose = False
|
17 |
|
|
|
214 |
gc.collect()
|
215 |
torch.cuda.empty_cache()
|
216 |
|
217 |
+
obj = np.random.normal(size=(10, 10))
|
218 |
+
obj_base64string = codecs.encode(pickle.dumps(obj, protocol=pickle.HIGHEST_PROTOCOL), "base64").decode('latin1')
|
219 |
+
img_str = pickle.loads(codecs.decode(obj_base64string.encode('latin1'), "base64"))
|
220 |
+
# with BytesIO() as buffer:
|
221 |
+
# np.save(buffer, images[0])
|
222 |
+
# img_str = base64.b64encode(buffer.getvalue()).decode('utf-8')
|
223 |
|
224 |
return images[0], so_img_list, img_str
|
225 |
|