shared.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import sys
  2. import gradio as gr
  3. from modules import shared_cmd_options, shared_gradio_themes, options, shared_items
  4. from modules.paths_internal import models_path, script_path, data_path, sd_configs_path, sd_default_config, sd_model_file, default_sd_model_file, extensions_dir, extensions_builtin_dir # noqa: F401
  5. from ldm.models.diffusion.ddpm import LatentDiffusion
  6. from modules import util
  7. cmd_opts = shared_cmd_options.cmd_opts
  8. parser = shared_cmd_options.parser
  9. batch_cond_uncond = cmd_opts.always_batch_cond_uncond or not (cmd_opts.lowvram or cmd_opts.medvram)
  10. parallel_processing_allowed = not cmd_opts.lowvram and not cmd_opts.medvram
  11. styles_filename = cmd_opts.styles_file
  12. config_filename = cmd_opts.ui_settings_file
  13. hide_dirs = {"visible": not cmd_opts.hide_ui_dir_config}
  14. demo = None
  15. device = None
  16. weight_load_location = None
  17. xformers_available = False
  18. hypernetworks = {}
  19. loaded_hypernetworks = []
  20. state = None
  21. prompt_styles = None
  22. interrogator = None
  23. face_restorers = []
  24. options_templates = None
  25. opts = None
  26. sd_model: LatentDiffusion = None
  27. settings_components = None
  28. """assinged from ui.py, a mapping on setting names to gradio components repsponsible for those settings"""
  29. tab_names = []
  30. latent_upscale_default_mode = "Latent"
  31. latent_upscale_modes = {
  32. "Latent": {"mode": "bilinear", "antialias": False},
  33. "Latent (antialiased)": {"mode": "bilinear", "antialias": True},
  34. "Latent (bicubic)": {"mode": "bicubic", "antialias": False},
  35. "Latent (bicubic antialiased)": {"mode": "bicubic", "antialias": True},
  36. "Latent (nearest)": {"mode": "nearest", "antialias": False},
  37. "Latent (nearest-exact)": {"mode": "nearest-exact", "antialias": False},
  38. }
  39. sd_upscalers = []
  40. clip_model = None
  41. progress_print_out = sys.stdout
  42. gradio_theme = gr.themes.Base()
  43. total_tqdm = None
  44. mem_mon = None
  45. options_section = options.options_section
  46. OptionInfo = options.OptionInfo
  47. OptionHTML = options.OptionHTML
  48. natural_sort_key = util.natural_sort_key
  49. listfiles = util.listfiles
  50. html_path = util.html_path
  51. html = util.html
  52. walk_files = util.walk_files
  53. ldm_print = util.ldm_print
  54. reload_gradio_theme = shared_gradio_themes.reload_gradio_theme
  55. list_checkpoint_tiles = shared_items.list_checkpoint_tiles
  56. refresh_checkpoints = shared_items.refresh_checkpoints
  57. list_samplers = shared_items.list_samplers
  58. reload_hypernetworks = shared_items.reload_hypernetworks