tejani's picture
Update app.py
c982554 verified
raw
history blame
923 Bytes
import gradio as gr
import random
# Load the pre-built model interface
model_interface = gr.load("models/ZB-Tech/Text-to-Image")
# Wrapper function to randomize the seed
def generate_with_random_seed(prompt, *args, **kwargs):
# Generate a random seed (e.g., between 0 and 2^32 - 1)
random_seed = random.randint(0, 4294967295)
# Call the loaded model interface with the prompt and random seed
# Assuming the model accepts a 'seed' parameter; adjust if it uses a different name
return model_interface(prompt, seed=random_seed, *args, **kwargs)
# Create a new Gradio interface with the wrapper
demo = gr.Interface(
fn=generate_with_random_seed,
inputs=gr.Textbox(label="Prompt", placeholder="Enter your prompt here"),
outputs="image",
title="Text-to-Image with Random Seed",
description="Generate images with a randomized seed each time."
)
# Launch the interface
demo.launch()