Spaces:
Runtime error
Runtime error
app.py
Browse files
app.py
CHANGED
|
@@ -26,7 +26,7 @@ layer_settings = {
|
|
| 26 |
step = 0.01 # Gradient ascent step size
|
| 27 |
num_octave = 3 # Number of scales at which to run gradient ascent
|
| 28 |
octave_scale = 1.4 # Size ratio between scales
|
| 29 |
-
iterations = 20 # Number of ascent steps per scale
|
| 30 |
max_loss = 15.0
|
| 31 |
|
| 32 |
def preprocess_image(img):
|
|
@@ -95,7 +95,7 @@ def gradient_ascent_loop(img, iterations, learning_rate, max_loss=None):
|
|
| 95 |
return img
|
| 96 |
|
| 97 |
|
| 98 |
-
def process_image(img):
|
| 99 |
original_img = preprocess_image(img)
|
| 100 |
original_shape = original_img.shape[1:3]
|
| 101 |
|
|
@@ -123,9 +123,10 @@ def process_image(img):
|
|
| 123 |
return deprocess_image(img.numpy())
|
| 124 |
|
| 125 |
image = gr.inputs.Image()
|
|
|
|
| 126 |
label = gr.outputs.Image()
|
| 127 |
|
| 128 |
-
iface = gr.Interface(process_image,image,label,
|
| 129 |
#outputs=[
|
| 130 |
# gr.outputs.Textbox(label="Engine issue"),
|
| 131 |
# gr.outputs.Textbox(label="Engine issue score")],
|
|
|
|
| 26 |
step = 0.01 # Gradient ascent step size
|
| 27 |
num_octave = 3 # Number of scales at which to run gradient ascent
|
| 28 |
octave_scale = 1.4 # Size ratio between scales
|
| 29 |
+
#iterations = 20 # Number of ascent steps per scale
|
| 30 |
max_loss = 15.0
|
| 31 |
|
| 32 |
def preprocess_image(img):
|
|
|
|
| 95 |
return img
|
| 96 |
|
| 97 |
|
| 98 |
+
def process_image(img,iterations):
|
| 99 |
original_img = preprocess_image(img)
|
| 100 |
original_shape = original_img.shape[1:3]
|
| 101 |
|
|
|
|
| 123 |
return deprocess_image(img.numpy())
|
| 124 |
|
| 125 |
image = gr.inputs.Image()
|
| 126 |
+
slider = gr.inputs.Slider(minimum=5, maximum=30, step=1, default=20, label="Number of ascent steps per scale")
|
| 127 |
label = gr.outputs.Image()
|
| 128 |
|
| 129 |
+
iface = gr.Interface(process_image,[image,slider],label,
|
| 130 |
#outputs=[
|
| 131 |
# gr.outputs.Textbox(label="Engine issue"),
|
| 132 |
# gr.outputs.Textbox(label="Engine issue score")],
|