Update app.py
#1
by
tejani
- opened
app.py
CHANGED
|
@@ -1,3 +1,26 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import random
|
| 3 |
|
| 4 |
+
# Load the pre-built model interface
|
| 5 |
+
model_interface = gr.load("models/ZB-Tech/Text-to-Image")
|
| 6 |
+
|
| 7 |
+
# Wrapper function to randomize the seed
|
| 8 |
+
def generate_with_random_seed(prompt, *args, **kwargs):
|
| 9 |
+
# Generate a random seed (e.g., between 0 and 2^32 - 1)
|
| 10 |
+
random_seed = random.randint(0, 4294967295)
|
| 11 |
+
|
| 12 |
+
# Call the loaded model interface with the prompt and random seed
|
| 13 |
+
# Assuming the model accepts a 'seed' parameter; adjust if it uses a different name
|
| 14 |
+
return model_interface(prompt, seed=random_seed, *args, **kwargs)
|
| 15 |
+
|
| 16 |
+
# Create a new Gradio interface with the wrapper
|
| 17 |
+
demo = gr.Interface(
|
| 18 |
+
fn=generate_with_random_seed,
|
| 19 |
+
inputs=gr.Textbox(label="Prompt", placeholder="Enter your prompt here"),
|
| 20 |
+
outputs="image",
|
| 21 |
+
title="Text-to-Image with Random Seed",
|
| 22 |
+
description="Generate images with a randomized seed each time."
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
# Launch the interface
|
| 26 |
+
demo.launch()
|