Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,21 +6,27 @@ import random
|
|
6 |
hf_token = os.getenv("HF_TOKEN")
|
7 |
|
8 |
# Load the pre-built text-to-image model interface
|
9 |
-
|
10 |
|
11 |
-
# Function to generate a random seed
|
12 |
-
def
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
# Create a custom interface
|
19 |
custom_interface = gr.Interface(
|
20 |
-
fn=
|
21 |
-
inputs="
|
22 |
-
outputs="
|
23 |
-
title="Text-to-Image with Random Seed"
|
|
|
24 |
)
|
25 |
|
26 |
# Launch the interface
|
|
|
6 |
hf_token = os.getenv("HF_TOKEN")
|
7 |
|
8 |
# Load the pre-built text-to-image model interface
|
9 |
+
base_interface = gr.load("models/ZB-Tech/Text-to-Image", token=hf_token)
|
10 |
|
11 |
+
# Function to generate an image with a random seed
|
12 |
+
def generate_image_with_seed(prompt):
|
13 |
+
# Generate a random seed (for display or potential use)
|
14 |
+
seed = random.randint(0, 1000000)
|
15 |
+
|
16 |
+
# Call the pre-built interface to generate the image
|
17 |
+
# Note: This assumes the interface takes a text prompt and returns an image
|
18 |
+
image = base_interface(prompt)
|
19 |
+
|
20 |
+
# Return the image and the seed value
|
21 |
+
return image, f"Random seed used: {seed}"
|
22 |
|
23 |
+
# Create a custom Gradio interface
|
24 |
custom_interface = gr.Interface(
|
25 |
+
fn=generate_image_with_seed,
|
26 |
+
inputs=gr.Textbox(label="Enter your prompt"),
|
27 |
+
outputs=[gr.Image(label="Generated Image"), gr.Textbox(label="Seed")],
|
28 |
+
title="Text-to-Image with Random Seed",
|
29 |
+
description="Generate an image from a text prompt with a random seed."
|
30 |
)
|
31 |
|
32 |
# Launch the interface
|