jhj0517 commited on
Commit ·
3f75a4f
1
Parent(s): b2fcecf
Add arg parses
Browse filesFiles changed (2)
- app.py+30-3
- modules/utils/helper.py+15-1
1234567862 unmodified lines717273747576773 unmodified lines8182838485868788import gradio as grfrom gradio_i18n import Translate, gettext as _from modules.live_portrait.live_portrait_inferencer import LivePortraitInferencerfrom modules.utils.paths import *class App:62 unmodified linesinputs=params + opt_in_features_params,outputs=img_out)self.app.launch(inbrowser=True)@staticmethoddef open_folder(folder_path: str):3 unmodified linesos.system(f"start {folder_path}")app = App()app.launch()1234567891062 unmodified lines7374757677787980818283848586873 unmodified lines919293949596979899100101102103104105106107108109110111112113114115import argparseimport gradio as grfrom gradio_i18n import Translate, gettext as _from modules.live_portrait.live_portrait_inferencer import LivePortraitInferencerfrom modules.utils.paths import *from modules.utils.helper import str2boolclass App:62 unmodified linesinputs=params + opt_in_features_params,outputs=img_out)gradio_launch_args = {"inbrowser": self.args.inbrowser,"share": self.args.share,"server_name": self.args.server_name,"server_port": self.args.server_port,"root_path": self.args.root_path,"auth": (self.args.username, self.args.password) if self.args.username and self.args.password else None,}self.app.queue().launch(**gradio_launch_args)@staticmethoddef open_folder(folder_path: str):3 unmodified linesos.system(f"start {folder_path}")if __name__ == "__main__":parser = argparse.ArgumentParser()parser.add_argument('--share', type=str2bool, default=False, nargs='?', const=True, help='Gradio share value')parser.add_argument('--inbrowser', type=str2bool, default=True, nargs='?', const=True,help='Whether to automatically starts on the browser or not')parser.add_argument('--server_name', type=str, default=None, help='Gradio server host')parser.add_argument('--server_port', type=int, default=None, help='Gradio server port')parser.add_argument('--root_path', type=str, default=None, help='Gradio root path')parser.add_argument('--username', type=str, default=None, help='Gradio authentication username')parser.add_argument('--password', type=str, default=None, help='Gradio authentication password')parser.add_argument('--model_dir', type=str, default=MODELS_DIR,help='Directory path of the LivePortrait models')parser.add_argument('--output_dir', type=str, default=OUTPUTS_DIR,help='Directory path of the outputs')_args = parser.parse_args()app = App(args=_args)app.launch()
8 unmodified lines91011121314111 unmodified lines1261271281291301318 unmodified linesimport cv2import torchimport yamlfrom rich.console import Consolefrom collections import OrderedDict111 unmodified linesdef load_yaml(file_path):with open(file_path, 'r') as file:data = yaml.safe_load(file)return data8 unmodified lines910111213141516111 unmodified lines1281291301311321331341351361371381391401411421431441458 unmodified linesimport cv2import torchimport yamlimport argparseimport localefrom rich.console import Consolefrom collections import OrderedDict111 unmodified linesdef load_yaml(file_path):encoding = locale.getpreferredencoding(False)with open(file_path, 'r', encoding=encoding) as file:data = yaml.safe_load(file)return datadef str2bool(v):if isinstance(v, bool):return vif v.lower() in ('yes', 'true', 't', 'y', '1'):return Trueelif v.lower() in ('no', 'false', 'f', 'n', '0'):return Falseelse:raise argparse.ArgumentTypeError('Boolean value expected.')
app.py+30-3
modules/utils/helper.py+15-1