修改 Stable Diffusion 使 api 接口增加模型参数

修改 Stable Diffusion 使 api 接口增加模型参数

    正在检查是否收录...

 参考:https://zhuanlan.zhihu.com/p/644545784

1、修改 modules/api/models.py 中的 StableDiffusionTxt2ImgProcessingAPI 增加模型名称

StableDiffusionTxt2ImgProcessingAPI = PydanticModelGenerator( "StableDiffusionProcessingTxt2Img", StableDiffusionProcessingTxt2Img, [ {"key": "sampler_index", "type": str, "default": "Euler"}, {"key": "script_name", "type": str, "default": None}, {"key": "script_args", "type": list, "default": []}, {"key": "send_images", "type": bool, "default": True}, {"key": "save_images", "type": bool, "default": False}, {"key": "alwayson_scripts", "type": dict, "default": {}}, {"key": "model_name", "type": str, "default": None}, ] ).generate_model()

 2、修改 modules/api/api.py 中 text2imgapi 代码:

...... from modules import sd_samplers, deepbooru, sd_hijack, images, scripts, ui, \ postprocessing, errors, restart, shared_items, sd_models from modules.api import models from modules.shared import opts, models_path ...... def text2imgapi(self, txt2imgreq: models.StableDiffusionTxt2ImgProcessingAPI): ...... with self.queue_lock: if txt2imgreq.model_name is not None: checkpoint_info = sd_models.CheckpointInfo(os.path.join(models_path, 'Stable-diffusion', txt2imgreq.model_name)) sd_models.reload_model_weights(info = checkpoint_info) with closing(StableDiffusionProcessingTxt2Img(sd_model=shared.sd_model, **args)) as p: ......

 3、修改 modules/processing.py 中的 StableDiffusionProcessingTxt2Img,增加模型名称接收

@dataclass(repr=False) class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing): enable_hr: bool = False denoising_strength: float = 0.75 firstphase_width: int = 0 firstphase_height: int = 0 hr_scale: float = 2.0 hr_upscaler: str = None hr_second_pass_steps: int = 0 hr_resize_x: int = 0 hr_resize_y: int = 0 hr_checkpoint_name: str = None hr_sampler_name: str = None hr_prompt: str = '' hr_negative_prompt: str = '' model_name: str = None

codediffusionapistablediffusionscriptsharepromptgeneratorelourl
  • 本文作者:李琛
  • 本文链接: https://wapzz.net/post-491.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
本站部分内容来源于网络转载,仅供学习交流使用。如涉及版权问题,请及时联系我们,我们将第一时间处理。
文章很赞!支持一下吧 还没有人为TA充电
为TA充电
还没有人为TA充电
0
  • 支付宝打赏
    支付宝扫一扫
  • 微信打赏
    微信扫一扫
感谢支持
文章很赞!支持一下吧
关于作者
2.3W+
5
0
1
WAP站长官方

大模型幻觉率排行:GPT-4 3%最低,谷歌Palm竟然高达27.2%

上一篇

阿里发布自研夸克大模型:整体能力已超GPT-3.5

下一篇
  • 复制图片
按住ctrl可打开默认菜单