Spaces:
Sleeping
Sleeping
app.py
CHANGED
@@ -44,11 +44,6 @@ video_names = [f for f in os.listdir(dir_videos) if f.endswith('.mp4') or f.ends
|
|
44 |
video_files = [BASE_URL + dir_videos + name for name in video_names]
|
45 |
|
46 |
|
47 |
-
#print(model3D_files)
|
48 |
-
#print(images_files)
|
49 |
-
#print(video_files)
|
50 |
-
|
51 |
-
|
52 |
DESCRIPTION = """# PROJET MOULIN SIMON """
|
53 |
|
54 |
css = '''
|
@@ -91,8 +86,8 @@ head = '''
|
|
91 |
|
92 |
def read_text_file(path:str)->str :
|
93 |
with open(path, 'r', encoding='utf-8') as file:
|
94 |
-
|
95 |
-
|
96 |
|
97 |
def read_PIL_images(filenames):
|
98 |
images = []
|
@@ -119,55 +114,36 @@ def build_comparison_slider(before_url , after_url):
|
|
119 |
|
120 |
return html
|
121 |
|
122 |
-
#print(head)
|
123 |
-
#head = head.replace('BASE_URL_3D' , BASE_URL + dir_models3D )
|
124 |
-
#print(head)
|
125 |
-
|
126 |
with gr.Blocks(analytics_enabled=False , head=head , css=css, theme="bethecloud/storj_theme" , elem_id='gradio-container') as demo:
|
127 |
-
|
128 |
-
|
129 |
-
# Load external javascript file
|
130 |
-
#with open('script.js', 'r') as f:
|
131 |
-
# js_str = f.read()
|
132 |
-
#demo.load(_js=js_str)
|
133 |
-
|
134 |
-
|
135 |
-
# gr.Markdown(DESCRIPTION)
|
136 |
-
# gr.Image(BASE_DIR + 'assets/images/banner-dugrainaupain.jpg', type='filepath')
|
137 |
gr.HTML(f'''<div style="width:100%; text-align:left"><img src="{BASE_URL}assets/images/banner-dugrainaupain.jpg" style="display: inline-block;"></div>''')
|
138 |
|
|
|
139 |
with gr.Tab("LE PROJET....."):
|
|
|
140 |
with gr.Row():
|
141 |
with gr.Column(scale=1):
|
142 |
-
|
143 |
-
|
144 |
-
gr.HTML(build_comparison_slider(before , after)
|
145 |
|
146 |
with gr.Column(scale=1):
|
147 |
gr.HTML(read_text_file("assets/html/intro.txt"))
|
148 |
|
|
|
149 |
with gr.Tab("Avant/Après"):
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
before_after_2 = gr.HTML(f'''
|
163 |
-
<img-comparison-slider hover="hover" class="slider-with-animated-handle" style="max-width:500px; --divider-width: 4px; --divider-color: #ff0000;">
|
164 |
-
<img slot="first" width="100%" src="{BASE_URL}assets/images/before-after/moulin-insitu-1-_1610534-BEFORE.jpg" />
|
165 |
-
<img slot="second" width="100%" src="{BASE_URL}assets/images/before-after/moulin-insitu-1-_1610534-AFTER.jpg" />
|
166 |
-
</img-comparison-slider>''')
|
167 |
|
168 |
-
|
169 |
-
print(f'{BASE_URL}assets/images/before-after/moulin-insitu-1-_1610534-BEFORE.jpg')
|
170 |
-
print(f'{BASE_URL}assets/images/before-after/moulin-insitu-1-_1610534-AFTER.jpg')
|
171 |
|
172 |
with gr.Tab("Images"):
|
173 |
image_viewer = gr.Gallery(label="Generated images",
|
@@ -178,6 +154,7 @@ with gr.Blocks(analytics_enabled=False , head=head , css=css, theme="bethecloud/
|
|
178 |
object_fit="cover",
|
179 |
interactive=False,
|
180 |
value=images_files)
|
|
|
181 |
|
182 |
with gr.Tab("Modèles 3D"):
|
183 |
|
@@ -188,7 +165,6 @@ with gr.Blocks(analytics_enabled=False , head=head , css=css, theme="bethecloud/
|
|
188 |
|
189 |
viewer_html = viewer_html.replace('DEFAULT_MODEL_URL' , BASE_URL + dir_models3D + model3D_names[0])
|
190 |
viewer_html = viewer_html.replace('BASE_URL_3D' , BASE_URL + dir_models3D)
|
191 |
-
# print(viewer_html)
|
192 |
|
193 |
google_viewer = gr.HTML(viewer_html)
|
194 |
|
@@ -209,31 +185,7 @@ with gr.Blocks(analytics_enabled=False , head=head , css=css, theme="bethecloud/
|
|
209 |
outputs=None ,
|
210 |
js=f"(name) => document.getElementById('google-3D-viewer').src = '{BASE_URL + dir_models3D}' + name")
|
211 |
|
212 |
-
'''
|
213 |
-
with gr.Tab("Modèles 3D"):
|
214 |
-
|
215 |
-
model_viewer = gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="3D Model" , interactive=False , value=model3D_files[0])
|
216 |
-
|
217 |
-
with gr.Row(visible=True):
|
218 |
-
|
219 |
-
model_selection = gr.Radio(
|
220 |
-
show_label=True,
|
221 |
-
container=True,
|
222 |
-
interactive=True,
|
223 |
-
choices=model3D_names,
|
224 |
-
value=model3D_names[0],
|
225 |
-
label="Selectionner un modèle 3D :",
|
226 |
-
)
|
227 |
|
228 |
-
def load_mesh(model_name):
|
229 |
-
model_file = BASE_URL + dir_models3D + model_name
|
230 |
-
print(f'LOADING MODEL: {model_file}')
|
231 |
-
# model_viewer.update(value=model_file)
|
232 |
-
return model_file
|
233 |
-
|
234 |
-
model_selection.change(fn=load_mesh, inputs=model_selection, outputs=model_viewer)
|
235 |
-
'''
|
236 |
-
|
237 |
with gr.Tab("Videos"):
|
238 |
|
239 |
video_viewer = gr.Video(interactive=False, value=video_files[0])
|
@@ -256,6 +208,6 @@ with gr.Blocks(analytics_enabled=False , head=head , css=css, theme="bethecloud/
|
|
256 |
|
257 |
video_selection.change(fn=load_video, inputs=video_selection, outputs=video_viewer)
|
258 |
|
259 |
-
|
260 |
if __name__ == "__main__":
|
261 |
-
demo.launch(debug=not IN_SPACE, show_api=False)
|
|
|
44 |
video_files = [BASE_URL + dir_videos + name for name in video_names]
|
45 |
|
46 |
|
|
|
|
|
|
|
|
|
|
|
47 |
DESCRIPTION = """# PROJET MOULIN SIMON """
|
48 |
|
49 |
css = '''
|
|
|
86 |
|
87 |
def read_text_file(path:str)->str :
|
88 |
with open(path, 'r', encoding='utf-8') as file:
|
89 |
+
content = file.read()
|
90 |
+
return content
|
91 |
|
92 |
def read_PIL_images(filenames):
|
93 |
images = []
|
|
|
114 |
|
115 |
return html
|
116 |
|
|
|
|
|
|
|
|
|
117 |
with gr.Blocks(analytics_enabled=False , head=head , css=css, theme="bethecloud/storj_theme" , elem_id='gradio-container') as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
gr.HTML(f'''<div style="width:100%; text-align:left"><img src="{BASE_URL}assets/images/banner-dugrainaupain.jpg" style="display: inline-block;"></div>''')
|
119 |
|
120 |
+
|
121 |
with gr.Tab("LE PROJET....."):
|
122 |
+
|
123 |
with gr.Row():
|
124 |
with gr.Column(scale=1):
|
125 |
+
before = BASE_URL + 'assets/images/before-after/moulin-insitu-1-_1610534-BEFORE.jpg'
|
126 |
+
after = BASE_URL + 'assets/images/before-after/moulin-insitu-1-_1610534-AFTER.jpg'
|
127 |
+
gr.HTML(build_comparison_slider(before , after))
|
128 |
|
129 |
with gr.Column(scale=1):
|
130 |
gr.HTML(read_text_file("assets/html/intro.txt"))
|
131 |
|
132 |
+
|
133 |
with gr.Tab("Avant/Après"):
|
134 |
+
with gr.Row():
|
135 |
+
before = BASE_URL + 'assets/images/before-after/moulin-insitu-1-_1610534-schema-BEFORE.jpg'
|
136 |
+
after = BASE_URL + 'assets/images/before-after/moulin-insitu-1-_1610534-AFTER.jpg'
|
137 |
+
gr.HTML(build_comparison_slider(before , after))
|
138 |
+
|
139 |
+
before = BASE_URL + 'assets/images/before-after/moulin-insitu-1-_1610534-BEFORE.jpg'
|
140 |
+
after = BASE_URL + 'assets/images/before-after/moulin-insitu-1-_1610534-AFTER.jpg'
|
141 |
+
gr.HTML(build_comparison_slider(before , after))
|
142 |
+
|
143 |
+
print(f'{BASE_URL}assets/images/before-after/moulin-insitu-1-_1610534-schema-BEFORE.jpg')
|
144 |
+
print(f'{BASE_URL}assets/images/before-after/moulin-insitu-1-_1610534-BEFORE.jpg')
|
145 |
+
print(f'{BASE_URL}assets/images/before-after/moulin-insitu-1-_1610534-AFTER.jpg')
|
|
|
|
|
|
|
|
|
|
|
146 |
|
|
|
|
|
|
|
147 |
|
148 |
with gr.Tab("Images"):
|
149 |
image_viewer = gr.Gallery(label="Generated images",
|
|
|
154 |
object_fit="cover",
|
155 |
interactive=False,
|
156 |
value=images_files)
|
157 |
+
|
158 |
|
159 |
with gr.Tab("Modèles 3D"):
|
160 |
|
|
|
165 |
|
166 |
viewer_html = viewer_html.replace('DEFAULT_MODEL_URL' , BASE_URL + dir_models3D + model3D_names[0])
|
167 |
viewer_html = viewer_html.replace('BASE_URL_3D' , BASE_URL + dir_models3D)
|
|
|
168 |
|
169 |
google_viewer = gr.HTML(viewer_html)
|
170 |
|
|
|
185 |
outputs=None ,
|
186 |
js=f"(name) => document.getElementById('google-3D-viewer').src = '{BASE_URL + dir_models3D}' + name")
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
with gr.Tab("Videos"):
|
190 |
|
191 |
video_viewer = gr.Video(interactive=False, value=video_files[0])
|
|
|
208 |
|
209 |
video_selection.change(fn=load_video, inputs=video_selection, outputs=video_viewer)
|
210 |
|
211 |
+
|
212 |
if __name__ == "__main__":
|
213 |
+
demo.launch(debug=not IN_SPACE, show_api=False)
|
assets/images/before-after/moulin-insitu-1-_1610534-schema-BEFORE.jpg
CHANGED