mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-23 22:42:32 +00:00
upgraded sd
This commit is contained in:
parent
7e3757148a
commit
33297e81c7
@ -128,6 +128,9 @@ class LollmsApplication(LoLLMsCom):
|
||||
self.mount_personalities()
|
||||
self.mount_extensions()
|
||||
|
||||
def add_discussion_tto_skills_library(self, client:Client):
|
||||
pass
|
||||
|
||||
def get_uploads_path(self, client_id):
|
||||
return self.lollms_paths.personal_uploads_path
|
||||
|
||||
|
@ -598,6 +598,8 @@ class Discussion:
|
||||
self.discussion_skills_folder.mkdir(exist_ok=True)
|
||||
self.discussion_rag_folder.mkdir(exist_ok=True)
|
||||
self.messages = self.get_messages()
|
||||
self.skills_db = self.discussion_skills_folder/"skills_db.db"
|
||||
|
||||
if len(self.messages)>0:
|
||||
self.current_message = self.messages[-1]
|
||||
|
||||
|
@ -58,7 +58,7 @@ def start_sd():
|
||||
|
||||
lollmsElfServer.ShowBlockingMessage("Starting SD api server\nPlease stand by")
|
||||
from lollms.services.sd.lollms_sd import get_sd
|
||||
lollmsElfServer.sd = get_sd(lollmsElfServer.lollms_paths)
|
||||
lollmsElfServer.sd = get_sd(lollmsElfServer.lollms_paths)(lollmsElfServer, lollmsElfServer.personality.name if lollmsElfServer.personality is not None else "Artbot")
|
||||
ASCIIColors.success("Done")
|
||||
lollmsElfServer.HideBlockingMessage()
|
||||
return {"status":True}
|
||||
|
@ -28,7 +28,7 @@ lollmsElfServer:LOLLMSWebUI = LOLLMSWebUI.get_instance()
|
||||
class DiscussionInfos(BaseModel):
|
||||
client_id: str
|
||||
|
||||
@router.get("/add_discussion_to_skills_library")
|
||||
@router.post("/add_discussion_to_skills_library")
|
||||
def add_discussion_to_skills_library(discussionInfos:DiscussionInfos):
|
||||
client = lollmsElfServer.session.get_client(discussionInfos.client_id)
|
||||
lollmsElfServer.add_discussion_tto_skills_library(client)
|
||||
|
@ -28,7 +28,7 @@ from typing import List, Dict, Any
|
||||
|
||||
from ascii_colors import ASCIIColors, trace_exception
|
||||
from lollms.paths import LollmsPaths
|
||||
from lollms.utilities import git_pull, show_yes_no_dialog
|
||||
from lollms.utilities import git_pull, show_yes_no_dialog, run_script_in_env, create_conda_env
|
||||
import subprocess
|
||||
import shutil
|
||||
from tqdm import tqdm
|
||||
@ -62,29 +62,23 @@ def install_sd(lollms_app:LollmsApplication):
|
||||
shared_folder = root_dir/"shared"
|
||||
sd_folder = shared_folder / "auto_sd"
|
||||
if sd_folder.exists():
|
||||
if not show_yes_no_dialog("warning!","I have detected that there is a previous installation of stable diffusion.\nShould I remove it and continue installing?"):
|
||||
if show_yes_no_dialog("warning!","I have detected that there is a previous installation of stable diffusion.\nShould I remove it and continue installing?"):
|
||||
shutil.rmtree(sd_folder)
|
||||
elif show_yes_no_dialog("warning!","Continue installation?"):
|
||||
ASCIIColors.cyan("Installing autosd conda environment with python 3.10")
|
||||
create_conda_env("autosd","3.10")
|
||||
ASCIIColors.cyan("Done")
|
||||
return
|
||||
else:
|
||||
shutil.rmtree(sd_folder)
|
||||
return
|
||||
|
||||
subprocess.run(["git", "clone", "https://github.com/ParisNeo/stable-diffusion-webui.git", str(sd_folder)])
|
||||
subprocess.run(["git", "clone", "https://github.com/ParisNeo/SD-CN-Animation.git", str(sd_folder/"extensions/SD-CN-Animation")])
|
||||
if show_yes_no_dialog("warning!","Do you want to install a model from civitai?\nIsuggest dreamshaper xl."):
|
||||
download_file("https://civitai.com/api/download/models/351306", sd_folder/"models/Stable-diffusion","dreamshaperXL_v21TurboDPMSDE.safetensors")
|
||||
# Get the path to the parent directory, which should be the 'bin' directory
|
||||
if platform.system()=="Windows":
|
||||
bin_dir = Path(sys.executable).parent.parent/"miniconda3/condabin"
|
||||
else:
|
||||
bin_dir = Path(sys.executable).parent.parent/"miniconda3/bin"
|
||||
if bin_dir.exists():
|
||||
conda_dir = str(bin_dir/ "conda")
|
||||
# For Windows, the activate script has a '.bat' extension
|
||||
if os.name == 'nt':
|
||||
conda_dir += '.bat'
|
||||
|
||||
result = subprocess.run([conda_dir, "create","--name","autosd","-y","python==3.10"])
|
||||
else:
|
||||
import conda.cli
|
||||
conda.cli.main("create","--name","autosd","-y","python==3.10")
|
||||
create_conda_env("autosd","3.10")
|
||||
|
||||
lollms_app.sd = LollmsSD(lollms_app)
|
||||
ASCIIColors.green("Stable diffusion installed successfully")
|
||||
|
||||
|
||||
@ -293,9 +287,11 @@ class LollmsSD:
|
||||
# process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
|
||||
|
||||
if share:
|
||||
subprocess.Popen(str(script_path) +" --share", cwd=self.sd_folder)
|
||||
run_script_in_env("autosd", script_path +" --share", cwd=self.sd_folder)
|
||||
# subprocess.Popen("conda activate " + str(script_path) +" --share", cwd=self.sd_folder)
|
||||
else:
|
||||
subprocess.Popen(script_path, cwd=self.sd_folder)
|
||||
run_script_in_env("autosd", script_path, cwd=self.sd_folder)
|
||||
# subprocess.Popen(script_path, cwd=self.sd_folder)
|
||||
else:
|
||||
ASCIIColors.info("Running on linux/MacOs")
|
||||
script_path = str(self.sd_folder / "lollms_sd.sh")
|
||||
@ -303,9 +299,10 @@ class LollmsSD:
|
||||
ASCIIColors.info(f"sd path: {self.sd_folder}")
|
||||
|
||||
if share:
|
||||
subprocess.Popen(['bash', script_path,"--share"], cwd=self.sd_folder)
|
||||
run_script_in_env("autosd","bash " + script_path +" --share", cwd=self.sd_folder)
|
||||
# subprocess.Popen("conda activate " + str(script_path) +" --share", cwd=self.sd_folder)
|
||||
else:
|
||||
subprocess.Popen(['bash', script_path], cwd=self.sd_folder)
|
||||
run_script_in_env("autosd","bash " + script_path, cwd=self.sd_folder)
|
||||
ASCIIColors.info("Process done")
|
||||
ASCIIColors.success("Launching Auto1111's SD succeeded")
|
||||
|
||||
|
@ -37,6 +37,30 @@ import sys
|
||||
import git
|
||||
|
||||
import mimetypes
|
||||
import subprocess
|
||||
from conda.cli.python_api import run_command, Commands
|
||||
|
||||
def create_conda_env(env_name, python_version):
|
||||
# Create a new Conda environment with the specified Python version
|
||||
run_command(Commands.CREATE, "-n", env_name, f"python={python_version}")
|
||||
|
||||
def run_python_script_in_env(env_name, script_path, cwd=None):
|
||||
# Set the current working directory if provided, otherwise use the current directory
|
||||
if cwd is None:
|
||||
cwd = os.getcwd()
|
||||
|
||||
# Activate the Conda environment
|
||||
run_command(Commands.RUN, "-n", env_name, "python", str(script_path), cwd=cwd)
|
||||
|
||||
def run_script_in_env(env_name, script_path, cwd=None):
|
||||
# Set the current working directory if provided, otherwise use the current directory
|
||||
if cwd is None:
|
||||
cwd = os.path.dirname(script_path)
|
||||
|
||||
# Activate the Conda environment
|
||||
subprocess.Popen(f'conda activate {env_name} && {script_path}', shell=True, cwd=cwd)
|
||||
#run_command(Commands.RUN, "-n", env_name, str(script_path), cwd=cwd)
|
||||
|
||||
|
||||
def process_ai_output(output, images, output_folder):
|
||||
if not PackageManager.check_package_installed("cv2"):
|
||||
|
Loading…
Reference in New Issue
Block a user