Rahatara commited on
Commit
e7aa936
·
verified ·
1 Parent(s): 930800b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -13
app.py CHANGED
@@ -18,9 +18,9 @@ def visualize_texture(section):
18
  sections = {
19
  'upper': np.where(mesh.vertices[:, 2] > mid_z)[0],
20
  'lower': np.where(mesh.vertices[:, 2] <= mid_z)[0],
21
- 'middle': np.where((mesh.vertices[:, 0] > min_bounds[0]) & (mesh.vertices[:, 0] < max_bounds[0]) &
22
- (mesh.vertices[:, 1] > min_bounds[1]) & (mesh.vertices[:, 1] < max_bounds[1]) &
23
- (mesh.vertices[:, 2] > min_bounds[2]) & (mesh.vertices[:, 2] < max_bounds[2]))[0],
24
  'top': np.where(mesh.vertices[:, 1] > mid_y)[0],
25
  'right': np.where(mesh.vertices[:, 0] > mid_x)[0]
26
  }
@@ -45,15 +45,8 @@ with gr.Blocks() as app:
45
  original_model = gr.Model3D('train.glb', label="Original Model")
46
  modified_model = gr.Model3D(label="Textured Model")
47
 
48
- with gr.Row():
49
- button_upper = gr.Button("Texture Upper Part", data="upper")
50
- button_lower = gr.Button("Texture Lower Part", data="lower")
51
- button_middle = gr.Button("Texture Middle", data="middle")
52
- button_top = gr.Button("Texture Top", data="top")
53
- button_right = gr.Button("Texture Right", data="right")
54
-
55
- buttons = [button_upper, button_lower, button_middle, button_top, button_right]
56
- for button in buttons:
57
- button.click(visualize_texture, inputs=button, outputs=modified_model)
58
 
59
  app.launch()
 
18
  sections = {
19
  'upper': np.where(mesh.vertices[:, 2] > mid_z)[0],
20
  'lower': np.where(mesh.vertices[:, 2] <= mid_z)[0],
21
+ 'middle': np.where((mesh.vertices[:, 0] >= min_bounds[0]) & (mesh.vertices[:, 0] <= max_bounds[0]) &
22
+ (mesh.vertices[:, 1] >= min_bounds[1]) & (mesh.vertices[:, 1] <= max_bounds[1]) &
23
+ (mesh.vertices[:, 2] >= min_bounds[2]) & (mesh.vertices[:, 2] <= max_bounds[2]))[0],
24
  'top': np.where(mesh.vertices[:, 1] > mid_y)[0],
25
  'right': np.where(mesh.vertices[:, 0] > mid_x)[0]
26
  }
 
45
  original_model = gr.Model3D('train.glb', label="Original Model")
46
  modified_model = gr.Model3D(label="Textured Model")
47
 
48
+ section_dropdown = gr.Dropdown(options=['upper', 'lower', 'middle', 'top', 'right'], label="Select Section")
49
+ button = gr.Button("Visualize Texture")
50
+ button.click(visualize_texture, inputs=section_dropdown, outputs=modified_model)
 
 
 
 
 
 
 
51
 
52
  app.launch()