Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -19,14 +19,14 @@ pipe = StableDiffusionPipeline.from_pretrained(
|
|
19 |
|
20 |
pipe = pipe.to(device)
|
21 |
|
22 |
-
def text_to_image(
|
23 |
|
24 |
# Create an instance of the S3 client
|
25 |
s3 = boto3.client('s3',
|
26 |
aws_access_key_id=AWS_ACCESS_KEY_ID,
|
27 |
aws_secret_access_key=AWS_SECRET_ACCESS_KEY)
|
28 |
|
29 |
-
image_name = '-'.join(
|
30 |
|
31 |
def save_image_to_s3(image):
|
32 |
# Create a BytesIO object to store the image.
|
@@ -40,17 +40,17 @@ def text_to_image(summary, image_name):
|
|
40 |
# Upload the image to the S3 bucket
|
41 |
s3.upload_fileobj(image_buffer, S3_BUCKET_NAME, s3_key)
|
42 |
|
43 |
-
def generator_image(
|
44 |
-
prompt =
|
45 |
image = pipe(prompt).images[0]
|
46 |
|
47 |
# Save the image in S3
|
48 |
save_image_to_s3(image)
|
49 |
|
50 |
-
generator_image(
|
51 |
return image_name
|
52 |
|
53 |
|
54 |
|
55 |
-
iface = gr.Interface(fn=text_to_image, inputs=[Textbox(label="
|
56 |
iface.launch()
|
|
|
19 |
|
20 |
pipe = pipe.to(device)
|
21 |
|
22 |
+
def text_to_image(prompt, save_as):
|
23 |
|
24 |
# Create an instance of the S3 client
|
25 |
s3 = boto3.client('s3',
|
26 |
aws_access_key_id=AWS_ACCESS_KEY_ID,
|
27 |
aws_secret_access_key=AWS_SECRET_ACCESS_KEY)
|
28 |
|
29 |
+
image_name = '-'.join(save_as.split()) + ".webp"
|
30 |
|
31 |
def save_image_to_s3(image):
|
32 |
# Create a BytesIO object to store the image.
|
|
|
40 |
# Upload the image to the S3 bucket
|
41 |
s3.upload_fileobj(image_buffer, S3_BUCKET_NAME, s3_key)
|
42 |
|
43 |
+
def generator_image(prompt):
|
44 |
+
prompt = prompt
|
45 |
image = pipe(prompt).images[0]
|
46 |
|
47 |
# Save the image in S3
|
48 |
save_image_to_s3(image)
|
49 |
|
50 |
+
generator_image(prompt)
|
51 |
return image_name
|
52 |
|
53 |
|
54 |
|
55 |
+
iface = gr.Interface(fn=text_to_image, inputs=[Textbox(label="prompt"), Textbox(label="save_as")], outputs="text")
|
56 |
iface.launch()
|