ford442 commited on
Commit
036bef7
Β·
1 Parent(s): 88e2385

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -112,6 +112,19 @@ models = {key: load_and_prepare_model(value) for key, value in MODEL_OPTIONS.ite
112
 
113
  MAX_SEED = np.iinfo(np.int32).max
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  def save_image(img):
116
  unique_name = str(uuid.uuid4()) + ".png"
117
  img.save(unique_name)
@@ -167,7 +180,9 @@ def generate(
167
  if "negative_prompt" in batch_options:
168
  batch_options["negative_prompt"] = options["negative_prompt"][i:i+BATCH_SIZE]
169
  images.extend(pipe(**batch_options).images)
170
-
 
 
171
  image_paths = [save_image(img) for img in images]
172
  return image_paths, seed
173
 
 
112
 
113
  MAX_SEED = np.iinfo(np.int32).max
114
 
115
+ def upload_to_ftp(filename):
116
+ try:
117
+ transport = paramiko.Transport((FTP_HOST, 22))
118
+ destination_path=FTP_DIR+filename
119
+ transport.connect(username = FTP_USER, password = FTP_PASS)
120
+ sftp = paramiko.SFTPClient.from_transport(transport)
121
+ sftp.put(filename, destination_path)
122
+ sftp.close()
123
+ transport.close()
124
+ print(f"Uploaded {filename} to FTP server")
125
+ except Exception as e:
126
+ print(f"FTP upload error: {e}")
127
+
128
  def save_image(img):
129
  unique_name = str(uuid.uuid4()) + ".png"
130
  img.save(unique_name)
 
180
  if "negative_prompt" in batch_options:
181
  batch_options["negative_prompt"] = options["negative_prompt"][i:i+BATCH_SIZE]
182
  images.extend(pipe(**batch_options).images)
183
+ sd_image_path = f"rv50_{seed}.png"
184
+ images[0].save(sd_image_path)
185
+ upload_to_ftp(sd_image_path)
186
  image_paths = [save_image(img) for img in images]
187
  return image_paths, seed
188