Yaron Koresh commited on
Commit
f130ec5
·
verified ·
1 Parent(s): d87eb53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -430,7 +430,8 @@ CHECKPOINTS = ESRGANUpscalerCheckpoints(
430
 
431
  device = DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
432
  DTYPE = dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float32
433
- enhancer = ESRGANUpscaler(checkpoints=CHECKPOINTS, device="cpu", dtype=DTYPE)
 
434
 
435
  # logging
436
 
@@ -450,8 +451,8 @@ MAX_SEED = np.iinfo(np.int32).max
450
  # precision data
451
 
452
  seq=512
453
- image_steps=25
454
- img_accu=3.5
455
 
456
  # ui data
457
 
@@ -523,6 +524,7 @@ torch.cuda.empty_cache()
523
 
524
  # functionality
525
 
 
526
  def upscaler(
527
  input_image: Image.Image,
528
  prompt: str = "Masterpiece, Best Quality, Hyper-Realistic, Super-Realistic.",
@@ -593,7 +595,7 @@ def _summarize(text):
593
  gen = model.generate(
594
  toks,
595
  length_penalty=2.0,
596
- num_beams=4,
597
  early_stopping=True,
598
  max_length=512
599
  )
@@ -1286,7 +1288,7 @@ def translate(txt,to_lang="en",from_lang="auto"):
1286
  log(f'RET translate with translation as {translation}')
1287
  return translation.lower()
1288
 
1289
- @spaces.GPU(duration=300)
1290
  def handle_generation(h,w,d):
1291
 
1292
  log(f'CALL handle_generate')
@@ -1334,7 +1336,7 @@ def handle_generation(h,w,d):
1334
  output_type="pil",
1335
  guidance_scale=img_accu,
1336
  num_images_per_prompt=1,
1337
- num_inference_steps=30,
1338
  max_sequence_length=seq,
1339
  generator=torch.Generator(device).manual_seed(random.randint(0, MAX_SEED))
1340
  ).images[0]
 
430
 
431
  device = DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
432
  DTYPE = dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float32
433
+
434
+ enhancer = ESRGANUpscaler(checkpoints=CHECKPOINTS, device=device, dtype=DTYPE).to(device)
435
 
436
  # logging
437
 
 
451
  # precision data
452
 
453
  seq=512
454
+ image_steps=30
455
+ img_accu=9.0
456
 
457
  # ui data
458
 
 
524
 
525
  # functionality
526
 
527
+ @spaces.GPU(duration=300)
528
  def upscaler(
529
  input_image: Image.Image,
530
  prompt: str = "Masterpiece, Best Quality, Hyper-Realistic, Super-Realistic.",
 
595
  gen = model.generate(
596
  toks,
597
  length_penalty=2.0,
598
+ num_beams=8,
599
  early_stopping=True,
600
  max_length=512
601
  )
 
1288
  log(f'RET translate with translation as {translation}')
1289
  return translation.lower()
1290
 
1291
+ @spaces.GPU(duration=100)
1292
  def handle_generation(h,w,d):
1293
 
1294
  log(f'CALL handle_generate')
 
1336
  output_type="pil",
1337
  guidance_scale=img_accu,
1338
  num_images_per_prompt=1,
1339
+ num_inference_steps=image_steps,
1340
  max_sequence_length=seq,
1341
  generator=torch.Generator(device).manual_seed(random.randint(0, MAX_SEED))
1342
  ).images[0]