.. _example_gradcam_fnf: Example: Doing Grad-CAM on the Food-Non-Food (FNF) model ======================================================== The code below is used to perform Grad-CAM on the FNF model. You can refer to :ref:`tutorial_gradcam_fnf` for an in-depth explanation for intuition behind the code. .. code:: python3 :number-lines: import XAI ds = XAI.datasets.DatasetFromCSV(path_to_csv="/path/to/desired/csv/data.csv") fnf_gc = XAI.FNFGradCam( model=model, target_layer_name="conv2d_7b", ) fnf_results_df = fnf_gc.do_gradcam( image_dataset=ds, batch_size=2, relu_attributions=False, return_metadata=True, output_folder="/output_folder", plot_gradcam=True ) You can also execute the ``plot_gradcam()`` function independently from the ``do_gradcam()`` function by setting ``plot_gradcam=False`` and doing the following: .. code:: python3 :number-lines: import XAI ds = XAI.datasets.DatasetFromCSV(path_to_csv="/path/to/desired/csv/data.csv") fnf_gc = XAI.FNFGradCam( model=model, target_layer_name="conv2d_7b", ) fnf_results_df = fnf_gc.do_gradcam( image_dataset=ds, batch_size=2, relu_attributions=False, return_metadata=True, output_folder="/output_folder", plot_gradcam=False ) fnf_results_df = fnf_gc.plot_gradcam( do_gradcam_df=fnf_results_df, savefig_dir="/output_folder", savefig=True, plt_show=True, save_csv=True ) After performing Grad-CAM on the FNF model as shown above, you can generate a PowerPoint report of the Grad-CAM results using the ``XAI.report_generation.generate_pptx()`` function. You can refer to :ref:`example_pptx_report` for the code.