Update app.py
Browse files
app.py
CHANGED
|
@@ -8,19 +8,13 @@ from gfpgan.utils import GFPGANer
|
|
| 8 |
from realesrgan.utils import RealESRGANer
|
| 9 |
|
| 10 |
# 打开一个ttt.py文件
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
# 如果找到,替换成 "from torchvision.transforms.functional import rgb_to_grayscale"
|
| 19 |
-
lines[i] = 'from torchvision.transforms.functional import rgb_to_grayscale\n'
|
| 20 |
-
|
| 21 |
-
# 将修改后的代码写回文件
|
| 22 |
-
f.seek(0)
|
| 23 |
-
f.writelines(lines)
|
| 24 |
|
| 25 |
|
| 26 |
os.system("pip freeze")
|
|
|
|
| 8 |
from realesrgan.utils import RealESRGANer
|
| 9 |
|
| 10 |
# 打开一个ttt.py文件
|
| 11 |
+
os.chmod("/home/user/.local/lib/python3.10/site-packages/basicsr/data/degradations.py", 0o777)
|
| 12 |
+
import subprocess
|
| 13 |
+
|
| 14 |
+
# 使用sed命令修改test.txt的内容
|
| 15 |
+
subprocess.run(["sed", "-i", "'8s/.*/from torchvision.transforms.functional import rgb_to_grayscale/'", "/home/user/.local/lib/python3.10/site-packages/basicsr/data/degradations.py"])
|
| 16 |
+
|
| 17 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
os.system("pip freeze")
|