Spaces:
Running
Running
download buttons
Browse files
119_image.png
ADDED
![]() |
app.py
CHANGED
@@ -11,6 +11,10 @@ from PIL import Image
|
|
11 |
import math
|
12 |
from obj2html import obj2html
|
13 |
|
|
|
|
|
|
|
|
|
14 |
minDepth=10
|
15 |
maxDepth=1000
|
16 |
def my_DepthNorm(x, maxDepth):
|
@@ -87,7 +91,7 @@ def create_obj(img, objPath='model.obj', mtlPath='model.mtl', matName='colored',
|
|
87 |
vete(v2, v2) + " " + vete(v3, v3) + "\n")
|
88 |
f.write("f " + vete(v3, v3) + " " +
|
89 |
vete(v2, v2) + " " + vete(v4, v4) + "\n")
|
90 |
-
|
91 |
class UpSample(nn.Sequential):
|
92 |
def __init__(self, skip_input, output_features):
|
93 |
super(UpSample, self).__init__()
|
@@ -164,7 +168,8 @@ def predict(inp):
|
|
164 |
|
165 |
return img, html_string
|
166 |
|
167 |
-
|
|
|
168 |
|
169 |
uploader = st.file_uploader('Upload your portrait here',type=['jpg','jpeg','png'])
|
170 |
|
@@ -172,11 +177,17 @@ if uploader is not None:
|
|
172 |
pil_image = Image.open(uploader)
|
173 |
pil_depth, html_string = predict(pil_image)
|
174 |
|
175 |
-
|
|
|
|
|
|
|
176 |
with col1:
|
177 |
st.image(pil_image)
|
178 |
with col2:
|
179 |
st.image(pil_depth)
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
|
11 |
import math
|
12 |
from obj2html import obj2html
|
13 |
|
14 |
+
from io import BytesIO
|
15 |
+
import base64
|
16 |
+
|
17 |
+
# DEPTH IMAGE TO OBJ
|
18 |
minDepth=10
|
19 |
maxDepth=1000
|
20 |
def my_DepthNorm(x, maxDepth):
|
|
|
91 |
vete(v2, v2) + " " + vete(v3, v3) + "\n")
|
92 |
f.write("f " + vete(v3, v3) + " " +
|
93 |
vete(v2, v2) + " " + vete(v4, v4) + "\n")
|
94 |
+
# MODEL
|
95 |
class UpSample(nn.Sequential):
|
96 |
def __init__(self, skip_input, output_features):
|
97 |
super(UpSample, self).__init__()
|
|
|
168 |
|
169 |
return img, html_string
|
170 |
|
171 |
+
|
172 |
+
# STREAMLIT
|
173 |
|
174 |
uploader = st.file_uploader('Upload your portrait here',type=['jpg','jpeg','png'])
|
175 |
|
|
|
177 |
pil_image = Image.open(uploader)
|
178 |
pil_depth, html_string = predict(pil_image)
|
179 |
|
180 |
+
components.html(html_string)
|
181 |
+
#st.markdown(html_string, unsafe_allow_html=True)
|
182 |
+
|
183 |
+
col1, col2, col3 = st.columns(3)
|
184 |
with col1:
|
185 |
st.image(pil_image)
|
186 |
with col2:
|
187 |
st.image(pil_depth)
|
188 |
+
with col3:
|
189 |
+
with open('model.obj') as f:
|
190 |
+
st.download_button('Download model.obj', f, file_name="model.obj")
|
191 |
+
pil_depth.save('tmp.png')
|
192 |
+
with open('tmp.png', "rb") as f:
|
193 |
+
st.download_button('Download depth.png', f,file_name="depth.png", mime="image/png")
|
model.obj
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tmp.png
ADDED
![]() |