julien-c HF staff commited on
Commit
afc8535
β€’
1 Parent(s): b7b2d07
AnimatedCube/AnimatedCube.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82de770fc82b48a77a33bb26abd4d7e75620491b36ddf98e8dca69fa73dd798c
3
+ size 1860
AnimatedCube/AnimatedCube.gltf ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accessors" : [
3
+ {
4
+ "bufferView" : 0,
5
+ "byteOffset" : 0,
6
+ "componentType" : 5126,
7
+ "count" : 3,
8
+ "max" : [
9
+ 2.000000
10
+ ],
11
+ "min" : [
12
+ 0.000000
13
+ ],
14
+ "type" : "SCALAR"
15
+ },
16
+ {
17
+ "bufferView" : 1,
18
+ "byteOffset" : 0,
19
+ "componentType" : 5126,
20
+ "count" : 3,
21
+ "max" : [
22
+ 0.000000,
23
+ 1.000000,
24
+ 0.000000,
25
+ 1.000000
26
+ ],
27
+ "min" : [
28
+ 0.000000,
29
+ -8.742278e-008,
30
+ 0.000000,
31
+ -1.000000
32
+ ],
33
+ "type" : "VEC4"
34
+ },
35
+ {
36
+ "bufferView" : 2,
37
+ "byteOffset" : 0,
38
+ "componentType" : 5123,
39
+ "count" : 36,
40
+ "max" : [
41
+ 35
42
+ ],
43
+ "min" : [
44
+ 0
45
+ ],
46
+ "type" : "SCALAR"
47
+ },
48
+ {
49
+ "bufferView" : 3,
50
+ "byteOffset" : 0,
51
+ "componentType" : 5126,
52
+ "count" : 36,
53
+ "max" : [
54
+ 1.000000,
55
+ 1.000000,
56
+ 1.000001
57
+ ],
58
+ "min" : [
59
+ -1.000000,
60
+ -1.000000,
61
+ -1.000000
62
+ ],
63
+ "type" : "VEC3"
64
+ },
65
+ {
66
+ "bufferView" : 4,
67
+ "byteOffset" : 0,
68
+ "componentType" : 5126,
69
+ "count" : 36,
70
+ "max" : [
71
+ 1.000000,
72
+ 1.000000,
73
+ 1.000000
74
+ ],
75
+ "min" : [
76
+ -1.000000,
77
+ -1.000000,
78
+ -1.000000
79
+ ],
80
+ "type" : "VEC3"
81
+ },
82
+ {
83
+ "bufferView" : 5,
84
+ "byteOffset" : 0,
85
+ "componentType" : 5126,
86
+ "count" : 36,
87
+ "max" : [
88
+ 1.000000,
89
+ -0.000000,
90
+ -0.000000,
91
+ 1.000000
92
+ ],
93
+ "min" : [
94
+ 0.000000,
95
+ -0.000000,
96
+ -1.000000,
97
+ -1.000000
98
+ ],
99
+ "type" : "VEC4"
100
+ },
101
+ {
102
+ "bufferView" : 6,
103
+ "byteOffset" : 0,
104
+ "componentType" : 5126,
105
+ "count" : 36,
106
+ "max" : [
107
+ 1.000000,
108
+ 1.000000
109
+ ],
110
+ "min" : [
111
+ -1.000000,
112
+ -1.000000
113
+ ],
114
+ "type" : "VEC2"
115
+ }
116
+ ],
117
+ "animations" : [
118
+ {
119
+ "channels" : [
120
+ {
121
+ "sampler" : 0,
122
+ "target" : {
123
+ "node" : 0,
124
+ "path" : "rotation"
125
+ }
126
+ }
127
+ ],
128
+ "name" : "animation_AnimatedCube",
129
+ "samplers" : [
130
+ {
131
+ "input" : 0,
132
+ "interpolation" : "LINEAR",
133
+ "output" : 1
134
+ }
135
+ ]
136
+ }
137
+ ],
138
+ "asset" : {
139
+ "generator" : "VKTS glTF 2.0 exporter",
140
+ "version" : "2.0"
141
+ },
142
+ "bufferViews" : [
143
+ {
144
+ "buffer" : 0,
145
+ "byteLength" : 12,
146
+ "byteOffset" : 0
147
+ },
148
+ {
149
+ "buffer" : 0,
150
+ "byteLength" : 48,
151
+ "byteOffset" : 12
152
+ },
153
+ {
154
+ "buffer" : 0,
155
+ "byteLength" : 72,
156
+ "byteOffset" : 60,
157
+ "target" : 34963
158
+ },
159
+ {
160
+ "buffer" : 0,
161
+ "byteLength" : 432,
162
+ "byteOffset" : 132,
163
+ "target" : 34962
164
+ },
165
+ {
166
+ "buffer" : 0,
167
+ "byteLength" : 432,
168
+ "byteOffset" : 564,
169
+ "target" : 34962
170
+ },
171
+ {
172
+ "buffer" : 0,
173
+ "byteLength" : 576,
174
+ "byteOffset" : 996,
175
+ "target" : 34962
176
+ },
177
+ {
178
+ "buffer" : 0,
179
+ "byteLength" : 288,
180
+ "byteOffset" : 1572,
181
+ "target" : 34962
182
+ }
183
+ ],
184
+ "buffers" : [
185
+ {
186
+ "byteLength" : 1860,
187
+ "uri" : "AnimatedCube.bin"
188
+ }
189
+ ],
190
+ "images" : [
191
+ {
192
+ "uri" : "AnimatedCube_BaseColor.png"
193
+ },
194
+ {
195
+ "uri" : "AnimatedCube_MetallicRoughness.png"
196
+ }
197
+ ],
198
+ "materials" : [
199
+ {
200
+ "name" : "AnimatedCube",
201
+ "pbrMetallicRoughness" : {
202
+ "baseColorTexture" : {
203
+ "index" : 0
204
+ },
205
+ "metallicRoughnessTexture" : {
206
+ "index" : 1
207
+ }
208
+ }
209
+ }
210
+ ],
211
+ "meshes" : [
212
+ {
213
+ "name" : "AnimatedCube",
214
+ "primitives" : [
215
+ {
216
+ "attributes" : {
217
+ "NORMAL" : 4,
218
+ "POSITION" : 3,
219
+ "TANGENT" : 5,
220
+ "TEXCOORD_0" : 6
221
+ },
222
+ "indices" : 2,
223
+ "material" : 0,
224
+ "mode" : 4
225
+ }
226
+ ]
227
+ }
228
+ ],
229
+ "nodes" : [
230
+ {
231
+ "mesh" : 0,
232
+ "name" : "AnimatedCube",
233
+ "rotation" : [
234
+ 0.000000,
235
+ -1.000000,
236
+ 0.000000,
237
+ 0.000000
238
+ ]
239
+ }
240
+ ],
241
+ "samplers" : [
242
+ {}
243
+ ],
244
+ "scene" : 0,
245
+ "scenes" : [
246
+ {
247
+ "nodes" : [
248
+ 0
249
+ ]
250
+ }
251
+ ],
252
+ "textures" : [
253
+ {
254
+ "sampler" : 0,
255
+ "source" : 0
256
+ },
257
+ {
258
+ "sampler" : 0,
259
+ "source" : 1
260
+ }
261
+ ]
262
+ }
AnimatedCube/AnimatedCube_BaseColor.png ADDED
AnimatedCube/AnimatedCube_MetallicRoughness.png ADDED
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
  title: Cube
