K e y s :   [ ' p r o m p t ' ,   ' w o r k f l o w ' ] 
 
 P r o m p t :   { " 1 " :   { " i n p u t s " :   { " t e x t " :   " b l u r r y   u g l y   b a d " ,   " c l i p " :   [ " 4 " ,   0 ] } ,   " c l a s s _ t y p e " :   " C L I P T e x t E n c o d e " ,   " _ m e 
 
 W o r k f l o w :   { " i d " :   " e 8 d f 6 a 9 4 - 0 7 0 8 - 4 5 3 8 - a 2 a d - 6 3 e 3 c 6 e e c c f b " ,   " r e v i s i o n " :   0 ,   " l a s t _ n o d e _ i d " :   3 3 ,   " l a s t _ l i n k _ i d " :   4 3 
 
 L o a d I m a g e   S o u r c e : 
 
 c l a s s   L o a d I m a g e : 
 
         @ c l a s s m e t h o d 
 
         d e f   I N P U T _ T Y P E S ( s ) : 
 
                 i n p u t _ d i r   =   f o l d e r _ p a t h s . g e t _ i n p u t _ d i r e c t o r y ( ) 
 
                 f i l e s   =   [ f   f o r   f   i n   o s . l i s t d i r ( i n p u t _ d i r )   i f   o s . p a t h . i s f i l e ( o s . p a t h . j o i n ( i n p u t _ d i r ,   f ) ) ] 
 
                 f i l e s   =   f o l d e r _ p a t h s . f i l t e r _ f i l e s _ c o n t e n t _ t y p e s ( f i l e s ,   [ " i m a g e " ] ) 
 
                 r e t u r n   { " r e q u i r e d " : 
 
                                         { " i m a g e " :   ( s o r t e d ( f i l e s ) ,   { " i m a g e _ u p l o a d " :   T r u e } ) } , 
 
                                 } 
 
 
 
         C A T E G O R Y   =   " i m a g e " 
 
 
 
         R E T U R N _ T Y P E S   =   ( " I M A G E " ,   " M A S K " ) 
 
         F U N C T I O N   =   " l o a d _ i m a g e " 
 
         d e f   l o a d _ i m a g e ( s e l f ,   i m a g e ) : 
 
                 i m a g e _ p a t h   =   f o l d e r _ p a t h s . g e t _ a n n o t a t e d _ f i l e p a t h ( i m a g e ) 
 
 
 
                 i m g   =   n o d e _ h e l p e r s . p i l l o w ( I m a g e . o p e n ,   i m a g e _ p a t h ) 
 
 
 
                 o u t p u t _ i m a g e s   =   [ ] 
 
                 o u t p u t _ m a s k s   =   [ ] 
 
                 w ,   h   =   N o n e ,   N o n e 
 
 
 
                 e x c l u d e d _ f o r m a t s   =   [ ' M P O ' ] 
 
 
 
                 f o r   i   i n   I m a g e S e q u e n c e . I t e r a t o r ( i m g ) : 
 
                         i   =   n o d e _ h e l p e r s . p i l l o w ( I m a g e O p s . e x i f _ t r a n s p o s e ,   i ) 
 
 
 
                         i f   i . m o d e   = =   ' I ' : 
 
                                 i   =   i . p o i n t ( l a m b d a   i :   i   *   ( 1   /   2 5 5 ) ) 
 
                         i m a g e   =   i . c o n v e r t ( " R G B " ) 
 
 
 
                         i f   l e n ( o u t p u t _ i m a g e s )   = =   0 : 
 
                                 w   =   i m a g e . s i z e [ 0 ] 
 
                                 h   =   i m a g e . s i z e [ 1 ] 
 
 
 
                         i f   i m a g e . s i z e [ 0 ]   ! =   w   o r   i m a g e . s i z e [ 1 ]   ! =   h : 
 
                                 c o n t i n u e 
 
 
 
                         i m a g e   =   n p . a r r a y ( i m a g e ) . a s t y p e ( n p . f l o a t 3 2 )   /   2 5 5 . 0 
 
                         i m a g e   =   t o r c h . f r o m _ n u m p y ( i m a g e ) [ N o n e , ] 
 
                         i f   ' A '   i n   i . g e t b a n d s ( ) : 
 
                                 m a s k   =   n p . a r r a y ( i . g e t c h a n n e l ( ' A ' ) ) . a s t y p e ( n p . f l o a t 3 2 )   /   2 5 5 . 0 
 
                                 m a s k   =   1 .   -   t o r c h . f r o m _ n u m p y ( m a s k ) 
 
                         e l i f   i . m o d e   = =   ' P '   a n d   ' t r a n s p a r e n c y '   i n   i . i n f o : 
 
                                 m a s k   =   n p . a r r a y ( i . c o n v e r t ( ' R G B A ' ) . g e t c h a n n e l ( ' A ' ) ) . a s t y p e ( n p . f l o a t 3 2 )   /   2 5 5 . 0 
 
                                 m a s k   =   1 .   -   t o r c h . f r o m _ n u m p y ( m a s k ) 
 
                         e l s e : 
 
                                 m a s k   =   t o r c h . z e r o s ( ( 6 4 , 6 4 ) ,   d t y p e = t o r c h . f l o a t 3 2 ,   d e v i c e = " c p u " ) 
 
                         o u t p u t _ i m a g e s . a p p e n d ( i m a g e ) 
 
                         o u t p u t _ m a s k s . a p p e n d ( m a s k . u n s q u e e z e ( 0 ) ) 
 
 
 
                 i f   l e n ( o u t p u t _ i m a g e s )   >   1   a n d   i m g . f o r m a t   n o t   i n   e x c l u d e d _ f o r m a t s : 
 
                         o u t p u t _ i m a g e   =   t o r c h . c a t ( o u t p u t _ i m a g e s ,   d i m = 0 ) 
 
                         o u t p u t _ m a s k   =   t o r c h . c a t ( o u t p u t _ m a s k s ,   d i m = 0 ) 
 
                 e l s e : 
 
                         o u t p u t _ i m a g e   =   o u t p u t _ i m a g e s [ 0 ] 
 
                         o u t p u t _ m a s k   =   o u t p u t _ m a s k s [ 0 ] 
 
 
 
                 r e t u r n   ( o u t p u t _ i m a g e ,   o u t p u t _ m a s k ) 
 
 
 
         @ c l a s s m e t h o d 
 
         d e f   I S _ C H A N G E D ( s ,   i m a g e ) : 
 
                 i m a g e _ p a t h   =   f o l d e r _ p a t h s . g e t _ a n n o t a t e d _ f i l e p a t h ( i m a g e ) 
 
                 m   =   h a s h l i b . s h a 2 5 6 ( ) 
 
                 w i t h   o p e n ( i m a g e _ p a t h ,   ' r b ' )   a s   f : 
 
                         m . u p d a t e ( f . r e a d ( ) ) 
 
                 r e t u r n   m . d i g e s t ( ) . h e x ( ) 
 
 
 
         @ c l a s s m e t h o d 
 
         d e f   V A L I D A T E _ I N P U T S ( s ,   i m a g e ) : 
 
                 i f   n o t   f o l d e r _ p a t h s . e x i s t s _ a n n o t a t e d _ f i l e p a t h ( i m a g e ) : 
 
                         r e t u r n   " I n v a l i d   i m a g e   f i l e :   { } " . f o r m a t ( i m a g e ) 
 
 
 
                 r e t u r n   T r u e 
 
 
 
 