LuigiLui commited on
Commit
51f8fc2
·
verified ·
1 Parent(s): 76ea01b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -24
app.py CHANGED
@@ -8,27 +8,20 @@ def generate_image(text, seed):
8
  if seed is not None:
9
  random.seed(seed)
10
 
11
- # Define slight variations of the original prompt for different poses/positions
12
- variations = [
13
- f"{text}, front view",
14
- f"{text}, side view",
15
- f"{text}, dynamic pose",
16
- f"{text}, close-up view"
17
- ]
18
 
19
- # Generate an image for each variation
20
- images = [model(variation) for variation in variations]
21
- return images
22
 
23
- # Define examples with pre-generated image previews
24
  examples = [
25
- ["Humanoid Cat Warrior, Full View", None, "path/to/humanoid_cat_preview.jpg"],
26
- ["Warhammer Sisterhood", None, "path/to/warhammer_sisterhood_preview.jpg"],
27
- ["Future Robots war", None, "path/to/future_robots_war_preview.jpg"],
28
- ["Fantasy dragon", None, "path/to/fantasy_dragon_preview.jpg"]
29
  ]
30
 
31
- # Custom CSS for styling
32
  css = """
33
  /* General button styles */
34
  button {
@@ -68,20 +61,16 @@ input[type=range] {
68
  }
69
  """
70
 
71
- # Define a function to create the examples with preview images
72
- def create_example_row(example):
73
- return [gr.Example(value=example[0], examples=None, label=example[0], image=example[2])]
74
-
75
- # Gradio interface
76
  interface = gr.Interface(
77
  fn=generate_image,
78
  inputs=[
79
  gr.Textbox(label="Type your imagination:", placeholder="Type or select an example..."),
80
  gr.Slider(minimum=0, maximum=10000, step=1, label="Seed (optional)")
81
  ],
82
- outputs=[gr.Image(label=f"Generated Image {i+1}") for i in range(4)],
83
- examples=create_example_row(examples), # Use pre-generated images for previews
84
- css=css,
85
  description="Note: The model is running on CPU; processing might take a bit longer. Thank you for your patience!"
86
  )
87
 
 
8
  if seed is not None:
9
  random.seed(seed)
10
 
11
+ if text in [example[0] for example in examples]:
12
+ print(f"Using example: {text}")
 
 
 
 
 
13
 
14
+ return model(text)
 
 
15
 
16
+ # Examples for user guidance
17
  examples = [
18
+ ["Humanoid Cat Warrior, Full View", None],
19
+ ["Warhammer Sisterhood", None],
20
+ ["Future Robots war", None],
21
+ ["Fantasy dragon", None]
22
  ]
23
 
24
+ # Custom CSS for gradient buttons and capsule shapes
25
  css = """
26
  /* General button styles */
27
  button {
 
61
  }
62
  """
63
 
64
+ # Gradio interface with custom styles
 
 
 
 
65
  interface = gr.Interface(
66
  fn=generate_image,
67
  inputs=[
68
  gr.Textbox(label="Type your imagination:", placeholder="Type or select an example..."),
69
  gr.Slider(minimum=0, maximum=10000, step=1, label="Seed (optional)")
70
  ],
71
+ outputs=gr.Image(label="Generated Image"),
72
+ examples=examples,
73
+ css=css, # Apply custom CSS styling
74
  description="Note: The model is running on CPU; processing might take a bit longer. Thank you for your patience!"
75
  )
76