Skip to content

Commit

Permalink
adjust dynamic scale
Browse files Browse the repository at this point in the history
  • Loading branch information
TNTwise committed Dec 15, 2024
1 parent cc8532d commit e42be7a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backend/src/pytorch/InterpolateTorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ def hotReload(self):

@torch.inference_mode()
def dynamicScaleCalculation(self,frame1):
closest_value = None
scale = None
if self.CompareNet is not None: # when there is dynamic optical flow scaling enabled.
ssim:torch.Tensor = self.CompareNet(self.frame0, frame1)
possible_values = {0.25:1.5, 0.5:1.25, 1.0:1.0} # closest_value:representative_scale
possible_values = {0.25:0.25, 0.37:0.5, 0.5:1.0, 0.69:1.5, 1.0:2.0} # closest_value:representative_scale
closest_value = min(possible_values, key=lambda v: abs(ssim.item() - v))
closest_value = possible_values[closest_value]
return closest_value
scale = possible_values[closest_value]
return scale

@abstractmethod
@torch.inference_mode()
Expand Down

0 comments on commit e42be7a

Please sign in to comment.