Example: Evaluation Pipeline
Here is an example of a full evaluation pipeline
import copy from diffusers import StableDiffusionPipeline from pruna import smash, SmashConfig from pruna.data.pruna_datamodule import PrunaDataModule from pruna.evaluation.evaluation_agent import EvaluationAgent from pruna.evaluation.task import Task # Load data and set up smash config smash_config = SmashConfig() smash_config['cacher'] = 'deepcache' # Load the base model model_path = "CompVis/stable-diffusion-v1-4" pipe = StableDiffusionPipeline.from_pretrained(model_path) # Smash the model copy_pipe = copy.deepcopy(pipe) smashed_pipe = smash(copy_pipe, smash_config) # Define the task and the evaluation agent metrics = ['clip_score', 'psnr'] task = Task(metrics, datamodule=PrunaDataModule.from_string('LAION256')) eval_agent = EvaluationAgent(task) # Evaluate base model, all models need to be wrapped in a PrunaModel before passing them to the EvaluationAgent first_results = eval_agent.evaluate(pipe) print(first_results.results) # Evaluate smashed model smashed_results = eval_agent.evaluate(smashed_pipe) print(smashed_results.results)