Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,46 +1,53 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import spaces
|
|
|
|
| 3 |
|
| 4 |
-
@spaces.GPU
|
| 5 |
-
def generate_image(prompt, negative_prompt="", seed
|
| 6 |
# This function will be called by gr.load(), so we don't need to implement it here
|
| 7 |
pass
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
["d3xt3r dressed as batman"],
|
| 12 |
-
["d3xt3r in a suit and tie"],
|
| 13 |
-
]
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
#
|
| 18 |
-
with gr.Blocks() as new_demo:
|
| 19 |
-
gr.Markdown("# D3XT3R Dachshund Image Generator")
|
| 20 |
|
| 21 |
with gr.Row():
|
| 22 |
with gr.Column():
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
# Add LoRA scale slider
|
| 27 |
-
lora_scale = gr.Slider(minimum=0.0, maximum=1.0, value=0.8, step=0.05, label="LoRA Influence")
|
| 28 |
-
|
| 29 |
-
generate_btn = gr.Button("Generate")
|
| 30 |
|
| 31 |
with gr.Column():
|
| 32 |
-
for
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
#
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
)
|
| 43 |
|
| 44 |
# Add GPUZero functionality
|
| 45 |
-
|
| 46 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import spaces
|
| 3 |
+
import random
|
| 4 |
|
| 5 |
+
@spaces.GPU(duration=60)
|
| 6 |
+
def generate_image(prompt, negative_prompt="", seed=-1, width=512, height=512, guidance_scale=7.5, num_inference_steps=50):
|
| 7 |
# This function will be called by gr.load(), so we don't need to implement it here
|
| 8 |
pass
|
| 9 |
|
| 10 |
+
# Load the pre-configured Flux model interface
|
| 11 |
+
flux_demo = gr.load("GenAIJake/d3xt3r")
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# Create the Gradio interface
|
| 14 |
+
with gr.Blocks() as demo:
|
| 15 |
+
gr.Markdown("# D3XT3R Dachshund Image Generator (Extended Version)")
|
|
|
|
|
|
|
| 16 |
|
| 17 |
with gr.Row():
|
| 18 |
with gr.Column():
|
| 19 |
+
prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
|
| 20 |
+
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Enter negative prompt here...")
|
| 21 |
+
generate_button = gr.Button("Generate Image")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
with gr.Column():
|
| 24 |
+
seed = gr.Number(label="Seed", value=-1, precision=0, description="Set to -1 for random seed")
|
| 25 |
+
width = gr.Slider(256, 1024, value=512, step=64, label="Width")
|
| 26 |
+
height = gr.Slider(256, 1024, value=512, step=64, label="Height")
|
| 27 |
+
guidance_scale = gr.Slider(1, 20, value=7.5, step=0.5, label="Guidance Scale")
|
| 28 |
+
num_inference_steps = gr.Slider(10, 100, value=50, step=1, label="Number of Inference Steps")
|
| 29 |
+
|
| 30 |
+
with gr.Row():
|
| 31 |
+
image_output = gr.Image(label="Generated Image")
|
| 32 |
+
seed_output = gr.Number(label="Used Seed", precision=0)
|
| 33 |
|
| 34 |
+
# Set up the function call using the loaded Flux model interface
|
| 35 |
+
generate_button.click(
|
| 36 |
+
flux_demo,
|
| 37 |
+
inputs=[prompt, negative_prompt, seed, width, height, guidance_scale, num_inference_steps],
|
| 38 |
+
outputs=[image_output, seed_output]
|
| 39 |
+
)
|
| 40 |
|
| 41 |
+
# Add examples
|
| 42 |
+
gr.Examples(
|
| 43 |
+
examples=[
|
| 44 |
+
["d3xt3r as a camp counselor in the woods.", "", -1, 512, 512, 7.5, 50],
|
| 45 |
+
["d3xt3r dressed as batman", "blurry, low quality", 42, 640, 640, 8.0, 60],
|
| 46 |
+
["d3xt3r in a suit and tie", "", 123, 768, 512, 6.5, 40],
|
| 47 |
+
],
|
| 48 |
+
inputs=[prompt, negative_prompt, seed, width, height, guidance_scale, num_inference_steps],
|
| 49 |
)
|
| 50 |
|
| 51 |
# Add GPUZero functionality
|
| 52 |
+
demo.queue()
|
| 53 |
+
demo.launch()
|