Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import replicate
|
| 3 |
import os
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
def generate_image(prompt, api_key):
|
| 6 |
# Set the API key for the current session
|
|
@@ -18,8 +21,12 @@ def generate_image(prompt, api_key):
|
|
| 18 |
input=inputs
|
| 19 |
)
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Create the Gradio interface
|
| 25 |
iface = gr.Interface(
|
|
@@ -37,7 +44,7 @@ iface = gr.Interface(
|
|
| 37 |
label="Replicate API Key"
|
| 38 |
)
|
| 39 |
],
|
| 40 |
-
outputs=gr.Image(type="
|
| 41 |
title="FLUX 1.1 Pro Text-to-Image Generator",
|
| 42 |
description="Generate images from text prompts using the FLUX 1.1 Pro model."
|
| 43 |
)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import replicate
|
| 3 |
import os
|
| 4 |
+
import requests
|
| 5 |
+
from PIL import Image
|
| 6 |
+
from io import BytesIO
|
| 7 |
|
| 8 |
def generate_image(prompt, api_key):
|
| 9 |
# Set the API key for the current session
|
|
|
|
| 21 |
input=inputs
|
| 22 |
)
|
| 23 |
|
| 24 |
+
# Fetch the image from the URL
|
| 25 |
+
response = requests.get(output_url)
|
| 26 |
+
image = Image.open(BytesIO(response.content))
|
| 27 |
+
|
| 28 |
+
# Return the image
|
| 29 |
+
return image
|
| 30 |
|
| 31 |
# Create the Gradio interface
|
| 32 |
iface = gr.Interface(
|
|
|
|
| 44 |
label="Replicate API Key"
|
| 45 |
)
|
| 46 |
],
|
| 47 |
+
outputs=gr.Image(type="pil"),
|
| 48 |
title="FLUX 1.1 Pro Text-to-Image Generator",
|
| 49 |
description="Generate images from text prompts using the FLUX 1.1 Pro model."
|
| 50 |
)
|