SAUL19 commited on
Commit
384d32a
·
1 Parent(s): c249291

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -19,14 +19,14 @@ pipe = StableDiffusionPipeline.from_pretrained(
19
 
20
  pipe = pipe.to(device)
21
 
22
- def text_to_image(summary, image_name):
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(image_name.split()) + ".webp"
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(summary):
44
- prompt = summary
45
  image = pipe(prompt).images[0]
46
 
47
  # Save the image in S3
48
  save_image_to_s3(image)
49
 
50
- generator_image(summary)
51
  return image_name
52
 
53
 
54
 
55
- iface = gr.Interface(fn=text_to_image, inputs=[Textbox(label="Summary"), Textbox(label="Image Name")], outputs="text")
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()