ms1449 commited on
Commit
7805a11
·
verified ·
1 Parent(s): 03b6378

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -4,6 +4,7 @@ from PIL import Image
4
  from io import BytesIO
5
  import base64
6
  import os
 
7
 
8
  API_KEY = os.getenv("NVIDIA_API_KEY")
9
  invoke_url = "https://ai.api.nvidia.com/v1/genai/stabilityai/sdxl-turbo"
@@ -49,7 +50,13 @@ def generate_kindle_cover(prompt):
49
  image = Image.open(BytesIO(image_bytes))
50
  print("Image successfully created")
51
 
52
- return image
 
 
 
 
 
 
53
 
54
  except Exception as e:
55
  print(f"An error occurred: {str(e)}")
@@ -58,7 +65,7 @@ def generate_kindle_cover(prompt):
58
  iface = gr.Interface(
59
  fn=generate_kindle_cover,
60
  inputs="text",
61
- outputs="image",
62
  title="Kindle Cover Generator",
63
  description="Generate high-quality covers for Amazon Kindle books using the NVIDIA SDXL-Turbo model."
64
  )
 
4
  from io import BytesIO
5
  import base64
6
  import os
7
+ import time
8
 
9
  API_KEY = os.getenv("NVIDIA_API_KEY")
10
  invoke_url = "https://ai.api.nvidia.com/v1/genai/stabilityai/sdxl-turbo"
 
50
  image = Image.open(BytesIO(image_bytes))
51
  print("Image successfully created")
52
 
53
+ # Save the image
54
+ timestamp = int(time.time())
55
+ filename = f"kindle_cover_{timestamp}.png"
56
+ image.save(filename)
57
+ print(f"Image saved as {filename}")
58
+
59
+ return filename
60
 
61
  except Exception as e:
62
  print(f"An error occurred: {str(e)}")
 
65
  iface = gr.Interface(
66
  fn=generate_kindle_cover,
67
  inputs="text",
68
+ outputs="file",
69
  title="Kindle Cover Generator",
70
  description="Generate high-quality covers for Amazon Kindle books using the NVIDIA SDXL-Turbo model."
71
  )