upgraded personality

This commit is contained in:
Saifeddine ALOUI 2024-02-26 19:22:54 +01:00
parent ac5d2b6df0
commit 895f54b422
3 changed files with 18 additions and 6 deletions

View File

@ -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:

View File

@ -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")

View File

@ -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())