bluenevus commited on
Commit
b43e919
·
verified ·
1 Parent(s): 8bbb39c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -1,6 +1,8 @@
1
  import gradio as gr
2
  import google.generativeai as genai
3
  import requests
 
 
4
 
5
  # List of popular styles
6
  STYLES = [
@@ -76,8 +78,12 @@ def generate_image(stability_api_key, enhanced_prompt, style, negative_prompt):
76
 
77
  def process_and_generate(google_api_key, stability_api_key, prompt, style, negative_prompt):
78
  enhanced_prompt = enhance_prompt(google_api_key, prompt, style)
79
- image_data = generate_image(stability_api_key, enhanced_prompt, style, negative_prompt)
80
- return image_data, enhanced_prompt
 
 
 
 
81
 
82
  with gr.Blocks() as demo:
83
  gr.Markdown("# Stability AI Image Generator with Google Gemini Prompt Enhancement")
 
1
  import gradio as gr
2
  import google.generativeai as genai
3
  import requests
4
+ from PIL import Image
5
+ import io
6
 
7
  # List of popular styles
8
  STYLES = [
 
78
 
79
  def process_and_generate(google_api_key, stability_api_key, prompt, style, negative_prompt):
80
  enhanced_prompt = enhance_prompt(google_api_key, prompt, style)
81
+ image_bytes = generate_image(stability_api_key, enhanced_prompt, style, negative_prompt)
82
+
83
+ # Convert bytes to PIL Image
84
+ image = Image.open(io.BytesIO(image_bytes))
85
+
86
+ return image, enhanced_prompt
87
 
88
  with gr.Blocks() as demo:
89
  gr.Markdown("# Stability AI Image Generator with Google Gemini Prompt Enhancement")