ruslanmv commited on
Commit
a6d6080
1 Parent(s): d077c9a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -9
app.py CHANGED
@@ -25,6 +25,7 @@ else:
25
  "runwayml/stable-diffusion-inpainting"
26
  ).to(device)
27
 
 
28
  DEFAULT_OBJ_FILE = "female.obj"
29
  DEFAULT_GLB_FILE = "vroid_girl1.glb"
30
  DEFAULT_VRM_FILE = "fischl.vrm"
@@ -229,6 +230,20 @@ def update_texture_display(prompt, texture_file, num_inference_steps):
229
  return Image.open(texture_file)
230
  return None
231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  with gr.Blocks() as demo:
233
  gr.Markdown("## 3D Object Viewer with Custom Texture, UV Scale, Transparency, Color, and Adjustable Lighting")
234
 
@@ -288,17 +303,17 @@ with gr.Blocks() as demo:
288
  texture_file.change(fn=update_texture_display, inputs=[prompt_input, texture_file, num_inference_steps_slider], outputs=texture_preview)
289
 
290
  demo.load(fn=update_display, inputs=[obj_file, texture_file, uv_scale_slider, uv_quality_dropdown, light_intensity_slider, ambient_intensity_slider, transparency_slider, color_picker, num_inference_steps_slider], outputs=display)
291
-
292
-
293
-
294
-
295
  gr.Examples(
296
- examples=[[DEFAULT_VRM_FILE, DEFAULT_TEXTURE],
297
- [DEFAULT_OBJ_FILE, None],
298
- [DEFAULT_GLB_FILE, None],
299
- [DEFAULT_VRM_FILE2, DEFAULT_TEXTURE2],
300
- [DEFAULT_VRM_FILE3, DEFAULT_TEXTURE3]],
 
 
301
  inputs=[obj_file, texture_file],
 
 
302
  label="Example Files"
303
  )
304
 
 
25
  "runwayml/stable-diffusion-inpainting"
26
  ).to(device)
27
 
28
+
29
  DEFAULT_OBJ_FILE = "female.obj"
30
  DEFAULT_GLB_FILE = "vroid_girl1.glb"
31
  DEFAULT_VRM_FILE = "fischl.vrm"
 
230
  return Image.open(texture_file)
231
  return None
232
 
233
+ def load_example(obj_file, texture_file):
234
+ """Loads and displays an example 3D object with texture."""
235
+ file_extension = obj_file.split('.')[-1].lower()
236
+ texture_image = None
237
+ if texture_file:
238
+ texture_image = Image.open(texture_file)
239
+
240
+ if file_extension == 'vrm':
241
+ return display_3d_object(obj_file, texture_image, 0.8, 0.5, "#D3D3D3", 1.0, 1.0, 'medium') # Using default values for other parameters
242
+ else:
243
+ return display_3d_object(obj_file, texture_image, 0.8, 0.5, "#D3D3D3", 1.0, 1.0) # Using default values for other parameters
244
+
245
+
246
+
247
  with gr.Blocks() as demo:
248
  gr.Markdown("## 3D Object Viewer with Custom Texture, UV Scale, Transparency, Color, and Adjustable Lighting")
249
 
 
303
  texture_file.change(fn=update_texture_display, inputs=[prompt_input, texture_file, num_inference_steps_slider], outputs=texture_preview)
304
 
305
  demo.load(fn=update_display, inputs=[obj_file, texture_file, uv_scale_slider, uv_quality_dropdown, light_intensity_slider, ambient_intensity_slider, transparency_slider, color_picker, num_inference_steps_slider], outputs=display)
 
 
 
 
306
  gr.Examples(
307
+ examples=[
308
+ [DEFAULT_VRM_FILE, DEFAULT_TEXTURE],
309
+ [DEFAULT_OBJ_FILE, None],
310
+ [DEFAULT_GLB_FILE, None],
311
+ [DEFAULT_VRM_FILE2, DEFAULT_TEXTURE2],
312
+ [DEFAULT_VRM_FILE3, DEFAULT_TEXTURE3]
313
+ ],
314
  inputs=[obj_file, texture_file],
315
+ outputs=display, # Specify the output component
316
+ fn=load_example, # Specify the function to load the example
317
  label="Example Files"
318
  )
319