Kvikontent commited on
Commit
0aedcaa
·
verified ·
1 Parent(s): f265fa8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -47,8 +47,9 @@ def query(payload):
47
 
48
  def generate_image_from_prompt(prompt_text):
49
  image_bytes = query({"inputs": prompt_text})
50
- generated_image = Image.open(io.BytesIO(image_bytes))
51
- return generated_image
 
52
 
53
  title = "KVIImager 2.0 Demo 🎨"
54
  description = "This app uses Hugging Face AI model to generate an image based on the provided text prompt 🖼️."
@@ -56,13 +57,13 @@ description = "This app uses Hugging Face AI model to generate an image based on
56
  input_prompt = gr.Textbox(label="Enter Prompt 📝", placeholder="E.g. 'A peaceful garden with a small cottage'")
57
  output_generated_image = gr.Image(label="Generated Image")
58
 
59
- with gr.Blocks(theme=gr.themes.Soft()) as app:
60
- caption = "Generate Image"
61
- iface = gr.Interface(
62
- generate_image_from_prompt,
63
- inputs=input_prompt,
64
- outputs=output_generated_image,
65
- title=title,
66
- description=description
67
- )
68
- iface.launch()
 
47
 
48
  def generate_image_from_prompt(prompt_text):
49
  image_bytes = query({"inputs": prompt_text})
50
+ img = BytesIO(image_bytes) # Convert to BytesIO stream
51
+ pil_img = Image.open(img) # Open the image using PIL library
52
+ return pil_img # Return the converted PIL image
53
 
54
  title = "KVIImager 2.0 Demo 🎨"
55
  description = "This app uses Hugging Face AI model to generate an image based on the provided text prompt 🖼️."
 
57
  input_prompt = gr.Textbox(label="Enter Prompt 📝", placeholder="E.g. 'A peaceful garden with a small cottage'")
58
  output_generated_image = gr.Image(label="Generated Image")
59
 
60
+ #with gr.Blocks(theme=gr.themes.Soft()) as app:
61
+ # caption = "Generate Image"
62
+ iface = gr.Interface(
63
+ generate_image_from_prompt,
64
+ inputs=input_prompt,
65
+ outputs=output_generated_image,
66
+ title=title,
67
+ description=description
68
+ )
69
+ iface.launch()