mirror of
https://github.com/Sygil-Dev/sygil-webui.git
synced 2024-12-15 22:42:14 +03:00
Merge pull request #1247 from ZeroCool940711/dev
Added condition to check if the concepts library folder exist and if it doesn't then tell the user where to download the concepts from.
This commit is contained in:
commit
dfa02ac139
@ -44,6 +44,7 @@ def getConceptsFromPath(page, conceptPerPage, searchText= ""):
|
||||
acceptedExtensions = ('jpeg', 'jpg', "png")
|
||||
concepts = []
|
||||
|
||||
if os.path.exists(path):
|
||||
# List all folders (concepts) in the path
|
||||
folders = [f for f in os.listdir(path) if os.path.isdir(os.path.join(path, f))]
|
||||
filteredFolders = folders
|
||||
@ -51,6 +52,8 @@ def getConceptsFromPath(page, conceptPerPage, searchText= ""):
|
||||
# Filter the folders by the search text
|
||||
if searchText != "":
|
||||
filteredFolders = [f for f in folders if searchText.lower() in f.lower()]
|
||||
else:
|
||||
filteredFolders = []
|
||||
|
||||
conceptIndex = 1
|
||||
for folder in filteredFolders:
|
||||
@ -119,6 +122,7 @@ def getTotalNumberOfConcepts(searchText= ""):
|
||||
path = os.path.join(os.getcwd(), st.session_state['defaults'].general.sd_concepts_library_folder)
|
||||
concepts = []
|
||||
|
||||
if os.path.exists(path):
|
||||
# List all folders (concepts) in the path
|
||||
folders = [f for f in os.listdir(path) if os.path.isdir(os.path.join(path, f))]
|
||||
filteredFolders = folders
|
||||
@ -126,6 +130,8 @@ def getTotalNumberOfConcepts(searchText= ""):
|
||||
# Filter the folders by the search text
|
||||
if searchText != "":
|
||||
filteredFolders = [f for f in folders if searchText.lower() in f.lower()]
|
||||
else:
|
||||
filteredFolders = []
|
||||
return len(filteredFolders)
|
||||
|
||||
def layout():
|
||||
@ -159,7 +165,7 @@ def layout():
|
||||
st.write("You don't have any concepts in your library ")
|
||||
# Propose the user to go to "https://github.com/sd-webui/sd-concepts-library"
|
||||
st.markdown("To add concepts to your library, download some from the [sd-concepts-library](https://github.com/sd-webui/sd-concepts-library) \
|
||||
repository and save the content of `sd-concepts-library` into ```./models/custom/sd-concepts-library``` or just create your own concept.", unsafe_allow_html=False)
|
||||
repository and save the content of `sd-concepts-library` into ```./models/custom/sd-concepts-library``` or just create your own concepts :wink:.", unsafe_allow_html=False)
|
||||
else:
|
||||
st.write("No concepts found in the library matching your search: " + searchInput)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user