|
| 1 | + |
| 2 | +from modules.ui.BaseConfigListView import BaseConfigListView |
| 3 | +from modules.util import path_util |
| 4 | + |
| 5 | +import customtkinter as ctk |
| 6 | + |
| 7 | + |
| 8 | +class BaseAdditionalEmbeddingsTabView(BaseConfigListView): |
| 9 | + |
| 10 | + def refresh_ui(self): |
| 11 | + if self.element_list is not None: |
| 12 | + self._destroy_frame(self.element_list) |
| 13 | + self.element_list = None |
| 14 | + self.widgets_initialized = False |
| 15 | + self._create_element_list() |
| 16 | + |
| 17 | + def open_element_window(self, i, ui_state) -> ctk.CTkToplevel: |
| 18 | + pass |
| 19 | + |
| 20 | + |
| 21 | +class BaseEmbeddingWidgetView: |
| 22 | + |
| 23 | + def __init__(self, components): |
| 24 | + self.components = components |
| 25 | + |
| 26 | + def build_content(self, top_frame, bottom_frame, ui_state, i, save_command, remove_command, clone_command, controller): |
| 27 | + self.ui_state = ui_state |
| 28 | + self.i = i |
| 29 | + self.save_command = save_command |
| 30 | + |
| 31 | + # close button |
| 32 | + self.components.colored_icon_button(top_frame, 0, 0, "X", "#C00000", lambda: remove_command(self.i)) |
| 33 | + |
| 34 | + # clone button |
| 35 | + self.components.colored_icon_button(top_frame, 0, 1, "+", "#00C000", lambda: clone_command(self.i, controller.randomize_uuid), padx=5) |
| 36 | + |
| 37 | + # embedding model names |
| 38 | + self.components.label(top_frame, 0, 2, "base embedding:", |
| 39 | + tooltip="The base embedding to train on. Leave empty to create a new embedding") |
| 40 | + self.components.path_entry( |
| 41 | + top_frame, 0, 3, self.ui_state, "model_name", |
| 42 | + mode="file", path_modifier=path_util.json_path_modifier |
| 43 | + ) |
| 44 | + |
| 45 | + # placeholder |
| 46 | + self.components.label(top_frame, 0, 4, "placeholder:", |
| 47 | + tooltip="The placeholder used when using the embedding in a prompt") |
| 48 | + self.components.entry(top_frame, 0, 5, self.ui_state, "placeholder") |
| 49 | + |
| 50 | + # token count |
| 51 | + self.components.label(top_frame, 0, 6, "token count:", |
| 52 | + tooltip="The token count used when creating a new embedding. Leave empty to auto detect from the initial embedding text.") |
| 53 | + self.components.entry(top_frame, 0, 7, self.ui_state, "token_count", width=40) |
| 54 | + |
| 55 | + # trainable |
| 56 | + self.components.label(bottom_frame, 0, 0, "train:") |
| 57 | + self.components.switch(bottom_frame, 0, 1, self.ui_state, "train", command=save_command, width=40) |
| 58 | + |
| 59 | + # output embedding |
| 60 | + self.components.label(bottom_frame, 0, 2, "output embedding:", |
| 61 | + tooltip="Output embeddings are calculated at the output of the text encoder, not the input. This can improve results for larger text encoders and lower VRAM usage.") |
| 62 | + self.components.switch(bottom_frame, 0, 3, self.ui_state, "is_output_embedding", width=40) |
| 63 | + |
| 64 | + # stop training after |
| 65 | + self.components.label(bottom_frame, 0, 4, "stop training after:", |
| 66 | + tooltip="When to stop training the embedding") |
| 67 | + self.components.time_entry(bottom_frame, 0, 5, self.ui_state, "stop_training_after", "stop_training_after_unit") |
| 68 | + |
| 69 | + # initial embedding text |
| 70 | + self.components.label(bottom_frame, 0, 6, "initial embedding text:", |
| 71 | + tooltip="The initial embedding text used when creating a new embedding") |
| 72 | + self.components.entry(bottom_frame, 0, 7, self.ui_state, "initial_embedding_text") |
| 73 | + |
| 74 | + def configure_element(self): |
| 75 | + pass |
0 commit comments