LuigiLui commited on
Commit
cc9c757
·
verified ·
1 Parent(s): 5808f1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -9
app.py CHANGED
@@ -1,17 +1,16 @@
1
  import gradio as gr
2
  import random
3
 
 
4
  model = gr.load("models/Purz/face-projection")
5
 
 
6
  def generate_image(text, seed):
7
  if seed is not None:
8
  random.seed(seed)
9
-
10
- if text in [example[0] for example in examples]:
11
- print(f"Using example: {text}")
12
-
13
  return model(text)
14
 
 
15
  examples = [
16
  ["Humanoid Cat Warrior, Full View", None],
17
  ["Warhammer Sisterhood", None],
@@ -19,16 +18,43 @@ examples = [
19
  ["Fantasy dragon", None]
20
  ]
21
 
 
22
  interface = gr.Interface(
23
  fn=generate_image,
24
  inputs=[
25
- gr.Textbox(label="Type here your imagination:", placeholder="Type or click an example..."),
26
- gr.Slider(minimum=0, maximum=10000, step=1, label="Seed (optional)")
27
  ],
28
- outputs=gr.Image(label="Generated Image"),
29
  examples=examples,
30
- theme="NoCrypt/miku",
31
- description="Sorry for the inconvenience. The model is currently running on the CPU, which might affect performance. We appreciate your understanding.",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  )
33
 
 
34
  interface.launch()
 
1
  import gradio as gr
2
  import random
3
 
4
+ # Load the model
5
  model = gr.load("models/Purz/face-projection")
6
 
7
+ # Function to generate image
8
  def generate_image(text, seed):
9
  if seed is not None:
10
  random.seed(seed)
 
 
 
 
11
  return model(text)
12
 
13
+ # Define example inputs
14
  examples = [
15
  ["Humanoid Cat Warrior, Full View", None],
16
  ["Warhammer Sisterhood", None],
 
18
  ["Fantasy dragon", None]
19
  ]
20
 
21
+ # Customized Gradio Interface
22
  interface = gr.Interface(
23
  fn=generate_image,
24
  inputs=[
25
+ gr.Textbox(label="Imagine and Type Here:", placeholder="Type your idea or click an example...", elem_id="input-text"),
26
+ gr.Slider(minimum=0, maximum=10000, step=1, label="Seed (optional)", elem_id="seed-slider")
27
  ],
28
+ outputs=gr.Image(label="Generated Image", elem_id="output-image"),
29
  examples=examples,
30
+ theme="default",
31
+ description="The model is currently running on CPU. Performance might vary. Thanks for your patience.",
32
+ css="""
33
+ #input-text, #seed-slider .input-label, .output-label, .description {
34
+ font-family: 'Arial', sans-serif;
35
+ text-align: center;
36
+ color: #333;
37
+ }
38
+ .container {
39
+ background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
40
+ border-radius: 12px;
41
+ padding: 10px;
42
+ }
43
+ .btn {
44
+ background: linear-gradient(90deg, #ff8a00, #e52e71);
45
+ border: none;
46
+ border-radius: 25px;
47
+ color: white;
48
+ padding: 12px 24px;
49
+ font-size: 16px;
50
+ font-weight: bold;
51
+ cursor: pointer;
52
+ }
53
+ .examples-table {
54
+ text-align: center;
55
+ }
56
+ """
57
  )
58
 
59
+ # Launch the interface
60
  interface.launch()