Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,33 +1,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 |
-
|
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
|
33 |
-
custom_interface.launch()
|
|
|
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 |
+
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|