mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-05-06 11:59:06 +08:00
dev
This commit is contained in:
parent
504abc5ad8
commit
89cea797b8
@ -490,11 +490,16 @@ class Api:
|
||||
return models.TextToImageResponse(images=b64images, parameters=vars(txt2imgreq), info=processed.js())
|
||||
|
||||
def img2imgapi(self, img2imgreq: models.StableDiffusionImg2ImgProcessingAPI):
|
||||
from modules.env_to_yaml import get_env_var
|
||||
from modules.s3 import s3_client
|
||||
from modules.download_from_s3 import get_photo_base64
|
||||
|
||||
task_id = img2imgreq.force_task_id or create_task_id("img2img")
|
||||
|
||||
init_images = img2imgreq.init_images
|
||||
if init_images is None:
|
||||
|
||||
if img2imgreq.init_images is None:
|
||||
raise HTTPException(status_code=404, detail="Init image not found")
|
||||
init_images = [get_photo_base64(s3_url=img2imgreq.init_images)]
|
||||
|
||||
mask = img2imgreq.mask
|
||||
if mask:
|
||||
@ -562,8 +567,6 @@ class Api:
|
||||
img2imgreq.init_images = None
|
||||
img2imgreq.mask = None
|
||||
|
||||
from modules.s3 import s3_client
|
||||
from modules.env_to_yaml import get_env_var
|
||||
import uuid
|
||||
|
||||
b64_string = b64images[0].decode("utf-8")
|
||||
|
@ -117,7 +117,7 @@ StableDiffusionImg2ImgProcessingAPI = PydanticModelGenerator(
|
||||
StableDiffusionProcessingImg2Img,
|
||||
[
|
||||
{"key": "sampler_index", "type": str, "default": "Euler"},
|
||||
{"key": "init_images", "type": list, "default": None},
|
||||
{"key": "init_images", "type": str, "default": None},
|
||||
{"key": "denoising_strength", "type": float, "default": 0.75},
|
||||
{"key": "mask", "type": str, "default": None},
|
||||
{"key": "include_init_images", "type": bool, "default": False, "exclude" : True},
|
||||
|
22
modules/download_from_s3.py
Normal file
22
modules/download_from_s3.py
Normal file
@ -0,0 +1,22 @@
|
||||
import base64
|
||||
from modules.s3 import s3_client
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
def get_photo_base64(s3_url) -> str:
|
||||
try:
|
||||
s3_url = s3_url
|
||||
parsed = urlparse(s3_url)
|
||||
path_parts = parsed.path.lstrip('/').split('/', 1)
|
||||
|
||||
if len(path_parts) != 2:
|
||||
raise ValueError("Не удалось извлечь bucket и key из URL.")
|
||||
|
||||
bucket_name, s3_key = path_parts
|
||||
|
||||
response = s3_client.get_object(Bucket=bucket_name, Key=s3_key)
|
||||
image_data = response['Body'].read()
|
||||
return base64.b64encode(image_data).decode('utf-8')
|
||||
except Exception as e:
|
||||
print(f"Ошибка при получении файла: {e}")
|
||||
return ""
|
@ -1,3 +1,4 @@
|
||||
|
||||
import boto3
|
||||
from botocore.client import Config
|
||||
|
||||
@ -11,5 +12,3 @@ s3_client = boto3.client(
|
||||
region_name='ru-1',
|
||||
config=Config(s3={'addressing_style': 'path'})
|
||||
)
|
||||
|
||||
|
||||
|
@ -13,18 +13,19 @@ gradio==3.41.2
|
||||
inflection
|
||||
jsonmerge
|
||||
kornia
|
||||
urllib
|
||||
lark
|
||||
numpy
|
||||
omegaconf
|
||||
open-clip-torch
|
||||
|
||||
dotenv
|
||||
piexif
|
||||
protobuf==3.20.0
|
||||
psutil
|
||||
pytorch_lightning
|
||||
requests
|
||||
resize-right
|
||||
|
||||
botocore
|
||||
safetensors
|
||||
scikit-image>=0.19
|
||||
tomesd
|
||||
|
Loading…
x
Reference in New Issue
Block a user