Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import cv2
|
3 |
import numpy as np
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
def replace_import_line(file_path):
|
4 |
+
# 置換対象の行
|
5 |
+
old_line = "from torchvision.transforms.functional_tensor import rgb_to_grayscale"
|
6 |
+
# 新しい行
|
7 |
+
new_line = "from torchvision.transforms.functional import rgb_to_grayscale"
|
8 |
+
|
9 |
+
# ファイルが存在するかチェック
|
10 |
+
if not os.path.exists(file_path):
|
11 |
+
print(f"ファイルが見つかりません: {file_path}")
|
12 |
+
return
|
13 |
+
|
14 |
+
# ファイルを読み込んで内容を置換
|
15 |
+
with open(file_path, 'r') as file:
|
16 |
+
lines = file.readlines()
|
17 |
+
|
18 |
+
# 置換処理
|
19 |
+
updated_lines = [line.replace(old_line, new_line) if old_line in line else line for line in lines]
|
20 |
+
|
21 |
+
# ファイルに書き込み
|
22 |
+
with open(file_path, 'w') as file:
|
23 |
+
file.writelines(updated_lines)
|
24 |
+
|
25 |
+
print(f"ファイルの置換が完了しました: {file_path}")
|
26 |
+
|
27 |
+
# 書き換えるファイルのパスを指定
|
28 |
+
file_path = "basicsr/data/degradations.py"
|
29 |
+
replace_import_line(file_path)
|
30 |
import gradio as gr
|
31 |
import cv2
|
32 |
import numpy as np
|