Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -161,12 +161,12 @@ def runModel(content, style):
|
|
161 |
if os.path.exists("0.png"):
|
162 |
os.remove("0.png")
|
163 |
gltf = GLTF2().load(content)
|
164 |
-
gltf.convert_images(ImageFormat.FILE,"/tmp/
|
165 |
gltf.images[0].uri
|
166 |
gltf_reinhard = GLTF2().load(content)
|
167 |
gltf_lhm = GLTF2().load(content)
|
168 |
gltf_pccm = GLTF2().load(content)
|
169 |
-
ori_image=PIL.Image.open('/tmp/
|
170 |
ori_image=ori_image.convert('RGB')
|
171 |
content_img = np.array(ori_image)[:, :, :3]
|
172 |
style_img = np.array(style)[:, :, :3]
|
@@ -176,15 +176,15 @@ def runModel(content, style):
|
|
176 |
image_reinhard = PIL.Image.fromarray(output_reinhard,'RGB')
|
177 |
image_lhm = PIL.Image.fromarray(output_lhm,'RGB')
|
178 |
image_pccm = PIL.Image.fromarray(output_pccm,'RGB')
|
179 |
-
image_reinhard=image_reinhard.save('/tmp/
|
180 |
-
image_lhm=image_lhm.save('/tmp/
|
181 |
-
image_pccm=image_pccm.save('/tmp/
|
182 |
image1=Image()
|
183 |
image2=Image()
|
184 |
image3=Image()
|
185 |
-
image1.uri='/tmp/
|
186 |
-
image2.uri='/tmp/
|
187 |
-
image3.uri='/tmp/
|
188 |
gltf_reinhard.images[0]=image1
|
189 |
gltf_lhm.images[0]=image2
|
190 |
gltf_pccm.images[0]=image3
|
@@ -197,10 +197,10 @@ def runModel(content, style):
|
|
197 |
gltf_lhm.images[0].name
|
198 |
gltf_pccm.images[0].uri
|
199 |
gltf_pccm.images[0].name
|
200 |
-
gltf_pccm.save('/tmp/
|
201 |
-
gltf_lhm.save('/tmp/
|
202 |
-
gltf_reinhard.save('/tmp/
|
203 |
-
return '/tmp/
|
204 |
|
205 |
demo = gr.Interface(runModel, [gr.Model3D(),gr.Image(type ='pil')], outputs = [gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="Reinhard"), gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="lhm"), gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="pccm")], )
|
206 |
|
|
|
161 |
if os.path.exists("0.png"):
|
162 |
os.remove("0.png")
|
163 |
gltf = GLTF2().load(content)
|
164 |
+
gltf.convert_images(ImageFormat.FILE,"/tmp/", override=True)
|
165 |
gltf.images[0].uri
|
166 |
gltf_reinhard = GLTF2().load(content)
|
167 |
gltf_lhm = GLTF2().load(content)
|
168 |
gltf_pccm = GLTF2().load(content)
|
169 |
+
ori_image=PIL.Image.open('/tmp/0.png')
|
170 |
ori_image=ori_image.convert('RGB')
|
171 |
content_img = np.array(ori_image)[:, :, :3]
|
172 |
style_img = np.array(style)[:, :, :3]
|
|
|
176 |
image_reinhard = PIL.Image.fromarray(output_reinhard,'RGB')
|
177 |
image_lhm = PIL.Image.fromarray(output_lhm,'RGB')
|
178 |
image_pccm = PIL.Image.fromarray(output_pccm,'RGB')
|
179 |
+
image_reinhard=image_reinhard.save('/tmp/reinhard.png')
|
180 |
+
image_lhm=image_lhm.save('/tmp/lhm.png')
|
181 |
+
image_pccm=image_pccm.save('/tmp/pccm.png')
|
182 |
image1=Image()
|
183 |
image2=Image()
|
184 |
image3=Image()
|
185 |
+
image1.uri='/tmp/reinhard.png'
|
186 |
+
image2.uri='/tmp/lhm.png'
|
187 |
+
image3.uri='/tmp/pccm.png'
|
188 |
gltf_reinhard.images[0]=image1
|
189 |
gltf_lhm.images[0]=image2
|
190 |
gltf_pccm.images[0]=image3
|
|
|
197 |
gltf_lhm.images[0].name
|
198 |
gltf_pccm.images[0].uri
|
199 |
gltf_pccm.images[0].name
|
200 |
+
gltf_pccm.save('/tmp/pccm.glb')
|
201 |
+
gltf_lhm.save('/tmp/lhm.glb')
|
202 |
+
gltf_reinhard.save('/tmp/reinhard.glb')
|
203 |
+
return '/tmp/pccm.glb','/tmp/lhm.glb', '/tmp/reinhard.glb'
|
204 |
|
205 |
demo = gr.Interface(runModel, [gr.Model3D(),gr.Image(type ='pil')], outputs = [gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="Reinhard"), gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="lhm"), gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="pccm")], )
|
206 |
|