3
- emoji: 🐠
4
- colorFrom: green
5
- colorTo: purple
6
  sdk: gradio
7
  sdk_version: 2.9.1
8
  app_file: app.py
 
1
  ---
2
  title: Cube
3
+ emoji: 🚚
4
+ colorFrom: orange
5
+ colorTo: red
6
  sdk: gradio
7
  sdk_version: 2.9.1
8
  app_file: app.py
app.py CHANGED
@@ -1,14 +1,15 @@
1
  import tempfile
2
  import gradio as gr
3
- from gradio.inputs import Image
4
  from gradio.outputs import Image3D
5
  from gltflib import GLTF, FileResource
6
 
7
- gltf = GLTF.load('./Avocado.glb')
 
8
 
9
- def load_mesh(im: str):
10
  print(im)
11
- model = gltf.clone()
12
  res = FileResource(im.name)
13
  with tempfile.NamedTemporaryFile(suffix=".glb", delete=False) as file:
14
  model.export(file.name)
@@ -16,8 +17,11 @@ def load_mesh(im: str):
16
 
17
  iface = gr.Interface(
18
  fn=load_mesh,
19
- # inputs=gr.inputs.Image3D(),
20
- inputs=Image(source="canvas", type="file", label="canvas"),
 
 
 
21
  outputs=Image3D(),
22
  live=True,
23
  )
 
1
  import tempfile
2
  import gradio as gr
3
+ from gradio.inputs import Image, Radio
4
  from gradio.outputs import Image3D
5
  from gltflib import GLTF, FileResource
6
 
7
+ avocado = GLTF.load('./Avocado.glb')
8
+ cube = GLTF.load("./AnimatedCube/AnimatedCube.gltf")
9
 
10
+ def load_mesh(im: str, choose: str):
11
  print(im)
12
+ model = (avocado if choose == "avocado" else cube).clone()
13
  res = FileResource(im.name)
14
  with tempfile.NamedTemporaryFile(suffix=".glb", delete=False) as file:
15
  model.export(file.name)
 
17
 
18
  iface = gr.Interface(
19
  fn=load_mesh,
20
+ description="draw on a canvas, get a 3D model",
21
+ inputs=[
22
+ Image(source="canvas", type="file", label="canvas"),
23
+ Radio(choices=["cube", "avocado"], default="cube"),
24
+ ],
25
  outputs=Image3D(),
26
  live=True,
27
  )