Merge pull request #334 from C43H66N12O12S2/channels-last

Channels last support
This commit is contained in:
AUTOMATIC1111 2022-09-12 16:40:01 +03:00 committed by GitHub
commit 01f8de3229
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -44,6 +44,7 @@ parser.add_argument("--hide-ui-dir-config", action='store_true', help="hide dire
parser.add_argument("--ui-settings-file", type=str, help="filename to use for ui settings", default=os.path.join(script_path, 'config.json')) parser.add_argument("--ui-settings-file", type=str, help="filename to use for ui settings", default=os.path.join(script_path, 'config.json'))
parser.add_argument("--gradio-debug", action='store_true', help="launch gradio with --debug option") parser.add_argument("--gradio-debug", action='store_true', help="launch gradio with --debug option")
parser.add_argument("--gradio-auth", type=str, help='set gradio authentication like "username:password"; or comma-delimit multiple like "u1:p1,u2:p2,u3:p3"', default=None) parser.add_argument("--gradio-auth", type=str, help='set gradio authentication like "username:password"; or comma-delimit multiple like "u1:p1,u2:p2,u3:p3"', default=None)
parser.add_argument("--channelslast", action='store_true', help="Enable Channels Last Memory Type")
cmd_opts = parser.parse_args() cmd_opts = parser.parse_args()

View File

@ -49,7 +49,8 @@ def load_model_from_config(config, ckpt, verbose=False):
if len(u) > 0 and verbose: if len(u) > 0 and verbose:
print("unexpected keys:") print("unexpected keys:")
print(u) print(u)
if cmd_opts.channelslast:
model = model.to(memory_format=torch.channels_last)
model.eval() model.eval()
return model return model