Commit
·
e9f0715
1
Parent(s):
45798af
third time is the charm
Browse files
app.py
CHANGED
|
@@ -22,15 +22,15 @@ def text2image_latent(text,steps,width,height,images,diversity):
|
|
| 22 |
image_str = image_str.replace("data:image/png;base64,","")
|
| 23 |
decoded_bytes = base64.decodebytes(bytes(image_str, "utf-8"))
|
| 24 |
img = Image.open(io.BytesIO(decoded_bytes))
|
| 25 |
-
image_arrays.append(img)
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
return(results[0],
|
| 34 |
|
| 35 |
def text2image_rudalle(text,aspect,model):
|
| 36 |
image = rudalle(text,aspect,model)[0]
|
|
|
|
| 22 |
image_str = image_str.replace("data:image/png;base64,","")
|
| 23 |
decoded_bytes = base64.decodebytes(bytes(image_str, "utf-8"))
|
| 24 |
img = Image.open(io.BytesIO(decoded_bytes))
|
| 25 |
+
#image_arrays.append(numpy.asarray(img))
|
| 26 |
+
url = shortuuid.uuid()
|
| 27 |
+
temp_dir = './tmp'
|
| 28 |
+
if not os.path.exists(temp_dir):
|
| 29 |
+
os.makedirs(temp_dir, exist_ok=True)
|
| 30 |
+
image_path = f'{temp_dir}/{url}.png'
|
| 31 |
+
img.save(f'{temp_dir}/{url}.png')
|
| 32 |
+
image_paths.append(image_path)
|
| 33 |
+
return(results[0],image_paths)
|
| 34 |
|
| 35 |
def text2image_rudalle(text,aspect,model):
|
| 36 |
image = rudalle(text,aspect,model)[0]
|