mirror of
				https://github.com/k4yt3x/video2x.git
				synced 2025-11-04 06:31:00 +01:00 
			
		
		
		
	made processor objects a class var
This commit is contained in:
		
							parent
							
								
									9fc0aa787e
								
							
						
					
					
						commit
						737646a248
					
				@ -44,11 +44,13 @@ class Interpolator(multiprocessing.Process):
 | 
				
			|||||||
        pause: Synchronized,
 | 
					        pause: Synchronized,
 | 
				
			||||||
    ) -> None:
 | 
					    ) -> None:
 | 
				
			||||||
        multiprocessing.Process.__init__(self)
 | 
					        multiprocessing.Process.__init__(self)
 | 
				
			||||||
        self.running = False
 | 
					 | 
				
			||||||
        self.processing_queue = processing_queue
 | 
					        self.processing_queue = processing_queue
 | 
				
			||||||
        self.processed_frames = processed_frames
 | 
					        self.processed_frames = processed_frames
 | 
				
			||||||
        self.pause = pause
 | 
					        self.pause = pause
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.running = False
 | 
				
			||||||
 | 
					        self.processor_objects = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        signal.signal(signal.SIGTERM, self._stop)
 | 
					        signal.signal(signal.SIGTERM, self._stop)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def run(self) -> None:
 | 
					    def run(self) -> None:
 | 
				
			||||||
@ -56,7 +58,6 @@ class Interpolator(multiprocessing.Process):
 | 
				
			|||||||
        logger.opt(colors=True).info(
 | 
					        logger.opt(colors=True).info(
 | 
				
			||||||
            f"Interpolator process <blue>{self.name}</blue> initiating"
 | 
					            f"Interpolator process <blue>{self.name}</blue> initiating"
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        processor_objects = {}
 | 
					 | 
				
			||||||
        while self.running is True:
 | 
					        while self.running is True:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                # pause if pause flag is set
 | 
					                # pause if pause flag is set
 | 
				
			||||||
@ -80,6 +81,7 @@ class Interpolator(multiprocessing.Process):
 | 
				
			|||||||
                if image0 is None:
 | 
					                if image0 is None:
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                # calculate the %diff between the current frame and the previous frame
 | 
				
			||||||
                difference = ImageChops.difference(image0, image1)
 | 
					                difference = ImageChops.difference(image0, image1)
 | 
				
			||||||
                difference_stat = ImageStat.Stat(difference)
 | 
					                difference_stat = ImageStat.Stat(difference)
 | 
				
			||||||
                difference_ratio = (
 | 
					                difference_ratio = (
 | 
				
			||||||
@ -92,10 +94,10 @@ class Interpolator(multiprocessing.Process):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                    # select a processor object with the required settings
 | 
					                    # select a processor object with the required settings
 | 
				
			||||||
                    # create a new object if none are available
 | 
					                    # create a new object if none are available
 | 
				
			||||||
                    processor_object = processor_objects.get(algorithm)
 | 
					                    processor_object = self.processor_objects.get(algorithm)
 | 
				
			||||||
                    if processor_object is None:
 | 
					                    if processor_object is None:
 | 
				
			||||||
                        processor_object = ALGORITHM_CLASSES[algorithm](0)
 | 
					                        processor_object = ALGORITHM_CLASSES[algorithm](0)
 | 
				
			||||||
                        processor_objects[algorithm] = processor_object
 | 
					                        self.processor_objects[algorithm] = processor_object
 | 
				
			||||||
                    interpolated_image = processor_object.process(image0, image1)
 | 
					                    interpolated_image = processor_object.process(image0, image1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                # if the difference is greater than threshold
 | 
					                # if the difference is greater than threshold
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user