NickKolok commited on
Commit
4db9c56
·
verified ·
1 Parent(s): 7aacbb3

Upgrade run_cmd

Browse files
Files changed (1) hide show
  1. app.py +21 -11
app.py CHANGED
@@ -5,27 +5,37 @@ from PIL import Image
5
  import torch
6
  from random import randint
7
  import sys
8
- from subprocess import call
9
  import psutil
 
 
10
 
11
-
12
-
13
-
14
- torch.hub.download_url_to_file('http://people.csail.mit.edu/billf/project%20pages/sresCode/Markov%20Random%20Fields%20for%20Super-Resolution_files/100075_lowres.jpg', 'bear.jpg')
15
-
16
-
17
  def run_cmd(command):
18
  try:
19
- print(command)
20
- call(command, shell=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  except KeyboardInterrupt:
22
  print("Process interrupted")
23
  sys.exit(1)
 
 
24
  run_cmd("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P .")
25
  run_cmd("pip install basicsr")
26
  run_cmd("pip freeze")
27
 
28
- os.system("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth -P .")
29
 
30
 
31
  def inference(img,mode):
@@ -44,7 +54,7 @@ def inference(img,mode):
44
  if mode == "base":
45
  run_cmd("python inference_realesrgan.py -n RealESRGAN_x4plus -i "+ INPUT_DIR + " -o " + OUTPUT_DIR)
46
  else:
47
- os.system("python inference_realesrgan.py -n RealESRGAN_x4plus_anime_6B -i "+ INPUT_DIR + " -o " + OUTPUT_DIR)
48
  return os.path.join(OUTPUT_DIR, "1_out.png")
49
 
50
 
 
5
  import torch
6
  from random import randint
7
  import sys
 
8
  import psutil
9
+ import subprocess
10
+ import sys
11
 
 
 
 
 
 
 
12
  def run_cmd(command):
13
  try:
14
+ print(f"Running command: {command}")
15
+ # Run the command and capture both output and error
16
+ result = subprocess.run(command, shell=True, text=True, capture_output=True)
17
+
18
+ # Print stdout and stderr
19
+ if result.stdout:
20
+ print("Output:\n", result.stdout)
21
+
22
+ if result.stderr:
23
+ print("Error:\n", result.stderr)
24
+
25
+ # Check for command success
26
+ if result.returncode != 0:
27
+ print(f"Command failed with return code {result.returncode}")
28
+
29
  except KeyboardInterrupt:
30
  print("Process interrupted")
31
  sys.exit(1)
32
+
33
+
34
  run_cmd("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P .")
35
  run_cmd("pip install basicsr")
36
  run_cmd("pip freeze")
37
 
38
+ run_cmd("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth -P .")
39
 
40
 
41
  def inference(img,mode):
 
54
  if mode == "base":
55
  run_cmd("python inference_realesrgan.py -n RealESRGAN_x4plus -i "+ INPUT_DIR + " -o " + OUTPUT_DIR)
56
  else:
57
+ run_cmd("python inference_realesrgan.py -n RealESRGAN_x4plus_anime_6B -i "+ INPUT_DIR + " -o " + OUTPUT_DIR)
58
  return os.path.join(OUTPUT_DIR, "1_out.png")
59
 
60