Skip to content

Commit

Permalink
Update stable_diffusion.py
Browse files Browse the repository at this point in the history
  • Loading branch information
elder-plinius committed Dec 1, 2023
1 parent b382d6b commit 8213769
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions swarms/models/stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import requests
import uuid
import shutil
from dotenv import load_dotenv
from typing import List

Expand Down Expand Up @@ -135,3 +136,15 @@ def run(self, task: str) -> List[str]:
image_paths.append(image_path)

return image_paths

def generate_and_move_image(self, prompt, iteration, folder_path):
# Generate the image
image_paths = self.run(prompt)
if not image_paths:
return None

# Move the image to the specified folder
src_image_path = image_paths[0]
dst_image_path = os.path.join(folder_path, f"image_{iteration}.jpg")
shutil.move(src_image_path, dst_image_path)
return dst_image_path

0 comments on commit 8213769

Please sign in to comment.