Sirreajohn commited on
Commit
cc4de1c
·
verified ·
1 Parent(s): 912fa34

gallery errors, duck you hf, you broke my script cause your shitty standards

Browse files
Files changed (1) hide show
  1. app.py +33 -50
app.py CHANGED
@@ -33,8 +33,6 @@ elif DEVICE == "cuda" and not torch.cuda.is_available():
33
  DEVICE = "cpu"
34
 
35
 
36
- # Allow Gradio to serve files directly from the HF bucket
37
-
38
  gr.set_static_paths(
39
  paths=[
40
  str(RENDERS_DIR),
@@ -125,6 +123,7 @@ def search_models(prompt, threshold, n_results):
125
  [
126
  str(f)
127
  for f in item_renders_dir.glob("*.png")
 
128
  ]
129
  )
130
 
@@ -137,7 +136,7 @@ def search_models(prompt, threshold, n_results):
137
  candidates.append({
138
  "id": item_id,
139
  "caption": caption,
140
- "distance": round(dist, 4),
141
  "thumbnail": thumbnail,
142
  "renders": render_files,
143
  })
@@ -146,7 +145,7 @@ def search_models(prompt, threshold, n_results):
146
  gallery_items.append(
147
  (
148
  thumbnail,
149
- f"Dist: {round(dist, 4)}\n{caption}"
150
  )
151
  )
152
 
@@ -186,9 +185,7 @@ def search_and_display(prompt, threshold, n_results):
186
  - **Status**: {"✅ 3D Model Loaded" if model_val else "⚠️ GLB file not found"}
187
  """
188
 
189
- # Dropdown uses indexes instead of file paths.
190
- # This avoids Gradio trying to validate gallery files
191
- # when the user selects a result.
192
 
193
  choices = [
194
  (
@@ -338,9 +335,8 @@ with gr.Blocks(title="3D RAG Explorer") as demo:
338
  inputs=[
339
  prompt,
340
  threshold,
341
- n_results
342
  ],
343
- outputs=[],
344
  )
345
 
346
  # RIGHT COLUMN (3D Model, Information, Result Selector, Multi View Renders)
@@ -405,52 +401,39 @@ with gr.Blocks(title="3D RAG Explorer") as demo:
405
  )
406
 
407
 
408
- # Bind actions
409
-
410
- search_outputs = [
411
- results_gallery,
412
- state_candidates,
413
- model_selector,
414
- model_viewer,
415
- metadata_card,
416
- renders_gallery
417
- ]
418
 
419
- search_btn.click(
420
- fn=search_and_display,
421
- inputs=[
422
- prompt,
423
- threshold,
424
- n_results
425
- ],
426
- outputs=search_outputs
427
- )
428
-
429
- model_selector.change(
430
- fn=load_selected_model,
431
- inputs=[
432
  model_selector,
433
- state_candidates
434
- ],
435
- outputs=[
436
  model_viewer,
437
  metadata_card,
438
- renders_gallery
439
  ]
440
- )
441
-
442
 
443
- # Examples
 
 
 
 
 
 
 
 
444
 
445
- examples_comp.click(
446
- fn=search_and_display,
447
- inputs=[
448
- prompt,
449
- threshold,
450
- n_results
451
- ],
452
- outputs=search_outputs
453
- )
 
 
 
454
 
455
 
456
  if __name__ == "__main__":
@@ -460,7 +443,7 @@ if __name__ == "__main__":
460
  server_port=7860,
461
  allowed_paths=[
462
  str(RENDERS_DIR),
463
- str(MODELS_DIR)
464
  ],
465
- ssr_mode=False
466
  )
 
33
  DEVICE = "cpu"
34
 
35
 
 
 
36
  gr.set_static_paths(
37
  paths=[
38
  str(RENDERS_DIR),
 
123
  [
124
  str(f)
125
  for f in item_renders_dir.glob("*.png")
126
+ if f.is_file()
127
  ]
128
  )
129
 
 
136
  candidates.append({
137
  "id": item_id,
138
  "caption": caption,
139
+ "distance": round(float(dist), 4),
140
  "thumbnail": thumbnail,
141
  "renders": render_files,
142
  })
 
145
  gallery_items.append(
146
  (
147
  thumbnail,
148
+ f"Dist: {round(float(dist), 4)}\n{caption}"
149
  )
150
  )
151
 
 
185
  - **Status**: {"✅ 3D Model Loaded" if model_val else "⚠️ GLB file not found"}
186
  """
187
 
188
+ # Use candidate indexes for selection instead of file paths
 
 
189
 
190
  choices = [
191
  (
 
335
  inputs=[
336
  prompt,
337
  threshold,
338
+ n_results,
339
  ],
 
340
  )
341
 
342
  # RIGHT COLUMN (3D Model, Information, Result Selector, Multi View Renders)
 
401
  )
402
 
403
 
404
+ # Bind actions
 
 
 
 
 
 
 
 
 
405
 
406
+ search_outputs = [
407
+ results_gallery,
408
+ state_candidates,
 
 
 
 
 
 
 
 
 
 
409
  model_selector,
 
 
 
410
  model_viewer,
411
  metadata_card,
412
+ renders_gallery,
413
  ]
 
 
414
 
415
+ search_btn.click(
416
+ fn=search_and_display,
417
+ inputs=[
418
+ prompt,
419
+ threshold,
420
+ n_results,
421
+ ],
422
+ outputs=search_outputs,
423
+ )
424
 
425
+ model_selector.change(
426
+ fn=load_selected_model,
427
+ inputs=[
428
+ model_selector,
429
+ state_candidates,
430
+ ],
431
+ outputs=[
432
+ model_viewer,
433
+ metadata_card,
434
+ renders_gallery,
435
+ ],
436
+ )
437
 
438
 
439
  if __name__ == "__main__":
 
443
  server_port=7860,
444
  allowed_paths=[
445
  str(RENDERS_DIR),
446
+ str(MODELS_DIR),
447
  ],
448
+ ssr_mode=False,
449
  )