huzey commited on
Commit
40154bc
1 Parent(s): 094608c

fix eigvecs

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -169,6 +169,7 @@ def compute_ncut(
169
 
170
  if only_eigvecs:
171
  eigvecs = eigvecs.to("cpu").reshape(features.shape[:-1] + (num_eig,))
 
172
  return None, logging_str, eigvecs
173
 
174
  start = time.time()
@@ -3443,7 +3444,7 @@ with demo:
3443
 
3444
 
3445
  with gr.Tab('PlayGround (test)', visible=False) as test_playground_tab:
3446
- eigvecs = gr.State(torch.tensor([]))
3447
  with gr.Row():
3448
  with gr.Column(scale=5, min_width=200):
3449
  gr.Markdown("### Step 1: Load Images and Run NCUT")
@@ -3605,6 +3606,7 @@ with demo:
3605
  @torch.no_grad()
3606
  def run_heatmap(images, eigvecs, image1_slider, prompt_image1, n_eig, distance_slider, flat_idx=None, overlay_image=True):
3607
  gr.Info(f"current number of eigenvectors: {n_eig}")
 
3608
  images = [image[0] for image in images]
3609
  if isinstance(images[0], str):
3610
  images = [Image.open(image[0]).convert("RGB").resize((256, 256)) for image in images]
@@ -3711,7 +3713,7 @@ with demo:
3711
  )
3712
 
3713
  with gr.Tab('PlayGround', visible=True) as test_playground_tab2:
3714
- eigvecs = gr.State(torch.tensor([]))
3715
  with gr.Row():
3716
  with gr.Column(scale=5, min_width=200):
3717
  gr.Markdown("### Step 1: Load Images")
@@ -3856,6 +3858,7 @@ with demo:
3856
  @torch.no_grad()
3857
  def run_heatmap(images, eigvecs, image1_slider, prompt_image1, n_eig, distance_slider, flat_idx=None, overlay_image=True):
3858
  gr.Info(f"current number of eigenvectors: {n_eig}", 2)
 
3859
  images = [image[0] for image in images]
3860
  if isinstance(images[0], str):
3861
  images = [Image.open(image[0]).convert("RGB").resize((256, 256)) for image in images]
 
169
 
170
  if only_eigvecs:
171
  eigvecs = eigvecs.to("cpu").reshape(features.shape[:-1] + (num_eig,))
172
+ eigvecs = eigvecs.detach().numpy()
173
  return None, logging_str, eigvecs
174
 
175
  start = time.time()
 
3444
 
3445
 
3446
  with gr.Tab('PlayGround (test)', visible=False) as test_playground_tab:
3447
+ eigvecs = gr.State(np.array([]))
3448
  with gr.Row():
3449
  with gr.Column(scale=5, min_width=200):
3450
  gr.Markdown("### Step 1: Load Images and Run NCUT")
 
3606
  @torch.no_grad()
3607
  def run_heatmap(images, eigvecs, image1_slider, prompt_image1, n_eig, distance_slider, flat_idx=None, overlay_image=True):
3608
  gr.Info(f"current number of eigenvectors: {n_eig}")
3609
+ eigvecs = torch.tensor(eigvecs)
3610
  images = [image[0] for image in images]
3611
  if isinstance(images[0], str):
3612
  images = [Image.open(image[0]).convert("RGB").resize((256, 256)) for image in images]
 
3713
  )
3714
 
3715
  with gr.Tab('PlayGround', visible=True) as test_playground_tab2:
3716
+ eigvecs = gr.State(np.array([]))
3717
  with gr.Row():
3718
  with gr.Column(scale=5, min_width=200):
3719
  gr.Markdown("### Step 1: Load Images")
 
3858
  @torch.no_grad()
3859
  def run_heatmap(images, eigvecs, image1_slider, prompt_image1, n_eig, distance_slider, flat_idx=None, overlay_image=True):
3860
  gr.Info(f"current number of eigenvectors: {n_eig}", 2)
3861
+ eigvecs = torch.tensor(eigvecs)
3862
  images = [image[0] for image in images]
3863
  if isinstance(images[0], str):
3864
  images = [Image.open(image[0]).convert("RGB").resize((256, 256)) for image in images]