Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,27 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
|
|
|
| 3 |
|
| 4 |
# Load the API token from the environment variable
|
| 5 |
hf_token = os.getenv("HF_TOKEN")
|
|
|
|
|
|
|
| 6 |
interface = gr.load("models/ZB-Tech/Text-to-Image", token=hf_token)
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
+
import random
|
| 4 |
|
| 5 |
# Load the API token from the environment variable
|
| 6 |
hf_token = os.getenv("HF_TOKEN")
|
| 7 |
+
|
| 8 |
+
# Load the pre-built text-to-image model interface
|
| 9 |
interface = gr.load("models/ZB-Tech/Text-to-Image", token=hf_token)
|
| 10 |
|
| 11 |
+
# Function to generate a random seed and display it
|
| 12 |
+
def generate_with_seed(prompt):
|
| 13 |
+
seed = random.randint(0, 1000000) # Generate a random seed
|
| 14 |
+
# Note: The pre-built interface may not accept a seed parameter directly.
|
| 15 |
+
# This is just an example of how you might use it if you had control over the model.
|
| 16 |
+
return f"Generated with random seed: {seed}"
|
| 17 |
+
|
| 18 |
+
# Create a custom interface that includes the seed generation
|
| 19 |
+
custom_interface = gr.Interface(
|
| 20 |
+
fn=generate_with_seed,
|
| 21 |
+
inputs="text",
|
| 22 |
+
outputs="text", # Adjust this based on what the model actually returns (e.g., "image")
|
| 23 |
+
title="Text-to-Image with Random Seed"
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# Launch the interface
|
| 27 |
+
custom_interface.launch()
|