primerz commited on
Commit
243381c
·
verified ·
1 Parent(s): 069fe14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -16
app.py CHANGED
@@ -17,12 +17,15 @@ gen = Generator(handler)
17
  @spaces.GPU(duration=35)
18
  def process_img(
19
  image,
20
- prompt,
 
21
  cfg_scale,
22
  steps,
23
  img_strength,
24
  depth_strength,
25
- edge_strength
 
 
26
  ):
27
  if image is None:
28
  raise gr.Error("Please upload an image first.")
@@ -33,11 +36,14 @@ def process_img(
33
  result = gen.predict(
34
  image,
35
  prompt,
 
36
  guidance_scale=cfg_scale,
37
  num_inference_steps=steps,
38
  img2img_strength=img_strength,
39
  depth_strength=depth_strength,
40
- lineart_strength=edge_strength
 
 
41
  )
42
  print("--- Generation Complete ---")
43
  return result
@@ -64,14 +70,26 @@ with gr.Blocks(title="Face To Pixel Art", theme=gr.themes.Soft()) as demo:
64
  info="The trigger words 'p1x3l4rt, pixel art' are added automatically."
65
  )
66
 
67
- # --- MOVED ACCORDION HERE ---
 
 
 
 
 
68
  with gr.Accordion("Advanced Settings", open=False):
 
 
 
 
 
 
 
 
69
  cfg_scale = gr.Slider(
70
  elem_id="cfg_scale",
71
  minimum=1.0,
72
  maximum=5.0,
73
  step=0.1,
74
- # --- USE CONFIG DEFAULT ---
75
  value=Config.CGF_SCALE,
76
  label="CFG Scale"
77
  )
@@ -80,7 +98,6 @@ with gr.Blocks(title="Face To Pixel Art", theme=gr.themes.Soft()) as demo:
80
  minimum=4,
81
  maximum=20,
82
  step=1,
83
- # --- USE CONFIG DEFAULT ---
84
  value=Config.STEPS_NUMBER,
85
  label="Steps Number"
86
  )
@@ -89,7 +106,6 @@ with gr.Blocks(title="Face To Pixel Art", theme=gr.themes.Soft()) as demo:
89
  minimum=0.1,
90
  maximum=1.0,
91
  step=0.05,
92
- # --- USE CONFIG DEFAULT ---
93
  value=Config.IMG_STRENGTH,
94
  label="Image Strength (Img2Img)"
95
  )
@@ -98,7 +114,6 @@ with gr.Blocks(title="Face To Pixel Art", theme=gr.themes.Soft()) as demo:
98
  minimum=0.0,
99
  maximum=1.0,
100
  step=0.05,
101
- # --- USE CONFIG DEFAULT ---
102
  value=Config.DEPTH_STRENGTH,
103
  label="DepthMap Strength"
104
  )
@@ -107,31 +122,37 @@ with gr.Blocks(title="Face To Pixel Art", theme=gr.themes.Soft()) as demo:
107
  minimum=0.0,
108
  maximum=1.0,
109
  step=0.05,
110
- # --- USE CONFIG DEFAULT ---
111
  value=Config.EDGE_STRENGTH,
112
  label="EdgeMap Strength (LineArt)"
113
  )
114
- # --- END OF MOVED BLOCK ---
115
-
116
- run_btn = gr.Button("Generate Pixel Art", variant="primary")
 
 
 
 
 
 
117
 
118
- # --- REMOVED gr.Examples BLOCK ---
119
 
120
  with gr.Column(scale=1):
121
  output_img = gr.Image(label="Pixel Art Result")
122
-
123
- # The accordion was here, but has been moved to the left column
124
 
125
  # Event Handler
126
  # Update inputs list for the click event
127
  all_inputs = [
128
  input_img,
129
  prompt,
 
130
  cfg_scale,
131
  steps,
132
  img_strength,
133
  depth_strength,
134
- edge_strength
 
 
135
  ]
136
 
137
  run_btn.click(
 
17
  @spaces.GPU(duration=35)
18
  def process_img(
19
  image,
20
+ prompt,
21
+ negative_prompt, # <-- ADDED
22
  cfg_scale,
23
  steps,
24
  img_strength,
25
  depth_strength,
26
+ edge_strength,
27
+ color_strength, # <-- ADDED
28
+ seed # <-- ADDED
29
  ):
30
  if image is None:
31
  raise gr.Error("Please upload an image first.")
 
36
  result = gen.predict(
37
  image,
38
  prompt,
39
+ negative_prompt=negative_prompt, # <-- ADDED
40
  guidance_scale=cfg_scale,
41
  num_inference_steps=steps,
42
  img2img_strength=img_strength,
43
  depth_strength=depth_strength,
44
+ lineart_strength=edge_strength,
45
+ color_strength=color_strength, # <-- ADDED
46
+ seed=seed # <-- ADDED
47
  )
48
  print("--- Generation Complete ---")
49
  return result
 
70
  info="The trigger words 'p1x3l4rt, pixel art' are added automatically."
71
  )
72
 
73
+ # --- ADDED: Negative Prompt ---
74
+ negative_prompt = gr.Textbox(
75
+ label="Negative Prompt (Optional)",
76
+ placeholder="e.g., blurry, text, watermark, bad art..."
77
+ )
78
+
79
  with gr.Accordion("Advanced Settings", open=False):
80
+ # --- ADDED: Seed ---
81
+ seed = gr.Number(
82
+ label="Seed",
83
+ value=-1,
84
+ info="-1 for random",
85
+ precision=0
86
+ )
87
+
88
  cfg_scale = gr.Slider(
89
  elem_id="cfg_scale",
90
  minimum=1.0,
91
  maximum=5.0,
92
  step=0.1,
 
93
  value=Config.CGF_SCALE,
94
  label="CFG Scale"
95
  )
 
98
  minimum=4,
99
  maximum=20,
100
  step=1,
 
101
  value=Config.STEPS_NUMBER,
102
  label="Steps Number"
103
  )
 
106
  minimum=0.1,
107
  maximum=1.0,
108
  step=0.05,
 
109
  value=Config.IMG_STRENGTH,
110
  label="Image Strength (Img2Img)"
111
  )
 
114
  minimum=0.0,
115
  maximum=1.0,
116
  step=0.05,
 
117
  value=Config.DEPTH_STRENGTH,
118
  label="DepthMap Strength"
119
  )
 
122
  minimum=0.0,
123
  maximum=1.0,
124
  step=0.05,
 
125
  value=Config.EDGE_STRENGTH,
126
  label="EdgeMap Strength (LineArt)"
127
  )
128
+ # --- ADDED: Color Strength ---
129
+ color_strength = gr.Slider(
130
+ elem_id="color_strength",
131
+ minimum=0.0,
132
+ maximum=1.0,
133
+ step=0.05,
134
+ value=Config.COLOR_STRENGTH,
135
+ label="ColorMap Strength"
136
+ )
137
 
138
+ run_btn = gr.Button("Generate Pixel Art", variant="primary")
139
 
140
  with gr.Column(scale=1):
141
  output_img = gr.Image(label="Pixel Art Result")
 
 
142
 
143
  # Event Handler
144
  # Update inputs list for the click event
145
  all_inputs = [
146
  input_img,
147
  prompt,
148
+ negative_prompt, # <-- ADDED
149
  cfg_scale,
150
  steps,
151
  img_strength,
152
  depth_strength,
153
+ edge_strength,
154
+ color_strength, # <-- ADDED
155
+ seed # <-- ADDED
156
  ]
157
 
158
  run_btn.click(