Sean Laurent commited on
Commit ·
be76e4a
1
Parent(s): be94e9d
Removed s3 code
Browse files
app.py
CHANGED
|
@@ -4,21 +4,21 @@ from io import BytesIO
|
|
| 4 |
from PIL import Image
|
| 5 |
import gradio as gr
|
| 6 |
import os
|
| 7 |
-
import boto3
|
| 8 |
|
| 9 |
model_key = os.environ.get("model_key")
|
| 10 |
api_key = os.environ.get("api_key")
|
| 11 |
-
aws_access_key_id = os.environ.get("aws_access_key_id")
|
| 12 |
-
aws_secret_access_key = os.environ.get("aws_secret_access_key")
|
| 13 |
|
| 14 |
# Create a session using AWS credentials
|
| 15 |
-
session = boto3.Session(aws_access_key_id, aws_secret_access_key)
|
| 16 |
|
| 17 |
# Create an S3 resource object using the session
|
| 18 |
-
s3 = session.resource('s3')
|
| 19 |
|
| 20 |
# Select your bucket
|
| 21 |
-
bucket = s3.Bucket('bwlmonet')
|
| 22 |
|
| 23 |
model_inputs = {
|
| 24 |
"endpoint": "txt2img",
|
|
@@ -37,8 +37,8 @@ model_inputs = {
|
|
| 37 |
}
|
| 38 |
}
|
| 39 |
|
| 40 |
-
for obj in bucket.objects.all():
|
| 41 |
-
|
| 42 |
|
| 43 |
def stable_diffusion_txt2img(prompt, api_key, model_key, model_inputs):
|
| 44 |
# Update the model_inputs with the provided prompt
|
|
@@ -54,13 +54,13 @@ def stable_diffusion_txt2img(prompt, api_key, model_key, model_inputs):
|
|
| 54 |
image = Image.open(image_bytes)
|
| 55 |
|
| 56 |
# Save image to S3
|
| 57 |
-
key = f"{prompt}.png"
|
| 58 |
-
image.save(key)
|
| 59 |
-
with open(key, "rb") as data:
|
| 60 |
-
|
| 61 |
|
| 62 |
-
for obj in bucket.objects.all():
|
| 63 |
-
|
| 64 |
|
| 65 |
return image
|
| 66 |
|
|
|
|
| 4 |
from PIL import Image
|
| 5 |
import gradio as gr
|
| 6 |
import os
|
| 7 |
+
# import boto3
|
| 8 |
|
| 9 |
model_key = os.environ.get("model_key")
|
| 10 |
api_key = os.environ.get("api_key")
|
| 11 |
+
# aws_access_key_id = os.environ.get("aws_access_key_id")
|
| 12 |
+
# aws_secret_access_key = os.environ.get("aws_secret_access_key")
|
| 13 |
|
| 14 |
# Create a session using AWS credentials
|
| 15 |
+
# session = boto3.Session(aws_access_key_id, aws_secret_access_key)
|
| 16 |
|
| 17 |
# Create an S3 resource object using the session
|
| 18 |
+
# s3 = session.resource('s3')
|
| 19 |
|
| 20 |
# Select your bucket
|
| 21 |
+
# bucket = s3.Bucket('bwlmonet')
|
| 22 |
|
| 23 |
model_inputs = {
|
| 24 |
"endpoint": "txt2img",
|
|
|
|
| 37 |
}
|
| 38 |
}
|
| 39 |
|
| 40 |
+
# for obj in bucket.objects.all():
|
| 41 |
+
# print(obj.key)
|
| 42 |
|
| 43 |
def stable_diffusion_txt2img(prompt, api_key, model_key, model_inputs):
|
| 44 |
# Update the model_inputs with the provided prompt
|
|
|
|
| 54 |
image = Image.open(image_bytes)
|
| 55 |
|
| 56 |
# Save image to S3
|
| 57 |
+
# key = f"{prompt}.png"
|
| 58 |
+
# image.save(key)
|
| 59 |
+
# with open(key, "rb") as data:
|
| 60 |
+
# bucket.put_object(Key=key, Body=data)
|
| 61 |
|
| 62 |
+
# for obj in bucket.objects.all():
|
| 63 |
+
# print(obj.key)
|
| 64 |
|
| 65 |
return image
|
| 66 |
|