Spaces:
Runtime error
Runtime error
update-params (#2)
Browse files- updated default parameters (b66671b1a618a79b3a30b298e9ce73edc037a02a)
- updated description (416974aef05758221880387c47e583953f40ec71)
Files changed (2)
- app.py+33-17
- arguments.py+8-10
77 unmodified lines78798081828384858687888990919293949596979899100101102161 unmodified lines26426526626726826927028 unmodified lines2993003013023033043053063073083093103113123133143153163173183193203213223233243253261 unmodified line32832933033133233333433533633733877 unmodified linesargs.save_all_images = Trueif enable_hps is True:args.disable_hps = Falseargs.hps_weighting = hps_wif enable_imagereward is True:args.disable_imagereward = Falseargs.imagereward_weighting = imgrw_wif enable_pickscore is True:args.disable_pickscore = Falseargs.pickscore_weighting = pcks_wif enable_clip is True:args.disable_clip = Falseargs.clip_weighting = clip_wif model == "flux":args.cpu_offloading = Trueargs.enable_multi_apply = Trueargs.multi_step_model = "flux"# Check if args are the same as the loaded_model_setup except for the promptif loaded_model_setup and hasattr(loaded_model_setup[0], '__dict__'):161 unmodified lines# Create Gradio interfacetitle="# ReNO: Enhancing One-step Text-to-Image Models through Reward-based Noise Optimization"description="Enter a prompt to generate an image using ReNO. Adjust the model and parameters as needed."css="""#model-status-id{28 unmodified lineswith gr.Column():prompt = gr.Textbox(label="Prompt")with gr.Row():chosen_model = gr.Dropdown(["sd-turbo", "sdxl-turbo", "pixart", "hyper-sd", "flux"], label="Model", value="sd-turbo")seed = gr.Number(label="seed", value=0)model_status = gr.Textbox(label="model status", visible=True, elem_id="model-status-id")with gr.Row():n_iter = gr.Slider(minimum=10, maximum=100, step=10, value=10, label="Number of Iterations")learning_rate = gr.Slider(minimum=0.1, maximum=10.0, step=0.1, value=5.0, label="Learning Rate")with gr.Accordion("Advanced Settings", open=True):with gr.Column():with gr.Row():enable_hps = gr.Checkbox(label="HPS ON", value=False, scale=1)hps_w = gr.Slider(label="HPS weight", step=0.1, minimum=0.0, maximum=10.0, value=5.0, interactive=False, scale=3)with gr.Row():enable_imagereward = gr.Checkbox(label="ImageReward ON", value=False, scale=1)imgrw_w = gr.Slider(label="ImageReward weight", step=0.1, minimum=0, maximum=5.0, value=1.0, interactive=False, scale=3)with gr.Row():enable_pickscore = gr.Checkbox(label="PickScore ON", value=False, scale=1)pcks_w = gr.Slider(label="PickScore weight", step=0.01, minimum=0, maximum=5.0, value=0.05, interactive=False, scale=3)with gr.Row():enable_clip = gr.Checkbox(label="CLIP ON", value=False, scale=1)clip_w = gr.Slider(label="CLIP weight", step=0.01, minimum=0, maximum=0.1, value=0.01, interactive=False, scale=3)submit_btn = gr.Button("Submit")1 unmodified linegr.Examples(examples = ["A red dog and a green cat","A pink elephant and a grey cow","A toaster riding a bike","Dwayne Johnson depicted as a philosopher king in an academic painting by Greg Rutkowski","A curious, orange fox and a fluffy, white rabbit, playing together in a lush, green meadow filled with yellow dandelions","An epic oil painting: a red portal infront of a cityscape, a solitary figure, and a colorful sky over snowy mountains"],inputs = [prompt])77 unmodified lines78798081828384858687888990919293949596979899100101102103104105106107108109110111112113161 unmodified lines27527627727827928028128228328428528628 unmodified lines3153163173183193203213223233243253263273283293303313323333343353363373383393403413421 unmodified line34434534634734834935035135235335477 unmodified linesargs.save_all_images = Trueif enable_hps is True:args.enable_hps = Trueargs.hps_weighting = hps_welse:args.enable_hps = Falseif enable_imagereward is True:args.enable_imagereward = Trueargs.imagereward_weighting = imgrw_welse:args.enable_imagereward = Falseif enable_pickscore is True:args.enable_pickscore = Trueargs.pickscore_weighting = pcks_welse:args.enable_pickscore = Falseif enable_clip is True:args.enable_clip = Trueargs.clip_weighting = clip_welse:args.enable_clip = Falseif model == "flux":args.cpu_offloading = Trueargs.enable_multi_apply = Trueargs.multi_step_model = "flux"if model == "hyper-sd":args.cpu_offloading = True# Check if args are the same as the loaded_model_setup except for the promptif loaded_model_setup and hasattr(loaded_model_setup[0], '__dict__'):161 unmodified lines# Create Gradio interfacetitle="# ReNO: Enhancing One-step Text-to-Image Models through Reward-based Noise Optimization"description = "Enter a prompt to generate an image using ReNO. The method enhances text-to-image generation by optimizing \the initial noise using reward models as detailed in the paper. The demo uses a lower learning rate (2.5) compared to the paper's default (5.0) \for smoother trajectories - if you are looking for more dramatic changes, you can increase this value. You can also \adjust the reward weights to e.g. prioritize either prompt following (increase ImageReward) or aesthetic quality \(increase HPS/PickScore) based on your preferences.\n\nThe first time you load this demo, it will take a bit \to download and initialize the required model. Once loaded, each optimization run takes about 25-60 seconds."css="""#model-status-id{28 unmodified lineswith gr.Column():prompt = gr.Textbox(label="Prompt")with gr.Row():chosen_model = gr.Dropdown(["sd-turbo", "sdxl-turbo", "pixart", "hyper-sd", "flux"], label="Model", value="sdxl-turbo")seed = gr.Number(label="seed", value=0)model_status = gr.Textbox(label="model status", visible=True, elem_id="model-status-id")with gr.Row():n_iter = gr.Slider(minimum=10, maximum=100, step=10, value=50, label="Number of Iterations")learning_rate = gr.Slider(minimum=0.1, maximum=10.0, step=0.1, value=2.5, label="Learning Rate")with gr.Accordion("Advanced Settings", open=True):with gr.Column():with gr.Row():enable_hps = gr.Checkbox(label="HPS ON", value=True, scale=1)hps_w = gr.Slider(label="HPS weight", step=0.1, minimum=0.0, maximum=10.0, value=5.0, interactive=False, scale=3)with gr.Row():enable_imagereward = gr.Checkbox(label="ImageReward ON", value=True, scale=1)imgrw_w = gr.Slider(label="ImageReward weight", step=0.1, minimum=0, maximum=5.0, value=1.0, interactive=False, scale=3)with gr.Row():enable_pickscore = gr.Checkbox(label="PickScore ON", value=True, scale=1)pcks_w = gr.Slider(label="PickScore weight", step=0.01, minimum=0, maximum=0.5, value=0.05, interactive=False, scale=3)with gr.Row():enable_clip = gr.Checkbox(label="CLIP ON", value=True, scale=1)clip_w = gr.Slider(label="CLIP weight", step=0.01, minimum=0, maximum=0.1, value=0.01, interactive=False, scale=3)submit_btn = gr.Button("Submit")1 unmodified linegr.Examples(examples = ["A red dog and a green cat","A blue scooter is parked near a curb in front of a green vintage car","A curious, orange fox and a fluffy, white rabbit, playing together in a lush, green meadow filled with yellow dandelions","An orange chair to the right of a black airplane""A toaster riding a bike","A brain riding a rocketship towards the moon",],inputs = [prompt])
38 unmodified lines394041424344454647484950515253542 unmodified lines5758596061626364656667686970717238 unmodified lines# reward lossesparser.add_argument("--disable_hps", default=True, action="store_false", dest="enable_hps")parser.add_argument("--hps_weighting", type=float, help="Weighting for HPS", default=5.0)parser.add_argument("--disable_imagereward",default=True,action="store_false",dest="enable_imagereward",)parser.add_argument("--imagereward_weighting",2 unmodified linesdefault=1.0,)parser.add_argument("--disable_clip", default=True, action="store_false", dest="enable_clip")parser.add_argument("--clip_weighting", type=float, help="Weighting for CLIP", default=0.01)parser.add_argument("--disable_pickscore",default=True,action="store_false",dest="enable_pickscore",)parser.add_argument("--pickscore_weighting",38 unmodified lines3940414243444546474849505152532 unmodified lines56575859606162636465666768697038 unmodified lines# reward lossesparser.add_argument("--enable_hps", default=False, action="store_true",)parser.add_argument("--hps_weighting", type=float, help="Weighting for HPS", default=5.0)parser.add_argument("--enable_imagereward",default=False,action="store_true",)parser.add_argument("--imagereward_weighting",2 unmodified linesdefault=1.0,)parser.add_argument("--enable_clip", default=False, action="store_true")parser.add_argument("--clip_weighting", type=float, help="Weighting for CLIP", default=0.01)parser.add_argument("--enable_pickscore",default=False,action="store_true",)parser.add_argument("--pickscore_weighting",
app.py+33-17
arguments.py+8-10