Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,24 @@ import glob
|
|
| 7 |
import psutil
|
| 8 |
import time
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Page configuration
|
| 11 |
st.set_page_config(
|
| 12 |
page_title="Image Enhancer",
|
|
|
|
| 7 |
import psutil
|
| 8 |
import time
|
| 9 |
|
| 10 |
+
def modify_degradations_py():
|
| 11 |
+
file_path = '/usr/local/lib/python3.10/site-packages/basicsr/data/degradations.py'
|
| 12 |
+
with open(file_path, 'r') as f:
|
| 13 |
+
lines = f.readlines()
|
| 14 |
+
|
| 15 |
+
# Find the line containing 'from torchvision.transforms.functional_tensor import rgb_to_grayscale'
|
| 16 |
+
for i, line in enumerate(lines):
|
| 17 |
+
if 'from torchvision.transforms.functional_tensor import rgb_to_grayscale' in line:
|
| 18 |
+
# Replace it with 'from torchvision.transforms.functional import rgb_to_grayscale'
|
| 19 |
+
lines[i] = 'from torchvision.transforms.functional import rgb_to_grayscale\n'
|
| 20 |
+
break
|
| 21 |
+
|
| 22 |
+
with open(file_path, 'w') as f:
|
| 23 |
+
f.writelines(lines)
|
| 24 |
+
|
| 25 |
+
# Call the function to modify the file
|
| 26 |
+
modify_degradations_py()
|
| 27 |
+
|
| 28 |
# Page configuration
|
| 29 |
st.set_page_config(
|
| 30 |
page_title="Image Enhancer",
|