MCPcopy
hub / github.com/Stability-AI/generative-models / image_to_image

Method image_to_image

sgm/inference/api.py:215–246  ·  view source on GitHub ↗
(
        self,
        params: SamplingParams,
        image,
        prompt: str,
        negative_prompt: str = "",
        samples: int = 1,
        return_latents: bool = False,
    )

Source from the content-addressed store, hash-verified

213 )
214
215 def image_to_image(
216 self,
217 params: SamplingParams,
218 image,
219 prompt: str,
220 negative_prompt: str = "",
221 samples: int = 1,
222 return_latents: bool = False,
223 ):
224 sampler = get_sampler_config(params)
225
226 if params.img2img_strength < 1.0:
227 sampler.discretization = Img2ImgDiscretizationWrapper(
228 sampler.discretization,
229 strength=params.img2img_strength,
230 )
231 height, width = image.shape[2], image.shape[3]
232 value_dict = asdict(params)
233 value_dict["prompt"] = prompt
234 value_dict["negative_prompt"] = negative_prompt
235 value_dict["target_width"] = width
236 value_dict["target_height"] = height
237 return do_img2img(
238 image,
239 self.model,
240 sampler,
241 value_dict,
242 samples,
243 force_uc_zero_embeddings=["txt"] if not self.specs.is_legacy else [],
244 return_latents=return_latents,
245 filter=None,
246 )
247
248 def refiner(
249 self,

Callers 2

test_img2imgMethod · 0.80

Calls 3

do_img2imgFunction · 0.90
get_sampler_configFunction · 0.85

Tested by 2

test_img2imgMethod · 0.64