Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,13 @@
|
|
3 |
# PIL's Image, Filter, Ops, and Chops,
|
4 |
# transforms from torchvision, style never stops!
|
5 |
### 🖥️ New and Improved Application Code
|
|
|
6 |
|
|
|
|
|
|
|
|
|
|
|
7 |
import numpy as np
|
8 |
import torch
|
9 |
import torch.nn as nn
|
@@ -50,6 +56,8 @@ class ResidualBlock(nn.Module):
|
|
50 |
self.conv_block = nn.Sequential(*conv_block)
|
51 |
def forward(self, x): return x + self.conv_block(x)
|
52 |
|
|
|
|
|
53 |
class Generator(nn.Module):
|
54 |
def __init__(self, input_nc, output_nc, n_residual_blocks=9, sigmoid=True):
|
55 |
super(Generator, self).__init__()
|
@@ -187,9 +195,11 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
187 |
with gr.Row():
|
188 |
with gr.Column(scale=1):
|
189 |
gr.Markdown("### 1. Select an Image")
|
190 |
-
#
|
|
|
|
|
|
|
191 |
input_image_path = gr.FileExplorer(
|
192 |
-
root=".",
|
193 |
glob=f"**/*[{''.join(ext[1:] for ext in IMAGE_EXTENSIONS)}]",
|
194 |
label="Browse Your Images",
|
195 |
height=400
|
@@ -247,4 +257,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
247 |
)
|
248 |
|
249 |
if __name__ == "__main__":
|
250 |
-
demo.launch()
|
|
|
3 |
# PIL's Image, Filter, Ops, and Chops,
|
4 |
# transforms from torchvision, style never stops!
|
5 |
### 🖥️ New and Improved Application Code
|
6 |
+
This runtime error is happening because the version of the `gradio` library in your environment is older and doesn't support the `root` argument for the `gr.FileExplorer` component.
|
7 |
|
8 |
+
The fix is to simply remove the `root="."` argument. The `FileExplorer` will default to the correct directory (where the script is running) without it.
|
9 |
+
|
10 |
+
-----
|
11 |
+
|
12 |
+
## 🛠️ Correct Code
|
13 |
import numpy as np
|
14 |
import torch
|
15 |
import torch.nn as nn
|
|
|
56 |
self.conv_block = nn.Sequential(*conv_block)
|
57 |
def forward(self, x): return x + self.conv_block(x)
|
58 |
|
59 |
+
|
60 |
+
# It a Generator
|
61 |
class Generator(nn.Module):
|
62 |
def __init__(self, input_nc, output_nc, n_residual_blocks=9, sigmoid=True):
|
63 |
super(Generator, self).__init__()
|
|
|
195 |
with gr.Row():
|
196 |
with gr.Column(scale=1):
|
197 |
gr.Markdown("### 1. Select an Image")
|
198 |
+
#
|
199 |
+
# ===== THIS IS THE CORRECTED LINE =====
|
200 |
+
# The 'root' argument has been removed to support older Gradio versions
|
201 |
+
#
|
202 |
input_image_path = gr.FileExplorer(
|
|
|
203 |
glob=f"**/*[{''.join(ext[1:] for ext in IMAGE_EXTENSIONS)}]",
|
204 |
label="Browse Your Images",
|
205 |
height=400
|
|
|
257 |
)
|
258 |
|
259 |
if __name__ == "__main__":
|
260 |
+
demo.launch()
|