Spaces:
Runtime error
Runtime error
drop ply format to enable frontend upload of glb
Browse files- files/horse.glb +3 -0
- files/{horse.ply.output → horse.glb.output}/output.glb +0 -0
- files/horse.ply +0 -0
- main.py +3 -21
files/horse.glb
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3259cfd706e72e1b3562e7ced8adacda42f32ee9adcec2e37e90d9ec431b87e6
|
| 3 |
+
size 30952
|
files/{horse.ply.output → horse.glb.output}/output.glb
RENAMED
|
File without changes
|
files/horse.ply
DELETED
|
Binary file (31.9 kB)
|
|
|
main.py
CHANGED
|
@@ -3,7 +3,6 @@ from __future__ import annotations
|
|
| 3 |
import math
|
| 4 |
import os
|
| 5 |
import subprocess
|
| 6 |
-
from pathlib import Path
|
| 7 |
|
| 8 |
import gradio as gr
|
| 9 |
import pygltflib
|
|
@@ -72,23 +71,6 @@ def add_lights(path_input, path_output):
|
|
| 72 |
glb.save(path_output)
|
| 73 |
|
| 74 |
|
| 75 |
-
class Model3D(gr.Model3D):
|
| 76 |
-
"""
|
| 77 |
-
A simple overload of Gradio Model3D that accepts arbitrary 3D formats supported by trimesh.
|
| 78 |
-
"""
|
| 79 |
-
|
| 80 |
-
def postprocess(self, y: str | Path | None) -> dict[str, str] | None:
|
| 81 |
-
"""
|
| 82 |
-
Converts user input 3D model in any format acceptable by trimesh to glb, required by the web component
|
| 83 |
-
:param y: path to input 3D model
|
| 84 |
-
:return: file name mapped to base64 url data
|
| 85 |
-
"""
|
| 86 |
-
if y is not None:
|
| 87 |
-
y = convert_formats(y, "glb")
|
| 88 |
-
out = super().postprocess(y)
|
| 89 |
-
return out
|
| 90 |
-
|
| 91 |
-
|
| 92 |
def breathe_new_life_into_3d_model(path_input, prompt, path_output=None):
|
| 93 |
"""
|
| 94 |
Paints the input 3D model using the following method:
|
|
@@ -169,7 +151,7 @@ def run():
|
|
| 169 |
thumbnail="thumbnail.jpg",
|
| 170 |
fn=breathe_new_life_into_3d_model,
|
| 171 |
inputs=[
|
| 172 |
-
Model3D(
|
| 173 |
camera_position=(30.0, 90.0, 3.0),
|
| 174 |
elem_classes="viewport",
|
| 175 |
label="Input Model",
|
|
@@ -188,10 +170,10 @@ def run():
|
|
| 188 |
],
|
| 189 |
examples=[
|
| 190 |
[
|
| 191 |
-
os.path.join(os.path.dirname(__file__), "files/horse.
|
| 192 |
"pastel superhero unicorn",
|
| 193 |
os.path.join(
|
| 194 |
-
os.path.dirname(__file__), "files/horse.
|
| 195 |
),
|
| 196 |
],
|
| 197 |
],
|
|
|
|
| 3 |
import math
|
| 4 |
import os
|
| 5 |
import subprocess
|
|
|
|
| 6 |
|
| 7 |
import gradio as gr
|
| 8 |
import pygltflib
|
|
|
|
| 71 |
glb.save(path_output)
|
| 72 |
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
def breathe_new_life_into_3d_model(path_input, prompt, path_output=None):
|
| 75 |
"""
|
| 76 |
Paints the input 3D model using the following method:
|
|
|
|
| 151 |
thumbnail="thumbnail.jpg",
|
| 152 |
fn=breathe_new_life_into_3d_model,
|
| 153 |
inputs=[
|
| 154 |
+
gr.Model3D(
|
| 155 |
camera_position=(30.0, 90.0, 3.0),
|
| 156 |
elem_classes="viewport",
|
| 157 |
label="Input Model",
|
|
|
|
| 170 |
],
|
| 171 |
examples=[
|
| 172 |
[
|
| 173 |
+
os.path.join(os.path.dirname(__file__), "files/horse.glb"),
|
| 174 |
"pastel superhero unicorn",
|
| 175 |
os.path.join(
|
| 176 |
+
os.path.dirname(__file__), "files/horse.glb.output/output.glb"
|
| 177 |
),
|
| 178 |
],
|
| 179 |
],
|