5
5
from modules .api .models import *
6
6
from modules .processing import StableDiffusionProcessingTxt2Img , StableDiffusionProcessingImg2Img , process_images
7
7
from modules .sd_samplers import all_samplers
8
- from modules .extras import run_extras
8
+ from modules .extras import run_extras , run_pnginfo
9
9
10
10
def upscaler_to_index (name : str ):
11
11
try :
@@ -32,6 +32,7 @@ def __init__(self, app, queue_lock):
32
32
self .app .add_api_route ("/sdapi/v1/img2img" , self .img2imgapi , methods = ["POST" ], response_model = ImageToImageResponse )
33
33
self .app .add_api_route ("/sdapi/v1/extra-single-image" , self .extras_single_image_api , methods = ["POST" ], response_model = ExtrasSingleImageResponse )
34
34
self .app .add_api_route ("/sdapi/v1/extra-batch-images" , self .extras_batch_images_api , methods = ["POST" ], response_model = ExtrasBatchImagesResponse )
35
+ self .app .add_api_route ("/sdapi/v1/png-info" , self .pnginfoapi , methods = ["POST" ], response_model = PNGInfoResponse )
35
36
36
37
def text2imgapi (self , txt2imgreq : StableDiffusionTxt2ImgProcessingAPI ):
37
38
sampler_index = sampler_to_index (txt2imgreq .sampler_index )
@@ -125,8 +126,13 @@ def prepareFiles(file):
125
126
126
127
return ExtrasBatchImagesResponse (images = list (map (encode_pil_to_base64 , result [0 ])), html_info = result [1 ])
127
128
128
- def pnginfoapi (self ):
129
- raise NotImplementedError
129
+ def pnginfoapi (self , req : PNGInfoRequest ):
130
+ if (not req .image .strip ()):
131
+ return PNGInfoResponse (info = "" )
132
+
133
+ result = run_pnginfo (decode_base64_to_image (req .image .strip ()))
134
+
135
+ return PNGInfoResponse (info = result [1 ])
130
136
131
137
def launch (self , server_name , port ):
132
138
self .app .include_router (self .router )
0 commit comments