ziqima commited on
Commit
64c5824
1 Parent(s): 727795d

cleanup readme and raise errors

Browse files
Files changed (2) hide show
  1. README copy.md +0 -12
  2. app.py +8 -3
README copy.md DELETED
@@ -1,12 +0,0 @@
1
- ---
2
- title: Find3D
3
- emoji: 🔥
4
- colorFrom: gray
5
- colorTo: indigo
6
- sdk: gradio
7
- sdk_version: 5.5.0
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -46,10 +46,14 @@ def predict(pcd_path, inference_mode, part_queries):
46
  xyz, rgb, normal = read_pcd(pcd_path)
47
  if inference_mode == "Segmentation":
48
  parts = [part.strip(" ") for part in re.split(r'[,;.|]', part_queries)]
 
 
49
  seg_rgb = segment_obj(xyz, rgb, normal, parts).cpu().numpy()
50
  legend = get_legend(parts)
51
  return render_point_cloud(xyz, seg_rgb, legend=legend)
52
  elif inference_mode == "Localization":
 
 
53
  heatmap_rgb = get_heatmap(xyz, rgb, normal, part_queries).cpu().numpy()
54
  return render_point_cloud(xyz, heatmap_rgb)
55
  else:
@@ -64,10 +68,11 @@ def on_select(evt: gr.SelectData):
64
  with gr.Blocks(theme=gr.themes.Default(text_size="lg", radius_size="none")) as demo:
65
  gr.HTML(
66
  '''<h1 text-align="center">Find Any Part in 3D</h1>
67
- <p style='font-size: 16px;'>This is a demo for Find3D: Find Any Part in 3D! Two modes are supported: segmentation and localization.
68
- For segmentation mode, please provide multiple part queries in the "queries" text box, in the format of comma-separated string, such as "part1,part2,part3".
69
  After hitting "Run", the model will segment the object into the provided parts.
70
- For localization mode, please only provide one query string in the "queries" text box. After hitting "Run", the model will generate a heatmap for the provided query text.
 
71
  Please click on the buttons below "Objaverse" and "In the Wild" for some examples. You can also upload your own .pcd files.</p>
72
  <p style='font-size: 16px;'>Hint:
73
  When uploading your own point cloud, please first close the existing point cloud by clicking on the "x" button.
 
46
  xyz, rgb, normal = read_pcd(pcd_path)
47
  if inference_mode == "Segmentation":
48
  parts = [part.strip(" ") for part in re.split(r'[,;.|]', part_queries)]
49
+ if len(parts)< 2:
50
+ raise gr.Error("For segmentation mode, please provide 2 or more parts", duration=5)
51
  seg_rgb = segment_obj(xyz, rgb, normal, parts).cpu().numpy()
52
  legend = get_legend(parts)
53
  return render_point_cloud(xyz, seg_rgb, legend=legend)
54
  elif inference_mode == "Localization":
55
+ if "," in part_queries or ";" in part_queries or "." in part_queries:
56
+ raise gr.Error("For localization mode, please provide only one part", duration=5)
57
  heatmap_rgb = get_heatmap(xyz, rgb, normal, part_queries).cpu().numpy()
58
  return render_point_cloud(xyz, heatmap_rgb)
59
  else:
 
68
  with gr.Blocks(theme=gr.themes.Default(text_size="lg", radius_size="none")) as demo:
69
  gr.HTML(
70
  '''<h1 text-align="center">Find Any Part in 3D</h1>
71
+ <p style='font-size: 16px;'>This is a demo for Find3D: Find Any Part in 3D! Two modes are supported: <b>segmentation</b> and <b>localization</b>.
72
+ For <b>segmentation mode</b>, please provide multiple part queries in the "queries" text box, in the format of comma-separated string, such as "part1,part2,part3".
73
  After hitting "Run", the model will segment the object into the provided parts.
74
+ <br>
75
+ For <b>localization mode<b>, please only provide one query string in the "queries" text box. After hitting "Run", the model will generate a heatmap for the provided query text.
76
  Please click on the buttons below "Objaverse" and "In the Wild" for some examples. You can also upload your own .pcd files.</p>
77
  <p style='font-size: 16px;'>Hint:
78
  When uploading your own point cloud, please first close the existing point cloud by clicking on the "x" button.