MCPcopy
hub / github.com/XPixelGroup/DiffBIR / save

Method save

diffbir/inference/loop.py:212–235  ·  view source on GitHub ↗
(self, samples: List[np.ndarray], pos_prompt: str, neg_prompt: str)

Source from the content-addressed store, hash-verified

210 self.save(samples, pos_prompt, neg_prompt)
211
212 def save(self, samples: List[np.ndarray], pos_prompt: str, neg_prompt: str) -> None:
213 file_stem = self.loop_ctx["file_stem"]
214 assert len(samples) == self.args.n_samples
215 for i, sample in enumerate(samples):
216 file_name = (
217 f"{file_stem}_{i}.png"
218 if self.args.n_samples > 1
219 else f"{file_stem}.png"
220 )
221 save_path = os.path.join(self.save_dir, file_name)
222 Image.fromarray(sample).save(save_path)
223 print(f"save result to {save_path}")
224 csv_path = os.path.join(self.save_dir, "prompt.csv")
225 df = pd.DataFrame(
226 {
227 "file_name": [file_stem],
228 "pos_prompt": [pos_prompt],
229 "neg_prompt": [neg_prompt],
230 }
231 )
232 if os.path.exists(csv_path):
233 df.to_csv(csv_path, index=None, mode="a", header=None)
234 else:
235 df.to_csv(csv_path, index=None)

Callers 10

runMethod · 0.95
mainFunction · 0.45
mainFunction · 0.45
process_imageMethod · 0.45
http_botFunction · 0.45
trainFunction · 0.45
_save_checkpointMethod · 0.45
get_inverse_affineMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected