Update app.py
Browse files
app.py
CHANGED
@@ -4,17 +4,15 @@ from PIL import Image
|
|
4 |
import io
|
5 |
import os
|
6 |
|
7 |
-
|
8 |
-
API_KEY = os.getenv("HF_API_TOKEN") # Replace with environment variable reference
|
9 |
MODEL_NAME = "black-forest-labs/FLUX.1-dev"
|
10 |
|
11 |
-
# Initialize client
|
12 |
client = InferenceClient(api_key=API_KEY)
|
13 |
|
14 |
def generate_image(prompt):
|
15 |
"""Generate an image from a text prompt using Hugging Face API."""
|
16 |
try:
|
17 |
-
image = client.text_to_image(prompt, model=MODEL_NAME)
|
18 |
img_byte_array = io.BytesIO()
|
19 |
image.save(img_byte_array, format="PNG")
|
20 |
img_byte_array.seek(0)
|
@@ -65,7 +63,7 @@ input, textarea {
|
|
65 |
with gr.Blocks(css=css) as demo:
|
66 |
title="🚀 Agents Valley AI Image Generator",
|
67 |
gr.Markdown(
|
68 |
-
"<h2 style='color: white; font-size: 18px; font-weight: 500;'>
|
69 |
)
|
70 |
prompt_input = gr.Textbox(label="Enter your prompt", value="A robot on a stallion.")
|
71 |
output_image = gr.Image(label="Generated Image by Agents Valley")
|
|
|
4 |
import io
|
5 |
import os
|
6 |
|
7 |
+
API_KEY = os.getenv("HF_API_TOKEN")
|
|
|
8 |
MODEL_NAME = "black-forest-labs/FLUX.1-dev"
|
9 |
|
|
|
10 |
client = InferenceClient(api_key=API_KEY)
|
11 |
|
12 |
def generate_image(prompt):
|
13 |
"""Generate an image from a text prompt using Hugging Face API."""
|
14 |
try:
|
15 |
+
image = client.text_to_image(prompt, model=MODEL_NAME)
|
16 |
img_byte_array = io.BytesIO()
|
17 |
image.save(img_byte_array, format="PNG")
|
18 |
img_byte_array.seek(0)
|
|
|
63 |
with gr.Blocks(css=css) as demo:
|
64 |
title="🚀 Agents Valley AI Image Generator",
|
65 |
gr.Markdown(
|
66 |
+
"<h2 style='color: white; font-size: 18px; font-weight: 500;'>AI image Generator powered by Agents Valley</h2>"
|
67 |
)
|
68 |
prompt_input = gr.Textbox(label="Enter your prompt", value="A robot on a stallion.")
|
69 |
output_image = gr.Image(label="Generated Image by Agents Valley")
|