Spaces:
Running
on
Zero
Running
on
Zero
bug fix
Browse files
app.py
CHANGED
|
@@ -19,6 +19,7 @@ from diffusers.utils import load_image
|
|
| 19 |
from gradio_imageslider import ImageSlider
|
| 20 |
import boto3
|
| 21 |
from io import BytesIO
|
|
|
|
| 22 |
|
| 23 |
device = "cuda"
|
| 24 |
base_model_id = "SG161222/RealVisXL_V4.0"
|
|
@@ -84,8 +85,8 @@ def get_depth_map(image):
|
|
| 84 |
return image
|
| 85 |
|
| 86 |
|
| 87 |
-
def
|
| 88 |
-
|
| 89 |
connectionUrl = f"https://{account_id}.r2.cloudflarestorage.com"
|
| 90 |
|
| 91 |
s3 = boto3.client(
|
|
@@ -95,7 +96,9 @@ def upload_to_s3(image, account_id, access_key, secret_key, bucket_name):
|
|
| 95 |
aws_access_key_id=access_key,
|
| 96 |
aws_secret_access_key=secret_key
|
| 97 |
)
|
| 98 |
-
|
|
|
|
|
|
|
| 99 |
buffer = BytesIO()
|
| 100 |
image.save(buffer, "PNG")
|
| 101 |
buffer.seek(0)
|
|
@@ -131,7 +134,7 @@ def process(image, image_url, prompt, n_prompt, num_steps, guidance_scale, contr
|
|
| 131 |
).images[0]
|
| 132 |
|
| 133 |
if upload_to_s3:
|
| 134 |
-
url =
|
| 135 |
result = {"status": "success", "url": url}
|
| 136 |
else:
|
| 137 |
result = {"status": "success", "message": "Image generated but not uploaded"}
|
|
|
|
| 19 |
from gradio_imageslider import ImageSlider
|
| 20 |
import boto3
|
| 21 |
from io import BytesIO
|
| 22 |
+
from datetime import datetime
|
| 23 |
|
| 24 |
device = "cuda"
|
| 25 |
base_model_id = "SG161222/RealVisXL_V4.0"
|
|
|
|
| 85 |
return image
|
| 86 |
|
| 87 |
|
| 88 |
+
def upload_image_to_s3(image, account_id, access_key, secret_key, bucket_name):
|
| 89 |
+
print("upload_image_to_s3", account_id, access_key, secret_key, bucket_name)
|
| 90 |
connectionUrl = f"https://{account_id}.r2.cloudflarestorage.com"
|
| 91 |
|
| 92 |
s3 = boto3.client(
|
|
|
|
| 96 |
aws_access_key_id=access_key,
|
| 97 |
aws_secret_access_key=secret_key
|
| 98 |
)
|
| 99 |
+
|
| 100 |
+
current_time = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 101 |
+
image_file = f"generated_images/{current_time}_{random.randint(0, MAX_SEED)}.png"
|
| 102 |
buffer = BytesIO()
|
| 103 |
image.save(buffer, "PNG")
|
| 104 |
buffer.seek(0)
|
|
|
|
| 134 |
).images[0]
|
| 135 |
|
| 136 |
if upload_to_s3:
|
| 137 |
+
url = upload_image_to_s3(generated_image, account_id, access_key, secret_key, bucket)
|
| 138 |
result = {"status": "success", "url": url}
|
| 139 |
else:
|
| 140 |
result = {"status": "success", "message": "Image generated but not uploaded"}
|