File tree Expand file tree Collapse file tree 2 files changed +24
-7
lines changed
Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Original file line number Diff line number Diff line change 11name : Test Few-Shot Model Export
22
33on :
4+ workflow_dispatch :
5+
46 push :
57 branches : [ main ]
68 pull_request :
Original file line number Diff line number Diff line change 1+ # testing/test1.py
2+
13import torch
4+ import torchvision .transforms as T
5+ import pprint
6+
7+ # Trust the transforms used in the model export
8+ torch .serialization .add_safe_globals ({
9+ 'torchvision.transforms.transforms.Compose' : T .Compose ,
10+ 'torchvision.transforms.transforms.Resize' : T .Resize ,
11+ 'torchvision.transforms.transforms.ToTensor' : T .ToTensor
12+ })
213
314def test_model_export (model_path ):
4- print (f"Loading model from: { model_path } " )
5- config = torch .load (model_path , map_location = 'cpu' )
15+ print (f"\n Loading model from: { model_path } " )
16+
17+ config = torch .load (model_path , map_location = 'cpu' , weights_only = False )
18+
19+ print ("\n --- Exported Model Content ---" )
620
721 for key , value in config .items ():
8- if torch . is_tensor (value ):
9- print (f"{ key } : Tensor with shape { tuple (value .shape )} " )
22+ if isinstance (value , torch . Tensor ):
23+ print (f"{ key } : Tensor shape = { tuple (value .shape )} " )
1024 else :
11- print (f"{ key } : { value } " )
25+ print (f"{ key } :" )
26+ pprint .pprint (value )
1227
13- # Run
14- test_model_export ("export/fewshot_model.pt" )
28+ if __name__ == "__main__" :
29+ test_model_export ("export/fewshot_model.pt" )
You can’t perform that action at this time.
0 commit comments