lemonaddie commited on
Commit
ef5dcbb
·
verified ·
1 Parent(s): 52abdb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -44
app.py CHANGED
@@ -10,8 +10,6 @@ from PIL import Image
10
 
11
  from gradio_imageslider import ImageSlider
12
 
13
- from extrude import extrude_depth_3d
14
-
15
 
16
  def process(
17
  pipe,
@@ -86,48 +84,6 @@ def process_3d(
86
  if plane_near >= plane_far:
87
  raise gr.Error("NEAR plane must have a value smaller than the FAR plane")
88
 
89
- def _process_3d(size_longest_px, filter_size, vertex_colors, scene_lights, output_model_scale=None):
90
- image_rgb = input_image
91
- image_depth = files[0]
92
-
93
- image_rgb_basename, image_rgb_ext = os.path.splitext(image_rgb)
94
- image_depth_basename, image_depth_ext = os.path.splitext(image_depth)
95
-
96
- image_rgb_content = Image.open(image_rgb)
97
- image_rgb_w, image_rgb_h = image_rgb_content.width, image_rgb_content.height
98
- image_rgb_d = max(image_rgb_w, image_rgb_h)
99
- image_new_w = size_longest_px * image_rgb_w // image_rgb_d
100
- image_new_h = size_longest_px * image_rgb_h // image_rgb_d
101
-
102
- image_rgb_new = image_rgb_basename + f"_{size_longest_px}" + image_rgb_ext
103
- image_depth_new = image_depth_basename + f"_{size_longest_px}" + image_depth_ext
104
- image_rgb_content.resize((image_new_w, image_new_h), Image.LANCZOS).save(
105
- image_rgb_new
106
- )
107
- Image.open(image_depth).resize((image_new_w, image_new_h), Image.LANCZOS).save(
108
- image_depth_new
109
- )
110
-
111
- path_glb, path_stl = extrude_depth_3d(
112
- image_rgb_new,
113
- image_depth_new,
114
- output_model_scale=size_longest_cm * 10 if output_model_scale is None else output_model_scale,
115
- filter_size=filter_size,
116
- coef_near=plane_near,
117
- coef_far=plane_far,
118
- emboss=embossing / 100,
119
- f_thic=frame_thickness / 100,
120
- f_near=frame_near / 100,
121
- f_back=frame_far / 100,
122
- vertex_colors=vertex_colors,
123
- scene_lights=scene_lights,
124
- )
125
-
126
- return path_glb, path_stl
127
-
128
- path_viewer_glb, _ = _process_3d(256, filter_size, vertex_colors=False, scene_lights=True, output_model_scale=1)
129
- path_files_glb, path_files_stl = _process_3d(size_longest_px, filter_size, vertex_colors=True, scene_lights=False)
130
-
131
  # sanitize 3d viewer glb path to keep babylon.js happy
132
  path_viewer_glb_sanitized = os.path.join(os.path.dirname(path_viewer_glb), "preview.glb")
133
  if path_viewer_glb_sanitized != path_viewer_glb:
 
10
 
11
  from gradio_imageslider import ImageSlider
12
 
 
 
13
 
14
  def process(
15
  pipe,
 
84
  if plane_near >= plane_far:
85
  raise gr.Error("NEAR plane must have a value smaller than the FAR plane")
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  # sanitize 3d viewer glb path to keep babylon.js happy
88
  path_viewer_glb_sanitized = os.path.join(os.path.dirname(path_viewer_glb), "preview.glb")
89
  if path_viewer_glb_sanitized != path_viewer_glb: