load_config.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import json
  2. import os
  3. default_config = {
  4. "model": {
  5. "text_use_gpu": True,
  6. "text_use_small": True,
  7. "coarse_use_gpu": True,
  8. "coarse_use_small": True,
  9. "fine_use_gpu": True,
  10. "fine_use_small": True,
  11. "codec_use_gpu": True,
  12. },
  13. "gradio_interface_options": {
  14. "inline": False,
  15. "inbrowser": True,
  16. "share": False,
  17. "debug": False,
  18. "max_threads": 40,
  19. "auth": None,
  20. "auth_message": None,
  21. "prevent_thread_lock": False,
  22. "show_error": False,
  23. # "server_name": "0.0.0.0",
  24. "server_name": "127.0.0.1",
  25. "server_port": 7770,
  26. # "show_tips": False, # DEPRECATED
  27. "height": 500,
  28. "width": "100%",
  29. "favicon_path": None,
  30. "ssl_keyfile": None,
  31. "ssl_certfile": None,
  32. "ssl_keyfile_password": None,
  33. "ssl_verify": True,
  34. "quiet": True,
  35. "show_api": True,
  36. "_frontend": True,
  37. },
  38. "extensions": {
  39. "disabled": [],
  40. },
  41. }
  42. def load_config():
  43. if os.path.exists("config.json"):
  44. with open("config.json", "r") as infile:
  45. return json.load(infile)
  46. else:
  47. print("Config file not found. Creating default config.")
  48. with open("config.json", "w") as outfile:
  49. json.dump(default_config, outfile, indent=2)
  50. return default_config