Skip to content

Commit

Permalink
[DOCS] Update how to use package in IDE (#1682)
Browse files Browse the repository at this point in the history
* added build artifacts dirs to gitignore
initial commit - 1 GPU, 1- show_in_window

* added show_in_window to all of the check tutorials.
MAJOR BUGS:
1. yolo related error in examples calling yolo AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'
2. duplicate display in all of the checks

* limiting torchvision version to 0.11.2 solves the YOLO bug
some displays are still duplicated but not all of them

* GPU comment added to the documentation for all of the relevant checks
Duplicate display bug not solved

Co-authored-by: Itay Gabbay <itay@deepchecks.com>
  • Loading branch information
TheSolY and ItayGabbay committed Jun 26, 2022
1 parent 8601969 commit 5c28d02
Show file tree
Hide file tree
Showing 22 changed files with 182 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ docs/source/user-guide/vision/auto_tutorials
docs/source/tutorials/vision/*.html
docs/source/tutorials/vision/deepchecks_formatted_image*.jpg
docs/source/tutorials/vision/tomato-detection/
docs/source/user-guide/vision/tutorials/tomato-detection
docs/source/user-guide/vision/tutorials/hymenoptera_data
docs/source/tutorials/vision/hymenoptera_data/
docs/source/user-guide/vision/tutorials/EuroSAT
docs/source/user-guide/general/exporting_results/wandb
deepchecks/vision/datasets/classification/models/

2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ readthedocs-sphinx-search
numpydoc>=1.1.0
pypandoc>=1.7.2
sphinx-reredirects>=0.0.1
ipywidgets @ git+https://github.com/deepchecks/ipywidgets.git@8ac487b64ffd48dbeaa0a47d1997be27f6052dbc
#ipywidgets @ git+https://github.com/deepchecks/ipywidgets.git@8ac487b64ffd48dbeaa0a47d1997be27f6052dbc
docutils
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
result = check.run(train_data)
result

#%%
# To display the results in an IDE like PyCharm, you can use the following code:

# result.show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# Observe Graphic Result
# ^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -72,5 +79,3 @@
# in the check's run.

result.value


Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
result = check.run(train_data)
result

#%%
# To display the results in an IDE like PyCharm, you can use the following code:

# result.show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# Observe Graphic Result
# ^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@
check = ClassPerformance()
check.run(train_ds, test_ds, mnist_model)

#%%
# If you have a GPU, you can speed up this check by calling:

# check.run(train_ds, test_ds, mnist_model, device=<your GPU>)

#%%
# To display the results in an IDE like PyCharm, you can use the following code:

# check.run(train_ds, test_ds, mnist_model).show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# Object Detection Class Performance
# ==================================
Expand Down Expand Up @@ -94,6 +106,18 @@
check = ClassPerformance(show_only='best')
check.run(train_ds, test_ds, yolo)

#%%
# If you have a GPU, you can speed up this check by calling:

# check.run(train_ds, test_ds, yolo, device=<your GPU>)

#%%
# To display the results in an IDE like PyCharm, you can use the following code:

# check.run(train_ds, test_ds, yolo).show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# Define a Condition
# ==================
Expand All @@ -106,5 +130,6 @@
result = check.run(train_ds, test_ds, yolo)
result


#%%
# We detected that for several classes our model performance is below the threshold.
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,15 @@

check = ConfusionMatrixReport(categories_to_display=10)
check.run(train_ds, yolo)

#%%
# If you have a GPU, you can speed up this check by calling:

# check.run(train_ds, yolo, device=<your GPU>)

#%%
# To display the results in an IDE like PyCharm, you can use the following code:

# check.run(train_ds, yolo).show_in_window()
#%%
# The result will be displayed in a new window.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
result = ImageSegmentPerformance().run(coco_data, model)
result

#%%
# If you have a GPU, you can speed up this check by passing it as an argument to .run() as device=<your GPU>
#
# To display the results in an IDE like PyCharm, you can use the following code:

# result.show_in_window()
#%%
# The result will be displayed in a new window.


#%%
# Observe the check’s output
# --------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
result = check.run(test_ds, yolo)
result

#%%
# If you have a GPU, you can speed up this check by passing it as an argument to .run() as device=<your GPU>
#
# To display the results in an IDE like PyCharm, you can use the following code:

# result.show_in_window()
#%%
# The result will be displayed in a new window.


# %%
# Observe the check’s output
# --------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
result = check.run(test_ds, yolo)
result

#%%
# If you have a GPU, you can speed up this check by passing it as an argument to .run() as device=<your GPU>
#
# To display the results in an IDE like PyCharm, you can use the following code:

# result.show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# Observe the check’s output
# --------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@
check = ModelErrorAnalysis(min_error_model_score=-0.1)
check.run(train_ds, test_ds, mnist_model)

#%%
# If you have a GPU, you can speed up this check by passing it as an argument to .run() as device=<your GPU>
#
# To display the results in an IDE like PyCharm, you can use the following code:

# check.run(train_ds, test_ds, mnist_model).show_in_window()
#%%
# The result will be displayed in a new window.


#%%
# Object Detection Class Performance
# ----------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@
result = RobustnessReport().run(mnist_dataloader_test, model)
result

#%%
# If you have a GPU, you can speed up this check by passing it as an argument to .run() as device=<your GPU>
#
# To display the results in an IDE like PyCharm, you can use the following code:

# result.show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# Observe the check’s output
# --------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ class has equal probability.
#%%
result

#%%
# If you have a GPU, you can speed up this check by passing it as an argument to .run() as device=<your GPU>
#
# To display the results in an IDE like PyCharm, you can use the following code:

# result.show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# Observe the check's output
# --------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
result = check.run(train_ds, mnist_model)
result

#%%
# If you have a GPU, you can speed up this check by passing it as an argument to .run() as device=<your GPU>
#
# To display the results in an IDE like PyCharm, you can use the following code:

# result.show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# The result value is a dictionary with the following fields:
# score - the actual result,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@
check = TrainTestPredictionDrift()
check.run(train_ds, test_ds, model)

#%%
# If you have a GPU, you can speed up this check by passing it as an argument to .run() as device=<your GPU>
#
# To display the results in an IDE like PyCharm, you can use the following code:

# check.run(train_ds, test_ds, model).show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# Understanding the results
# -------------------------
Expand Down Expand Up @@ -146,12 +155,14 @@ def collate_test(batch):
mod_train_ds = MNISTData(mod_train_loader)
mod_test_ds = MNISTData(mod_test_loader)

#%%
# Run the check
# -------------

check = TrainTestPredictionDrift()
check.run(mod_train_ds, mod_test_ds, model)

#%%
# Add a condition
# ---------------
# We could also add a condition to the check to alert us to changes in the prediction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ def mnist_batch_to_images_with_bias(batch):
check = FeatureLabelCorrelationChange()
check.run(train_ds, test_ds)

#%%
# To display the results in an IDE like PyCharm, you can use the following code:

# check.run(train_ds, test_ds).show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# We can see that the check detected the bias we inserted, and that the
# brightness property of the image has a high PPS, meaning it can be used to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@
check = HeatmapComparison()
check.run(train_ds, test_ds)

#%%
# To display the results in an IDE like PyCharm, you can use the following code:

# check.run(train_ds, test_ds).show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# Limit to Specific Classes
# =========================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ def batch_to_images(self, batch):
check = ImageDatasetDrift()
check.run(train_dataset=drifted_train_ds, test_dataset=test_ds_coco)

#%%
# To display the results in an IDE like PyCharm, you can use the following code:

# check.run(drifted_train_ds, test_ds_coco).show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# Define a Condition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@
check_result = ImagePropertyDrift().run(train_dataset, test_dataset)
check_result

#%%
# To display the results in an IDE like PyCharm, you can use the following code:

# check_result.show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# Observe the check’s output
# --------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
result = NewLabels().run(coco_train, coco_test)
result

#%%
# To display the results in an IDE like PyCharm, you can use the following code:

# result.show_in_window()
#%%
# The result will be displayed in a new window.

# %%
# Observe the check’s output
# ~~~~~~~~~~~~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
check = SimilarImageLeakage()
check.run(train_ds, test_ds)

#%%
# To display the results in an IDE like PyCharm, you can use the following code:

# check.run(train_ds, test_ds).show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# As we can see, no similar images were found.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@
mnist_model = load_mnist_model(pretrained=True)
ClassPerformance().run(train_ds, test_ds, mnist_model)

#%%
# To display the results in an IDE like PyCharm, you can use the following code:

# ClassPerformance().run(train_ds, test_ds, mnist_model).show_in_window()
#%%
# The result will be displayed in a new window.

#%%
# MNIST with label drift
# ======================
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ requirements: $(ENV)
"torch==1.10.2+cpu" "torchvision==0.11.3+cpu" "torchaudio==0.10.2+cpu" \
-f https://s3.amazonaws.com/pytorch/whl/torch_stable.html; \
else \
$(PIP) install -q torch torchvision torchaudio; \
$(PIP) install -q torch "torchvision==0.11.2" torchaudio; \
fi;

@$(PIP) install -U pip
Expand Down

0 comments on commit 5c28d02

Please sign in to comment.