GenAIJake commited on
Commit
dac7332
·
verified ·
1 Parent(s): 1117196

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -42
app.py CHANGED
@@ -1,52 +1,23 @@
1
  import gradio as gr
2
  import spaces
3
- from huggingface_hub import HfApi
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("spaces/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.predict,
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()
 
1
  import gradio as gr
2
  import spaces
 
3
 
4
+ @spaces.GPU
5
+ def generate_image(prompt, negative_prompt="", seed=42, width=512, height=512, guidance_scale=3.5, num_inference_steps=20):
6
  # This function will be called by gr.load(), so we don't need to implement it here
7
  pass
8
 
9
+ examples = [
10
+ ["d3xt3r as a camp counselor in the woods."],
11
+ ["d3xt3r dressed as batman"],
12
+ ["d3xt3r in a suit and tie"],
13
+ ]
14
 
15
+ demo = gr.load("models/GenAIJake/d3xt3r")
16
+
17
+ # Customize the interface
18
+ with demo:
19
+ gr.Markdown("# D3XT3R Dachshund Image Generator")
20
+ gr.Examples(examples, inputs=demo.input_components)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  # Add GPUZero functionality
23
  demo.queue()