diff --git a/lollms/personality.py b/lollms/personality.py index 773591f..c8377b0 100644 --- a/lollms/personality.py +++ b/lollms/personality.py @@ -929,7 +929,7 @@ class AIPersonality: return True def add_file(self, path, client:Client, callback=None): - + output = "" if not self.callback: self.callback = callback @@ -976,7 +976,7 @@ class AIPersonality: # Convert the image to RGB mode img = img.convert("RGB") output += "## image description :\n"+ self.model.interrogate_blip([img])[0] - # output += "## image description :\n"+ self.model.qna_blip([img],"Describe this photo with details.\n")[0] + # output += "## image description :\n"+ self.model.qna_blip([img],"q:Describe this photo with as much details as possible.\na:")[0] self.full(output) self.HideBlockingMessage("Understanding image (please wait)") if self.config.debug: diff --git a/lollms/services/sd/lollms_sd.py b/lollms/services/sd/lollms_sd.py index 5854272..5da245a 100644 --- a/lollms/services/sd/lollms_sd.py +++ b/lollms/services/sd/lollms_sd.py @@ -38,7 +38,15 @@ def verify_sd(lollms_paths:LollmsPaths): shared_folder = root_dir/"shared" sd_folder = shared_folder / "auto_sd" return sd_folder.exists() - + +def download_file(url, folder_path, local_filename): + with requests.get(url, stream=True) as r: + r.raise_for_status() + with open(folder_path + '/' + local_filename, 'wb') as f: + for chunk in r.iter_content(chunk_size=8192): + f.write(chunk) + return local_filename + def install_sd(lollms_app:LollmsApplication): root_dir = lollms_app.lollms_paths.personal_path shared_folder = root_dir/"shared" @@ -50,7 +58,8 @@ def install_sd(lollms_app:LollmsApplication): sd_folder.unlink(True) 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 lollms_app.YesNoMessage("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") ASCIIColors.green("Stable diffusion installed successfully") diff --git a/lollms/utilities.py b/lollms/utilities.py index 1d3f343..d7c045f 100644 --- a/lollms/utilities.py +++ b/lollms/utilities.py @@ -184,8 +184,11 @@ def run_async(func): """ if is_asyncio_loop_running(): # We're in a running event loop, so we can call the function with asyncio.create_task - asyncio.create_task(func()) - else: + #task = asyncio.run_coroutine_threadsafe(func(), asyncio.get_event_loop()) + #task.result() + loop = asyncio.get_running_loop() + task = loop.create_task(func()) + else: # We're not in a running event loop, so we need to create one and run the function in it try: asyncio.run(func())