SoggyKiwi commited on
Commit
07b1c90
1 Parent(s): 5c39195

prevent running if image not uploaded

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -12,6 +12,9 @@ model.to(device)
12
  model.eval()
13
 
14
  def process_image(input_image, learning_rate, iterations):
 
 
 
15
  def get_encoder_activations(x):
16
  encoder_output = model.vit(x)
17
  final_activations = encoder_output.last_hidden_state
@@ -47,7 +50,8 @@ iface = gr.Interface(
47
  gr.Number(value=0.01, label="Learning Rate"),
48
  gr.Number(value=1, label="Iterations")
49
  ],
50
- outputs=gr.Image(type="numpy", label="Processed Image")
 
51
  )
52
 
53
  iface.launch()
 
12
  model.eval()
13
 
14
  def process_image(input_image, learning_rate, iterations):
15
+ if input_image is None:
16
+ return None, "Please upload an image."
17
+
18
  def get_encoder_activations(x):
19
  encoder_output = model.vit(x)
20
  final_activations = encoder_output.last_hidden_state
 
50
  gr.Number(value=0.01, label="Learning Rate"),
51
  gr.Number(value=1, label="Iterations")
52
  ],
53
+ outputs=[gr.outputs.Image(type="numpy", label="ViT-Dreamed Image"), gr.outputs.Textbox()],
54
+ live=True
55
  )
56
 
57
  iface.launch()