1inkusFace commited on
Commit
c9cf264
Β·
verified Β·
1 Parent(s): bc257ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -12
app.py CHANGED
@@ -52,13 +52,11 @@ from PIL import Image
52
 
53
  hftoken = os.getenv("HF_AUTH_TOKEN")
54
 
55
- code = r'''
56
- import torch
57
  import paramiko
58
- import os
59
  import socket
60
  import threading # NEW IMPORT
61
  import queue # NEW IMPORT
 
62
  FTP_HOST = 'noahcohn.com'
63
  FTP_USER = 'ford442'
64
  FTP_PASS = os.getenv("FTP_PASS")
@@ -138,9 +136,6 @@ def upload_to_ftp(filename):
138
  print("❌ Critical Error: Neither FTP host responded in time.")
139
  except Exception as e:
140
  print(f"❌ An unexpected error occurred during SFTP operation: {e}")
141
- '''
142
-
143
- pyx = cyper.inline(code, fast_indexing=True, directives=dict(boundscheck=False, wraparound=False, language_level=3))
144
 
145
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
146
 
@@ -215,7 +210,7 @@ def infer_60(
215
  timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
216
  sd35_path = f"sd35ll_{timestamp}.png"
217
  sd_image.save(sd35_path,optimize=False,compress_level=0)
218
- pyx.upload_to_ftp(sd35_path)
219
  with torch.no_grad():
220
  upscale = upscaler_2(sd_image, tiling=True, tile_width=256, tile_height=256)
221
  upscale2 = upscaler_2(upscale, tiling=True, tile_width=256, tile_height=256)
@@ -223,7 +218,7 @@ def infer_60(
223
  downscale = upscale2.resize((upscale2.width // 4, upscale2.height // 4),Image.LANCZOS)
224
  upscale_path = f"sd35ll_upscale_{timestamp}.png"
225
  downscale.save(upscale_path,optimize=False,compress_level=0)
226
- pyx.upload_to_ftp(upscale_path)
227
  return sd_image, prompt
228
 
229
  @spaces.GPU(duration=100)
@@ -259,7 +254,7 @@ def infer_90(
259
  timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
260
  sd35_path = f"sd35ll_{timestamp}.png"
261
  sd_image.save(sd35_path,optimize=False,compress_level=0)
262
- pyx.upload_to_ftp(sd35_path)
263
  with torch.no_grad():
264
  upscale = upscaler_2(sd_image, tiling=True, tile_width=256, tile_height=256)
265
  upscale2 = upscaler_2(upscale, tiling=True, tile_width=256, tile_height=256)
@@ -267,7 +262,7 @@ def infer_90(
267
  downscale = upscale2.resize((upscale2.width // 4, upscale2.height // 4),Image.LANCZOS)
268
  upscale_path = f"sd35ll_upscale_{timestamp}.png"
269
  downscale.save(upscale_path,optimize=False,compress_level=0)
270
- pyx.upload_to_ftp(upscale_path)
271
  return sd_image, prompt
272
 
273
  @spaces.GPU(duration=120)
@@ -303,7 +298,7 @@ def infer_110(
303
  timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
304
  sd35_path = f"sd35ll_{timestamp}.png"
305
  sd_image.save(sd35_path,optimize=False,compress_level=0)
306
- pyx.upload_to_ftp(sd35_path)
307
  with torch.no_grad():
308
  upscale = upscaler_2(sd_image, tiling=True, tile_width=256, tile_height=256)
309
  upscale2 = upscaler_2(upscale, tiling=True, tile_width=256, tile_height=256)
@@ -311,7 +306,7 @@ def infer_110(
311
  downscale = upscale2.resize((upscale2.width // 4, upscale2.height // 4),Image.LANCZOS)
312
  upscale_path = f"sd35ll_upscale_{timestamp}.png"
313
  downscale.save(upscale_path,optimize=False,compress_level=0)
314
- pyx.upload_to_ftp(upscale_path)
315
  return sd_image, prompt
316
 
317
  css = """
 
52
 
53
  hftoken = os.getenv("HF_AUTH_TOKEN")
54
 
 
 
55
  import paramiko
 
56
  import socket
57
  import threading # NEW IMPORT
58
  import queue # NEW IMPORT
59
+
60
  FTP_HOST = 'noahcohn.com'
61
  FTP_USER = 'ford442'
62
  FTP_PASS = os.getenv("FTP_PASS")
 
136
  print("❌ Critical Error: Neither FTP host responded in time.")
137
  except Exception as e:
138
  print(f"❌ An unexpected error occurred during SFTP operation: {e}")
 
 
 
139
 
140
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
141
 
 
210
  timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
211
  sd35_path = f"sd35ll_{timestamp}.png"
212
  sd_image.save(sd35_path,optimize=False,compress_level=0)
213
+ upload_to_ftp(sd35_path)
214
  with torch.no_grad():
215
  upscale = upscaler_2(sd_image, tiling=True, tile_width=256, tile_height=256)
216
  upscale2 = upscaler_2(upscale, tiling=True, tile_width=256, tile_height=256)
 
218
  downscale = upscale2.resize((upscale2.width // 4, upscale2.height // 4),Image.LANCZOS)
219
  upscale_path = f"sd35ll_upscale_{timestamp}.png"
220
  downscale.save(upscale_path,optimize=False,compress_level=0)
221
+ upload_to_ftp(upscale_path)
222
  return sd_image, prompt
223
 
224
  @spaces.GPU(duration=100)
 
254
  timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
255
  sd35_path = f"sd35ll_{timestamp}.png"
256
  sd_image.save(sd35_path,optimize=False,compress_level=0)
257
+ upload_to_ftp(sd35_path)
258
  with torch.no_grad():
259
  upscale = upscaler_2(sd_image, tiling=True, tile_width=256, tile_height=256)
260
  upscale2 = upscaler_2(upscale, tiling=True, tile_width=256, tile_height=256)
 
262
  downscale = upscale2.resize((upscale2.width // 4, upscale2.height // 4),Image.LANCZOS)
263
  upscale_path = f"sd35ll_upscale_{timestamp}.png"
264
  downscale.save(upscale_path,optimize=False,compress_level=0)
265
+ upload_to_ftp(upscale_path)
266
  return sd_image, prompt
267
 
268
  @spaces.GPU(duration=120)
 
298
  timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
299
  sd35_path = f"sd35ll_{timestamp}.png"
300
  sd_image.save(sd35_path,optimize=False,compress_level=0)
301
+ upload_to_ftp(sd35_path)
302
  with torch.no_grad():
303
  upscale = upscaler_2(sd_image, tiling=True, tile_width=256, tile_height=256)
304
  upscale2 = upscaler_2(upscale, tiling=True, tile_width=256, tile_height=256)
 
306
  downscale = upscale2.resize((upscale2.width // 4, upscale2.height // 4),Image.LANCZOS)
307
  upscale_path = f"sd35ll_upscale_{timestamp}.png"
308
  downscale.save(upscale_path,optimize=False,compress_level=0)
309
+ upload_to_ftp(upscale_path)
310
  return sd_image, prompt
311
 
312
  css = """