Download app.py from SrirakshaKR/Text_To_Image_Conversion: direct link, hf CLI and curl.
- Browser
- Download file 923 Bytes
-
https://huggingface.co/spaces/SrirakshaKR/Text_To_Image_Conversion/resolve/refs%2Fpr%2F1/app.py
- Command line
-
hf download hf://spaces/SrirakshaKR/Text_To_Image_Conversion@refs/pr/1/app.py
-
curl -L -o app.py https://huggingface.co/spaces/SrirakshaKR/Text_To_Image_Conversion/resolve/refs%2Fpr%2F1/app.py
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() |