Skip to content

Commit

Permalink
Merge pull request #2347 from bmaltais/2345-feature-request-hide-star…
Browse files Browse the repository at this point in the history
…t-tensorboard-buttons-with-cli-argument

Hide tensorboard button if tensorflow module is not installed
  • Loading branch information
bmaltais authored Apr 19, 2024
2 parents 08460be + 40c5ac6 commit b0e81a0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion kohya_gui/class_tensorboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,20 @@ def stop_tensorboard(self):
return self.get_button_states(started=False)

def gradio_interface(self):
try:
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'

import tensorflow # Attempt to import tensorflow to check if it is installed

visibility = True

except ImportError:
self.log.error("Tensorboard is not installed, hiding the tensorboard button...")
visibility = False

with gr.Row():
button_start_tensorboard = gr.Button(
value="Start tensorboard", elem_id="myTensorButton"
value="Start tensorboard", elem_id="myTensorButton", visible=visibility
)
button_stop_tensorboard = gr.Button(
value="Stop tensorboard",
Expand Down

0 comments on commit b0e81a0

Please sign in to comment.