mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-08-04 03:10:21 +00:00
Deduplicate extra network preview-search code
This commit is contained in:
@@ -2,6 +2,7 @@ import glob
|
||||
import os.path
|
||||
import urllib.parse
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from modules import shared
|
||||
import gradio as gr
|
||||
@@ -137,6 +138,15 @@ class ExtraNetworksPage:
|
||||
|
||||
return self.card_page.format(**args)
|
||||
|
||||
def _find_preview(self, path: str) -> Optional[str]:
|
||||
"""
|
||||
Find a preview PNG for a given path (without extension) and call link_preview on it.
|
||||
"""
|
||||
for file in [path + ".png", path + ".preview.png"]:
|
||||
if os.path.isfile(file):
|
||||
return self.link_preview(file)
|
||||
return None
|
||||
|
||||
|
||||
def intialize():
|
||||
extra_pages.clear()
|
||||
|
Reference in New Issue
Block a user