Oysiyl commited on
Commit
413ecd6
·
1 Parent(s): bc85fe6

fix torch dynamo issue in freeu

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. comfy_extras/nodes_freelunch.py +10 -6
app.py CHANGED
@@ -401,7 +401,7 @@ else:
401
  )
402
 
403
 
404
- @spaces.GPU(duration=75)
405
  def generate_qr_code_unified(
406
  prompt: str,
407
  text_input: str,
 
401
  )
402
 
403
 
404
+ @spaces.GPU(duration=90)
405
  def generate_qr_code_unified(
406
  prompt: str,
407
  text_input: str,
comfy_extras/nodes_freelunch.py CHANGED
@@ -45,12 +45,14 @@ class FreeU:
45
  scale = scale_dict.get(int(h.shape[1]), None)
46
  if scale is not None:
47
  h[:,:h.shape[1] // 2] = h[:,:h.shape[1] // 2] * scale[0]
48
- if hsp.device not in on_cpu_devices:
 
 
49
  try:
50
  hsp = Fourier_filter(hsp, threshold=1, scale=scale[1])
51
  except:
52
- logging.warning("Device {} does not support the torch.fft functions used in the FreeU node, switching to CPU.".format(hsp.device))
53
- on_cpu_devices[hsp.device] = True
54
  hsp = Fourier_filter(hsp.cpu(), threshold=1, scale=scale[1]).to(hsp.device)
55
  else:
56
  hsp = Fourier_filter(hsp.cpu(), threshold=1, scale=scale[1]).to(hsp.device)
@@ -91,12 +93,14 @@ class FreeU_V2:
91
 
92
  h[:,:h.shape[1] // 2] = h[:,:h.shape[1] // 2] * ((scale[0] - 1 ) * hidden_mean + 1)
93
 
94
- if hsp.device not in on_cpu_devices:
 
 
95
  try:
96
  hsp = Fourier_filter(hsp, threshold=1, scale=scale[1])
97
  except:
98
- logging.warning("Device {} does not support the torch.fft functions used in the FreeU node, switching to CPU.".format(hsp.device))
99
- on_cpu_devices[hsp.device] = True
100
  hsp = Fourier_filter(hsp.cpu(), threshold=1, scale=scale[1]).to(hsp.device)
101
  else:
102
  hsp = Fourier_filter(hsp.cpu(), threshold=1, scale=scale[1]).to(hsp.device)
 
45
  scale = scale_dict.get(int(h.shape[1]), None)
46
  if scale is not None:
47
  h[:,:h.shape[1] // 2] = h[:,:h.shape[1] // 2] * scale[0]
48
+ # Convert device to string for torch.compile compatibility
49
+ device_str = str(hsp.device)
50
+ if device_str not in on_cpu_devices:
51
  try:
52
  hsp = Fourier_filter(hsp, threshold=1, scale=scale[1])
53
  except:
54
+ logging.warning("Device {} does not support the torch.fft functions used in the FreeU node, switching to CPU.".format(device_str))
55
+ on_cpu_devices[device_str] = True
56
  hsp = Fourier_filter(hsp.cpu(), threshold=1, scale=scale[1]).to(hsp.device)
57
  else:
58
  hsp = Fourier_filter(hsp.cpu(), threshold=1, scale=scale[1]).to(hsp.device)
 
93
 
94
  h[:,:h.shape[1] // 2] = h[:,:h.shape[1] // 2] * ((scale[0] - 1 ) * hidden_mean + 1)
95
 
96
+ # Convert device to string for torch.compile compatibility
97
+ device_str = str(hsp.device)
98
+ if device_str not in on_cpu_devices:
99
  try:
100
  hsp = Fourier_filter(hsp, threshold=1, scale=scale[1])
101
  except:
102
+ logging.warning("Device {} does not support the torch.fft functions used in the FreeU node, switching to CPU.".format(device_str))
103
+ on_cpu_devices[device_str] = True
104
  hsp = Fourier_filter(hsp.cpu(), threshold=1, scale=scale[1]).to(hsp.device)
105
  else:
106
  hsp = Fourier_filter(hsp.cpu(), threshold=1, scale=scale[1]).to(hsp.device)