generated from databricks-industry-solutions/industry-solutions-blueprints
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from databricks-industry-solutions/feature/mon…
…ai_integration MONAILabel Integration
- Loading branch information
Showing
182 changed files
with
476,209 additions
and
1,578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Databricks notebook source | ||
# MAGIC %md | ||
# MAGIC # Introduction | ||
# MAGIC | ||
# MAGIC This notebook is designed to install the MONAILabel_Pixels and databricks-sdk libraries. It provides the necessary instructions to install these libraries using the `%pip` command and restart the Python library using `dbutils.library.restartPython()`. | ||
# MAGIC | ||
# MAGIC # MONAILabel | ||
# MAGIC | ||
# MAGIC MONAILabel is a framework for creating interactive and customizable annotation workflows for medical imaging data. It provides a user-friendly interface for annotating medical images and supports various annotation tasks such as segmentation, classification, etc. | ||
# MAGIC | ||
# MAGIC # Integration with OHIF Viewer: | ||
# MAGIC | ||
# MAGIC MONAILabel can be integrated with the OHIF Viewer to provide a seamless annotation experience. The OHIF Viewer is a web-based medical image viewer that allows users to view, annotate, and analyze medical images. By integrating MONAILabel with the OHIF Viewer, users can leverage the advanced annotation capabilities of MONAILabel directly within the viewer interface. This integration enables efficient and accurate annotation of medical images, enhancing the overall workflow for medical image analysis and research. | ||
|
||
# COMMAND ---------- | ||
|
||
# DBTITLE 1,Install MONAILabel_Pixels and databricks-sdk | ||
# MAGIC %pip install git+https://github.com/erinaldidb/MONAILabel_Pixels.git databricks-sdk --upgrade | ||
|
||
# COMMAND ---------- | ||
|
||
dbutils.library.restartPython() | ||
|
||
# COMMAND ---------- | ||
|
||
# MAGIC %run ./config/proxy_prep | ||
|
||
# COMMAND ---------- | ||
|
||
init_widgets() | ||
|
||
# COMMAND ---------- | ||
|
||
# DBTITLE 1,MONAILabel Server Address Generation in Databricks | ||
init_env() | ||
displayHTML(f"<h1>Use the following link as MONAILabel server address</h1><br><h2>{get_proxy_url()}") | ||
|
||
# COMMAND ---------- | ||
|
||
# DBTITLE 1,Downloading Radiology Apps with MonaiLabel | ||
# MAGIC %sh | ||
# MAGIC monailabel apps --download --name radiology --output /local_disk0/monai/apps/ | ||
|
||
# COMMAND ---------- | ||
|
||
# DBTITLE 1,Monailabel Radiology Segmentation | ||
# MAGIC %sh | ||
# MAGIC monailabel start_server --app /local_disk0/monai/apps/radiology --studies $DATABRICKS_HOST --conf models segmentation --table $DATABRICKS_PIXELS_TABLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Databricks notebook source | ||
import os | ||
from dbruntime.databricks_repl_context import get_context | ||
from databricks.sdk import WorkspaceClient | ||
|
||
ctx = get_context() | ||
w = WorkspaceClient() | ||
|
||
|
||
# COMMAND ---------- | ||
|
||
def init_widgets(): | ||
dbutils.widgets.text("table", "main.pixels_solacc.object_catalog", label="1.0 Catalog Schema Table to store object metadata into") | ||
dbutils.widgets.text("sqlWarehouseID", "", label="2.0 SQL Warehouse") | ||
sql_warehouse_id = dbutils.widgets.get("sqlWarehouseID") | ||
table = dbutils.widgets.get("table") | ||
return sql_warehouse_id, table | ||
|
||
# COMMAND ---------- | ||
|
||
def init_env(): | ||
sql_warehouse_id = dbutils.widgets.get("sqlWarehouseID") | ||
table = dbutils.widgets.get("table") | ||
|
||
if not spark.catalog.tableExists(table): | ||
raise Exception("The configured table does not exist!") | ||
|
||
if sql_warehouse_id == "": | ||
raise Exception("SQL Warehouse ID is mandatory!") | ||
else: | ||
wh = w.warehouses.get(id=sql_warehouse_id) | ||
print(f"Using '{wh.as_dict()['name']}' as SQL Warehouse") | ||
|
||
os.environ["DATABRICKS_TOKEN"] = ctx.apiToken | ||
os.environ["DATABRICKS_WAREHOUSE_ID"] = sql_warehouse_id | ||
os.environ["DATABRICKS_HOST"] = f"https://{ctx.browserHostName}" | ||
os.environ["DATABRICKS_PIXELS_TABLE"] = table | ||
|
||
# COMMAND ---------- | ||
|
||
def get_proxy_url(port:int = 8000): | ||
host_name = ctx.browserHostName | ||
ending = f"driver-proxy/o/{get_context().workspaceId}/{get_context().clusterId}/{port}/" | ||
|
||
azure = "azuredatabricks.net" | ||
gcp = "gcp.databricks.com" | ||
aws = "cloud.databricks.com" | ||
|
||
if azure in host_name: | ||
shard = int(get_context().workspaceId) % 20 | ||
return f"https://adb-dp-{get_context().workspaceId}.{shard}.{azure}/{ending}" | ||
elif gcp in host_name: | ||
shard = int(get_context().workspaceId) % 10 | ||
return f"https://dp-{get_context().workspaceId}.{shard}.{gcp}/{ending}" | ||
elif aws in host_name: | ||
dbc_host = '.'.join(host_name.split(".")[1:]) | ||
return f"https://dbc-dp-{get_context().workspaceId}.{dbc_host}/{ending}" | ||
|
Oops, something went wrong.