fix meta data loading problem
parent
2d0c143370
commit
e863506ed1
|
|
@ -1,9 +1,11 @@
|
|||
psutil
|
||||
openai
|
||||
numba
|
||||
BeautifulSoup4
|
||||
gpt_index==0.4.24
|
||||
langchain==0.0.132
|
||||
gradio_client==0.5.0
|
||||
requests==2.31.0
|
||||
urllib3==2.0.6
|
||||
tqdm==4.64.0
|
||||
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ class MiaoShouAssistant(object):
|
|||
with gr.Column():
|
||||
|
||||
btn_load_model = gr.HTML(
|
||||
value=f'<div class="lg secondary gradio-button svelte-1ipelgc" style="text-align: center;"' \
|
||||
value=f'<div class="lg secondary gradio-button svelte-cmf5ev" style="text-align: center;"' \
|
||||
f'onclick="return selectCheckpoint()">Load Model</div>',
|
||||
visible=True)
|
||||
with gr.Column():
|
||||
|
|
@ -364,7 +364,7 @@ class MiaoShouAssistant(object):
|
|||
dwn_button = gr.Button(value='Download',
|
||||
visible=is_civitai_model_source_active, elem_id='ms_dwn_button')
|
||||
open_url_in_browser_newtab_button = gr.HTML(
|
||||
value='<div class="lg secondary gradio-button svelte-1ipelgc" style="text-align: center;">'
|
||||
value='<div class="lg secondary gradio-button svelte-cmf5ev" style="text-align: center;">'
|
||||
'<a style="text-align: center;" href="http://www.liandange.com/models" '
|
||||
'target="_blank">Download</a></div>',
|
||||
visible=not is_civitai_model_source_active)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class MiaoshouPrelude(metaclass=MiaoshouSingleton):
|
|||
def _init_constants(self) -> None:
|
||||
self._api_url = {
|
||||
"civitai.com": "https://model-share.com/v1/models",
|
||||
"liandange.com": "https://model-api.liandange.com/model/api/models",
|
||||
"liandange.com": "http://api.miaoshouai.com/model/api/models",
|
||||
}
|
||||
self._ext_folder = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", ".."))
|
||||
self._setting_file = os.path.join(self.ext_folder, "configs", "settings.json")
|
||||
|
|
|
|||
|
|
@ -23,8 +23,9 @@ import time
|
|||
import torch
|
||||
import typing as t
|
||||
from bs4 import BeautifulSoup
|
||||
from PIL import Image
|
||||
from gpt_index import SimpleDirectoryReader, GPTListIndex, GPTSimpleVectorIndex, LLMPredictor, PromptHelper
|
||||
from modules import shared, sd_hijack, sd_samplers, processing
|
||||
from modules import shared, sd_hijack, sd_samplers, processing, images
|
||||
from modules.sd_models import CheckpointInfo
|
||||
from numba import cuda
|
||||
|
||||
|
|
@ -796,21 +797,6 @@ class MiaoshouRuntime(object):
|
|||
for mv in m['modelVersions']:
|
||||
for img in mv['images']:
|
||||
if img['url'] == cover_url:
|
||||
if img['meta'] is not None and img['meta'] != '':
|
||||
try:
|
||||
meta = img['meta']
|
||||
generation_info += f"{meta['prompt']}\n"
|
||||
if meta['negativePrompt'] is not None:
|
||||
generation_info += f"Negative prompt: {meta['negativePrompt']}\n"
|
||||
generation_info += f"Steps: {meta['steps']}, Sampler: {meta['sampler']}, "
|
||||
generation_info += f"CFG scale: {meta['cfgScale']}, Seed: {meta['seed']}, Size: {meta['Size']},"
|
||||
if meta['Model hash'] is not None:
|
||||
generation_info += f"Model hash: {meta['Model hash']}"
|
||||
|
||||
except Exception as e:
|
||||
self.logger.info(f"generation_info error:{str(e)}")
|
||||
pass
|
||||
|
||||
if not os.path.exists(self.prelude.cache_folder):
|
||||
os.mkdir(self.prelude.cache_folder)
|
||||
|
||||
|
|
@ -819,15 +805,19 @@ class MiaoshouRuntime(object):
|
|||
elif self.my_model_source == 'liandange.com':
|
||||
fname = os.path.join(self.prelude.cache_folder, cover_url.split('?')[0].split('/')[-1])
|
||||
|
||||
break
|
||||
if fname is not None and not os.path.exists(fname):
|
||||
if self.my_model_source == 'liandange.com':
|
||||
cover_url = soup.findAll('img')[0]['src'].replace('/w/150', '/w/450')
|
||||
r = requests.get(cover_url, timeout=30, stream=True)
|
||||
r.raw.decode_content = True
|
||||
with open(fname, 'wb') as f:
|
||||
shutil.copyfileobj(r.raw, f)
|
||||
|
||||
if fname is not None and not os.path.exists(fname):
|
||||
if self.my_model_source == 'liandange.com':
|
||||
cover_url = soup.findAll('img')[0]['src'].replace('/w/150', '/w/450')
|
||||
r = requests.get(cover_url, timeout=30, stream=True)
|
||||
r.raw.decode_content = True
|
||||
with open(fname, 'wb') as f:
|
||||
shutil.copyfileobj(r.raw, f)
|
||||
if os.path.exists(fname):
|
||||
c_image = Image.open(fname)
|
||||
html, generation_info, html2 = modules.extras.run_pnginfo(c_image)
|
||||
|
||||
break
|
||||
|
||||
return gr.Button.update(visible=True), gr.Text.update(value=generation_info), gr.Image.update(value=fname)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue