remove underscores from function names in #8366

remove LRU from #8366 because I don't know why it's there
This commit is contained in:
AUTOMATIC 2023-03-11 15:27:42 +03:00
parent c239b3d7a8
commit ce68ab8d0d
5 changed files with 11 additions and 13 deletions

View File

@ -18,8 +18,8 @@ class ExtraNetworksPageLora(ui_extra_networks.ExtraNetworksPage):
yield { yield {
"name": name, "name": name,
"filename": path, "filename": path,
"preview": self._find_preview(path), "preview": self.find_preview(path),
"description": self._find_description(path), "description": self.find_description(path),
"search_term": self.search_terms_from_path(lora_on_disk.filename), "search_term": self.search_terms_from_path(lora_on_disk.filename),
"prompt": json.dumps(f"<lora:{name}:") + " + opts.extra_networks_default_multiplier + " + json.dumps(">"), "prompt": json.dumps(f"<lora:{name}:") + " + opts.extra_networks_default_multiplier + " + json.dumps(">"),
"local_preview": path + ".png", "local_preview": path + ".png",

View File

@ -1,9 +1,7 @@
import glob import glob
import os.path import os.path
import urllib.parse import urllib.parse
from functools import lru_cache
from pathlib import Path from pathlib import Path
from typing import Optional
from modules import shared from modules import shared
import gradio as gr import gradio as gr
@ -140,17 +138,17 @@ class ExtraNetworksPage:
return self.card_page.format(**args) return self.card_page.format(**args)
def _find_preview(self, path: str) -> Optional[str]: def find_preview(self, path):
""" """
Find a preview PNG for a given path (without extension) and call link_preview on it. Find a preview PNG for a given path (without extension) and call link_preview on it.
""" """
for file in [path + ".png", path + ".preview.png"]: for file in [path + ".png", path + ".preview.png"]:
if os.path.isfile(file): if os.path.isfile(file):
return self.link_preview(file) return self.link_preview(file)
return None return None
@lru_cache(maxsize=512) def find_description(self, path):
def _find_description(self, path: str) -> Optional[str]:
""" """
Find and read a description file for a given path (without extension). Find and read a description file for a given path (without extension).
""" """

View File

@ -19,8 +19,8 @@ class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
yield { yield {
"name": checkpoint.name_for_extra, "name": checkpoint.name_for_extra,
"filename": path, "filename": path,
"preview": self._find_preview(path), "preview": self.find_preview(path),
"description": self._find_description(path), "description": self.find_description(path),
"search_term": self.search_terms_from_path(checkpoint.filename) + " " + (checkpoint.sha256 or ""), "search_term": self.search_terms_from_path(checkpoint.filename) + " " + (checkpoint.sha256 or ""),
"onclick": '"' + html.escape(f"""return selectCheckpoint({json.dumps(name)})""") + '"', "onclick": '"' + html.escape(f"""return selectCheckpoint({json.dumps(name)})""") + '"',
"local_preview": path + ".png", "local_preview": path + ".png",

View File

@ -18,8 +18,8 @@ class ExtraNetworksPageHypernetworks(ui_extra_networks.ExtraNetworksPage):
yield { yield {
"name": name, "name": name,
"filename": path, "filename": path,
"preview": self._find_preview(path), "preview": self.find_preview(path),
"description": self._find_description(path), "description": self.find_description(path),
"search_term": self.search_terms_from_path(path), "search_term": self.search_terms_from_path(path),
"prompt": json.dumps(f"<hypernet:{name}:") + " + opts.extra_networks_default_multiplier + " + json.dumps(">"), "prompt": json.dumps(f"<hypernet:{name}:") + " + opts.extra_networks_default_multiplier + " + json.dumps(">"),
"local_preview": path + ".png", "local_preview": path + ".png",

View File

@ -18,8 +18,8 @@ class ExtraNetworksPageTextualInversion(ui_extra_networks.ExtraNetworksPage):
yield { yield {
"name": embedding.name, "name": embedding.name,
"filename": embedding.filename, "filename": embedding.filename,
"preview": self._find_preview(path), "preview": self.find_preview(path),
"description": self._find_description(path), "description": self.find_description(path),
"search_term": self.search_terms_from_path(embedding.filename), "search_term": self.search_terms_from_path(embedding.filename),
"prompt": json.dumps(embedding.name), "prompt": json.dumps(embedding.name),
"local_preview": path + ".preview.png", "local_preview": path + ".preview.png",