Hyphonical commited on
Commit
5a7f927
·
1 Parent(s): 263de18

📽️ Fix Overlapping Again, Added A Forceful Upload Every x Frames

Browse files
Files changed (1) hide show
  1. App.py +20 -9
App.py CHANGED
@@ -204,6 +204,7 @@ class Upscaler:
204
  CurrentFrameIndex = 0
205
  PrevFrame = None
206
  UpscaledPrevFrame = None
 
207
 
208
  while True:
209
  Ret, Frame = Video.read()
@@ -212,7 +213,13 @@ class Upscaler:
212
 
213
  CurrentFrameIndex += 1
214
 
215
- ForceFull = (CurrentFrameIndex == 1 or not InputUseRegions or (InputFullFrameInterval > 0 and CurrentFrameIndex % InputFullFrameInterval == 0))
 
 
 
 
 
 
216
 
217
  if ForceFull:
218
  OutputFrame = self.UpscaleFullFrame(Model, Frame)
@@ -224,6 +231,10 @@ class Upscaler:
224
  OutputFrame, SimilarityPercentage, Rectangles, RegionLog, UseRegions = self.UpscaleRegions(
225
  Model, Frame, PrevFrame, UpscaledPrevFrame, InputThreshold, InputMinPercentage, InputMaxRectangles, InputPadding, InputSegmentRows, InputSegmentColumns
226
  )
 
 
 
 
227
 
228
  if Times:
229
  AverageTime = sum(Times) / len(Times)
@@ -333,7 +344,7 @@ with App.Blocks(
333
  )
334
  InputThreshold = App.Slider(
335
  label='Threshold',
336
- value=1,
337
  minimum=0,
338
  maximum=10,
339
  step=0.5,
@@ -360,9 +371,9 @@ with App.Blocks(
360
  )
361
  InputMaxRectangles = App.Slider(
362
  label='Max Rectangles',
363
- value=8,
364
  minimum=1,
365
- maximum=15,
366
  step=1,
367
  info='Maximum number of rectangles to consider upscaling the full frame',
368
  interactive=False
@@ -370,18 +381,18 @@ with App.Blocks(
370
  with App.Row():
371
  InputSegmentRows = App.Slider(
372
  label='Segment Rows',
373
- value=12,
374
  minimum=1,
375
- maximum=20,
376
  step=1,
377
  info='Number of rows to segment the video into for processing',
378
  interactive=False
379
  )
380
  InputSegmentColumns = App.Slider(
381
  label='Segment Columns',
382
- value=20,
383
  minimum=1,
384
- maximum=30,
385
  step=1,
386
  info='Number of columns to segment the video into for processing',
387
  interactive=False
@@ -390,7 +401,7 @@ with App.Blocks(
390
  label='Full Frame Interval',
391
  value=5,
392
  minimum=1,
393
- maximum=30,
394
  step=1,
395
  info='Force a full-frame upscale every N frames (set to 1 to always upscale full frame)',
396
  interactive=False
 
204
  CurrentFrameIndex = 0
205
  PrevFrame = None
206
  UpscaledPrevFrame = None
207
+ PartialUpscaleCount = 0
208
 
209
  while True:
210
  Ret, Frame = Video.read()
 
213
 
214
  CurrentFrameIndex += 1
215
 
216
+ ForceFull = False
217
+ if CurrentFrameIndex == 1 or not InputUseRegions:
218
+ ForceFull = True
219
+ PartialUpscaleCount = 0
220
+ elif PartialUpscaleCount >= InputFullFrameInterval:
221
+ ForceFull = True
222
+ PartialUpscaleCount = 0
223
 
224
  if ForceFull:
225
  OutputFrame = self.UpscaleFullFrame(Model, Frame)
 
231
  OutputFrame, SimilarityPercentage, Rectangles, RegionLog, UseRegions = self.UpscaleRegions(
232
  Model, Frame, PrevFrame, UpscaledPrevFrame, InputThreshold, InputMinPercentage, InputMaxRectangles, InputPadding, InputSegmentRows, InputSegmentColumns
233
  )
234
+ if UseRegions:
235
+ PartialUpscaleCount += 1
236
+ else:
237
+ PartialUpscaleCount = 0
238
 
239
  if Times:
240
  AverageTime = sum(Times) / len(Times)
 
344
  )
345
  InputThreshold = App.Slider(
346
  label='Threshold',
347
+ value=2,
348
  minimum=0,
349
  maximum=10,
350
  step=0.5,
 
371
  )
372
  InputMaxRectangles = App.Slider(
373
  label='Max Rectangles',
374
+ value=10,
375
  minimum=1,
376
+ maximum=16,
377
  step=1,
378
  info='Maximum number of rectangles to consider upscaling the full frame',
379
  interactive=False
 
381
  with App.Row():
382
  InputSegmentRows = App.Slider(
383
  label='Segment Rows',
384
+ value=32,
385
  minimum=1,
386
+ maximum=64,
387
  step=1,
388
  info='Number of rows to segment the video into for processing',
389
  interactive=False
390
  )
391
  InputSegmentColumns = App.Slider(
392
  label='Segment Columns',
393
+ value=48,
394
  minimum=1,
395
+ maximum=64,
396
  step=1,
397
  info='Number of columns to segment the video into for processing',
398
  interactive=False
 
401
  label='Full Frame Interval',
402
  value=5,
403
  minimum=1,
404
+ maximum=100,
405
  step=1,
406
  info='Force a full-frame upscale every N frames (set to 1 to always upscale full frame)',
407
  interactive=False