下载地址:
SD-WebUI启动器 绘世-启动器 | 万物档案
decode_base64_to_file报错:
File "E:\BaiduNetdiskDownload\stable diffusion\sd-webui-aki-v4\extensions\sd-webui-controlnet\scripts\external_code.py", line 7, in <module>
from modules.api import api
File "E:\BaiduNetdiskDownload\stable diffusion\sd-webui-aki-v4\modules\api\api.py", line 9, in <module>
from gradio.processing_utils import decode_base64_to_file
ImportError: cannot import name 'decode_base64_to_file' from 'gradio.processing_utils'
报错2:
import gradio as gr
original_IOComponent_init = gr.components.IOComponent.__init__
4.*版本报错, gradio-3.41.2-py3-none-any.whl 不报错
报错2:
File "E:\BaiduNetdiskDownload\stable diffusion\sd-webui-aki-v4\modules\api\models.py", line 96, in generate_model
DynamicModel.__config__.allow_population_by_field_name = True
File "D:\ProgramData\miniconda3\envs\pysd\lib\site-packages\pydantic\_internal\_model_construction.py", line 215, in __getattr__
raise AttributeError(item)
AttributeError: __config__
报错的gradio版本:
pip install gradio-3.41.2-py3-none-any.whl
sd-webui-aki-v4文章来源:https://www.toymoban.com/news/detail-848080.html
from gradio.processing_utils import decode_base64_to_image文章来源地址https://www.toymoban.com/news/detail-848080.html
def decode_base64_to_image(encoding: str) -> Image.Image:
image_encoded = extract_base64_data(encoding)
img = Image.open(BytesIO(base64.b64decode(image_encoded)))
try:
if hasattr(ImageOps, "exif_transpose"):
img = ImageOps.exif_transpose(img)
except Exception:
log.warning(
"Failed to transpose image %s based on EXIF data.",
img,
exc_info=True,
)
return img
python 实现代码:
def decode_base64_to_image(encoding):
if encoding.startswith("data:image/"):
encoding = encoding.split(";")[1].split(",")[1]
try:
image = Image.open(BytesIO(base64.b64decode(encoding)))
return image
except Exception as err:
raise HTTPException(status_code=500, detail="Invalid encoded image")
def encode_pil_to_base64(image):
with io.BytesIO() as output_bytes:
if opts.samples_format.lower() == 'png':
use_metadata = False
metadata = PngImagePlugin.PngInfo()
for key, value in image.info.items():
if isinstance(key, str) and isinstance(value, str):
metadata.add_text(key, value)
use_metadata = True
image.save(output_bytes, format="PNG", pnginfo=(metadata if use_metadata else None), quality=opts.jpeg_quality)
elif opts.samples_format.lower() in ("jpg", "jpeg", "webp"):
parameters = image.info.get('parameters', None)
exif_bytes = piexif.dump({
"Exif": { piexif.ExifIFD.UserComment: piexif.helper.UserComment.dump(parameters or "", encoding="unicode") }
})
if opts.samples_format.lower() in ("jpg", "jpeg"):
image.save(output_bytes, format="JPEG", exif = exif_bytes, quality=opts.jpeg_quality)
else:
image.save(output_bytes, format="WEBP", exif = exif_bytes, quality=opts.jpeg_quality)
else:
raise HTTPException(status_code=500, detail="Invalid image format")
bytes_data = output_bytes.getvalue()
return base64.b64encode(bytes_data)
到了这里,关于aigc 启动器 sd-webui-aki-v4 decode_base64_to_file的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!