Spaces:
Sleeping
Sleeping
lucaeyring
commited on
Commit
·
b66671b
1
Parent(s):
5cc9176
updated default parameters
Browse files- app.py +27 -16
- arguments.py +8 -10
app.py
CHANGED
|
@@ -78,25 +78,36 @@ def setup_model(loaded_model_setup, prompt, model, seed, num_iterations, enable_
|
|
| 78 |
args.save_all_images = True
|
| 79 |
|
| 80 |
if enable_hps is True:
|
| 81 |
-
args.
|
| 82 |
args.hps_weighting = hps_w
|
|
|
|
|
|
|
| 83 |
|
| 84 |
if enable_imagereward is True:
|
| 85 |
-
args.
|
| 86 |
args.imagereward_weighting = imgrw_w
|
|
|
|
|
|
|
| 87 |
|
| 88 |
if enable_pickscore is True:
|
| 89 |
-
args.
|
| 90 |
args.pickscore_weighting = pcks_w
|
|
|
|
|
|
|
| 91 |
|
| 92 |
if enable_clip is True:
|
| 93 |
-
args.
|
| 94 |
args.clip_weighting = clip_w
|
|
|
|
|
|
|
| 95 |
|
| 96 |
if model == "flux":
|
| 97 |
args.cpu_offloading = True
|
| 98 |
args.enable_multi_apply = True
|
| 99 |
args.multi_step_model = "flux"
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
# Check if args are the same as the loaded_model_setup except for the prompt
|
| 102 |
if loaded_model_setup and hasattr(loaded_model_setup[0], '__dict__'):
|
|
@@ -299,28 +310,28 @@ with gr.Blocks(css=css, analytics_enabled=False) as demo:
|
|
| 299 |
with gr.Column():
|
| 300 |
prompt = gr.Textbox(label="Prompt")
|
| 301 |
with gr.Row():
|
| 302 |
-
chosen_model = gr.Dropdown(["sd-turbo", "sdxl-turbo", "pixart", "hyper-sd", "flux"], label="Model", value="
|
| 303 |
seed = gr.Number(label="seed", value=0)
|
| 304 |
|
| 305 |
model_status = gr.Textbox(label="model status", visible=True, elem_id="model-status-id")
|
| 306 |
|
| 307 |
with gr.Row():
|
| 308 |
-
n_iter = gr.Slider(minimum=10, maximum=100, step=10, value=
|
| 309 |
-
learning_rate = gr.Slider(minimum=0.1, maximum=10.0, step=0.1, value=5
|
| 310 |
|
| 311 |
with gr.Accordion("Advanced Settings", open=True):
|
| 312 |
with gr.Column():
|
| 313 |
with gr.Row():
|
| 314 |
-
enable_hps = gr.Checkbox(label="HPS ON", value=
|
| 315 |
hps_w = gr.Slider(label="HPS weight", step=0.1, minimum=0.0, maximum=10.0, value=5.0, interactive=False, scale=3)
|
| 316 |
with gr.Row():
|
| 317 |
-
enable_imagereward = gr.Checkbox(label="ImageReward ON", value=
|
| 318 |
imgrw_w = gr.Slider(label="ImageReward weight", step=0.1, minimum=0, maximum=5.0, value=1.0, interactive=False, scale=3)
|
| 319 |
with gr.Row():
|
| 320 |
-
enable_pickscore = gr.Checkbox(label="PickScore ON", value=
|
| 321 |
-
pcks_w = gr.Slider(label="PickScore weight", step=0.01, minimum=0, maximum=5
|
| 322 |
with gr.Row():
|
| 323 |
-
enable_clip = gr.Checkbox(label="CLIP ON", value=
|
| 324 |
clip_w = gr.Slider(label="CLIP weight", step=0.01, minimum=0, maximum=0.1, value=0.01, interactive=False, scale=3)
|
| 325 |
|
| 326 |
submit_btn = gr.Button("Submit")
|
|
@@ -328,11 +339,11 @@ with gr.Blocks(css=css, analytics_enabled=False) as demo:
|
|
| 328 |
gr.Examples(
|
| 329 |
examples = [
|
| 330 |
"A red dog and a green cat",
|
| 331 |
-
"A
|
| 332 |
-
"A toaster riding a bike",
|
| 333 |
-
"Dwayne Johnson depicted as a philosopher king in an academic painting by Greg Rutkowski",
|
| 334 |
"A curious, orange fox and a fluffy, white rabbit, playing together in a lush, green meadow filled with yellow dandelions",
|
| 335 |
-
"An
|
|
|
|
|
|
|
| 336 |
],
|
| 337 |
inputs = [prompt]
|
| 338 |
)
|
|
|
|
| 78 |
args.save_all_images = True
|
| 79 |
|
| 80 |
if enable_hps is True:
|
| 81 |
+
args.enable_hps = True
|
| 82 |
args.hps_weighting = hps_w
|
| 83 |
+
else:
|
| 84 |
+
args.enable_hps = False
|
| 85 |
|
| 86 |
if enable_imagereward is True:
|
| 87 |
+
args.enable_imagereward = True
|
| 88 |
args.imagereward_weighting = imgrw_w
|
| 89 |
+
else:
|
| 90 |
+
args.enable_imagereward = False
|
| 91 |
|
| 92 |
if enable_pickscore is True:
|
| 93 |
+
args.enable_pickscore = True
|
| 94 |
args.pickscore_weighting = pcks_w
|
| 95 |
+
else:
|
| 96 |
+
args.enable_pickscore = False
|
| 97 |
|
| 98 |
if enable_clip is True:
|
| 99 |
+
args.enable_clip = True
|
| 100 |
args.clip_weighting = clip_w
|
| 101 |
+
else:
|
| 102 |
+
args.enable_clip = False
|
| 103 |
|
| 104 |
if model == "flux":
|
| 105 |
args.cpu_offloading = True
|
| 106 |
args.enable_multi_apply = True
|
| 107 |
args.multi_step_model = "flux"
|
| 108 |
+
|
| 109 |
+
if model == "hyper-sd":
|
| 110 |
+
args.cpu_offloading = True
|
| 111 |
|
| 112 |
# Check if args are the same as the loaded_model_setup except for the prompt
|
| 113 |
if loaded_model_setup and hasattr(loaded_model_setup[0], '__dict__'):
|
|
|
|
| 310 |
with gr.Column():
|
| 311 |
prompt = gr.Textbox(label="Prompt")
|
| 312 |
with gr.Row():
|
| 313 |
+
chosen_model = gr.Dropdown(["sd-turbo", "sdxl-turbo", "pixart", "hyper-sd", "flux"], label="Model", value="sdxl-turbo")
|
| 314 |
seed = gr.Number(label="seed", value=0)
|
| 315 |
|
| 316 |
model_status = gr.Textbox(label="model status", visible=True, elem_id="model-status-id")
|
| 317 |
|
| 318 |
with gr.Row():
|
| 319 |
+
n_iter = gr.Slider(minimum=10, maximum=100, step=10, value=50, label="Number of Iterations")
|
| 320 |
+
learning_rate = gr.Slider(minimum=0.1, maximum=10.0, step=0.1, value=2.5, label="Learning Rate")
|
| 321 |
|
| 322 |
with gr.Accordion("Advanced Settings", open=True):
|
| 323 |
with gr.Column():
|
| 324 |
with gr.Row():
|
| 325 |
+
enable_hps = gr.Checkbox(label="HPS ON", value=True, scale=1)
|
| 326 |
hps_w = gr.Slider(label="HPS weight", step=0.1, minimum=0.0, maximum=10.0, value=5.0, interactive=False, scale=3)
|
| 327 |
with gr.Row():
|
| 328 |
+
enable_imagereward = gr.Checkbox(label="ImageReward ON", value=True, scale=1)
|
| 329 |
imgrw_w = gr.Slider(label="ImageReward weight", step=0.1, minimum=0, maximum=5.0, value=1.0, interactive=False, scale=3)
|
| 330 |
with gr.Row():
|
| 331 |
+
enable_pickscore = gr.Checkbox(label="PickScore ON", value=True, scale=1)
|
| 332 |
+
pcks_w = gr.Slider(label="PickScore weight", step=0.01, minimum=0, maximum=0.5, value=0.05, interactive=False, scale=3)
|
| 333 |
with gr.Row():
|
| 334 |
+
enable_clip = gr.Checkbox(label="CLIP ON", value=True, scale=1)
|
| 335 |
clip_w = gr.Slider(label="CLIP weight", step=0.01, minimum=0, maximum=0.1, value=0.01, interactive=False, scale=3)
|
| 336 |
|
| 337 |
submit_btn = gr.Button("Submit")
|
|
|
|
| 339 |
gr.Examples(
|
| 340 |
examples = [
|
| 341 |
"A red dog and a green cat",
|
| 342 |
+
"A blue scooter is parked near a curb in front of a green vintage car",
|
|
|
|
|
|
|
| 343 |
"A curious, orange fox and a fluffy, white rabbit, playing together in a lush, green meadow filled with yellow dandelions",
|
| 344 |
+
"An orange chair to the right of a black airplane"
|
| 345 |
+
"A toaster riding a bike",
|
| 346 |
+
"A brain riding a rocketship towards the moon",
|
| 347 |
],
|
| 348 |
inputs = [prompt]
|
| 349 |
)
|
arguments.py
CHANGED
|
@@ -39,16 +39,15 @@ def parse_args():
|
|
| 39 |
|
| 40 |
# reward losses
|
| 41 |
parser.add_argument(
|
| 42 |
-
"--
|
| 43 |
)
|
| 44 |
parser.add_argument(
|
| 45 |
"--hps_weighting", type=float, help="Weighting for HPS", default=5.0
|
| 46 |
)
|
| 47 |
parser.add_argument(
|
| 48 |
-
"--
|
| 49 |
-
default=
|
| 50 |
-
action="
|
| 51 |
-
dest="enable_imagereward",
|
| 52 |
)
|
| 53 |
parser.add_argument(
|
| 54 |
"--imagereward_weighting",
|
|
@@ -57,16 +56,15 @@ def parse_args():
|
|
| 57 |
default=1.0,
|
| 58 |
)
|
| 59 |
parser.add_argument(
|
| 60 |
-
"--
|
| 61 |
)
|
| 62 |
parser.add_argument(
|
| 63 |
"--clip_weighting", type=float, help="Weighting for CLIP", default=0.01
|
| 64 |
)
|
| 65 |
parser.add_argument(
|
| 66 |
-
"--
|
| 67 |
-
default=
|
| 68 |
-
action="
|
| 69 |
-
dest="enable_pickscore",
|
| 70 |
)
|
| 71 |
parser.add_argument(
|
| 72 |
"--pickscore_weighting",
|
|
|
|
| 39 |
|
| 40 |
# reward losses
|
| 41 |
parser.add_argument(
|
| 42 |
+
"--enable_hps", default=False, action="store_true",
|
| 43 |
)
|
| 44 |
parser.add_argument(
|
| 45 |
"--hps_weighting", type=float, help="Weighting for HPS", default=5.0
|
| 46 |
)
|
| 47 |
parser.add_argument(
|
| 48 |
+
"--enable_imagereward",
|
| 49 |
+
default=False,
|
| 50 |
+
action="store_true",
|
|
|
|
| 51 |
)
|
| 52 |
parser.add_argument(
|
| 53 |
"--imagereward_weighting",
|
|
|
|
| 56 |
default=1.0,
|
| 57 |
)
|
| 58 |
parser.add_argument(
|
| 59 |
+
"--enable_clip", default=False, action="store_true"
|
| 60 |
)
|
| 61 |
parser.add_argument(
|
| 62 |
"--clip_weighting", type=float, help="Weighting for CLIP", default=0.01
|
| 63 |
)
|
| 64 |
parser.add_argument(
|
| 65 |
+
"--enable_pickscore",
|
| 66 |
+
default=False,
|
| 67 |
+
action="store_true",
|
|
|
|
| 68 |
)
|
| 69 |
parser.add_argument(
|
| 70 |
"--pickscore_weighting",
|