File size: 590 Bytes
fb74498
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from pathlib import Path
MARKER_DIR = Path('automodel_poc')
MARKER_DIR.mkdir(parents=True, exist_ok=True)
(MARKER_DIR / 'import_executed.txt').write_text('evil module imported\n')
class UNet2DConditionModel:
    @classmethod
    def from_pretrained(cls, pretrained_model_or_path, **kwargs):
        MARKER_DIR.mkdir(parents=True, exist_ok=True)
        (MARKER_DIR / 'from_pretrained_executed.txt').write_text(
            f'from_pretrained called path={pretrained_model_or_path} kwargs={kwargs}\n'
        )
        print('EVIL_FROM_PRETRAINED_EXECUTED')
        return cls()