NickKolok commited on
Commit
4677b33
·
verified ·
1 Parent(s): eda498a

Upgrade run_cmd

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -1,24 +1,32 @@
1
  import os
2
  os.system("pip install gradio==2.9b23")
3
- #https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13985
4
- #os.system("python -m pip install torch==2.0.1 torchvision==0.15.2")
5
  import random
6
  import gradio as gr
7
  from PIL import Image
8
  import torch
9
  from random import randint
10
  import sys
11
- from subprocess import call
12
  import psutil
 
13
 
14
-
15
-
16
-
17
-
18
  def run_cmd(command):
19
  try:
20
- print(command)
21
- call(command, shell=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  except KeyboardInterrupt:
23
  print("Process interrupted")
24
  sys.exit(1)
@@ -35,6 +43,9 @@ def inference(img,mode):
35
  _id = randint(1, 10000)
36
  INPUT_DIR = "./tmp/input_image" + str(_id) + "/"
37
  OUTPUT_DIR = "./tmp/output_image" + str(_id) + "/"
 
 
 
38
  run_cmd("rm -rf " + INPUT_DIR)
39
  run_cmd("rm -rf " + OUTPUT_DIR)
40
  run_cmd("mkdir -p " + INPUT_DIR)
 
1
  import os
2
  os.system("pip install gradio==2.9b23")
3
+
 
4
  import random
5
  import gradio as gr
6
  from PIL import Image
7
  import torch
8
  from random import randint
9
  import sys
 
10
  import psutil
11
+ import subprocess
12
 
 
 
 
 
13
  def run_cmd(command):
14
  try:
15
+ print(f"Running command: {command}")
16
+ # Run the command and capture both output and error
17
+ result = subprocess.run(command, shell=True, text=True, capture_output=True)
18
+
19
+ # Print stdout and stderr
20
+ if result.stdout:
21
+ print("Output:\n", result.stdout)
22
+
23
+ if result.stderr:
24
+ print("Error:\n", result.stderr)
25
+
26
+ # Check for command success
27
+ if result.returncode != 0:
28
+ print(f"Command failed with return code {result.returncode}")
29
+
30
  except KeyboardInterrupt:
31
  print("Process interrupted")
32
  sys.exit(1)
 
43
  _id = randint(1, 10000)
44
  INPUT_DIR = "./tmp/input_image" + str(_id) + "/"
45
  OUTPUT_DIR = "./tmp/output_image" + str(_id) + "/"
46
+
47
+ run_cmd("ls -l ./tmp/*/*")
48
+
49
  run_cmd("rm -rf " + INPUT_DIR)
50
  run_cmd("rm -rf " + OUTPUT_DIR)
51
  run_cmd("mkdir -p " + INPUT_DIR)