Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -152,7 +152,10 @@ def run_main_app(semantic_concept, word, letter, font_name, num_steps, example=0
|
|
152 |
preprocess(cfg.font, cfg.word, cfg.optimized_letter, cfg.level_of_cc)
|
153 |
filename_init = os.path.join("code/data/init/", f"{cfg.font}_{cfg.word}_scaled.svg").replace(" ", "_")
|
154 |
if not example:
|
155 |
-
|
|
|
|
|
|
|
156 |
|
157 |
sds_loss = SDSLoss(cfg, device, model)
|
158 |
|
@@ -207,7 +210,10 @@ def run_main_app(semantic_concept, word, letter, font_name, num_steps, example=0
|
|
207 |
check_and_create_dir(filename)
|
208 |
save_svg.save_svg(filename, w, h, shapes, shape_groups)
|
209 |
if not example:
|
210 |
-
yield gr.update(visible=True),gr.update(value=filename, label=f'iters: {step} / {num_iter}', visible=True),gr.update(visible=False)
|
|
|
|
|
|
|
211 |
|
212 |
x = img.unsqueeze(0).permute(0, 3, 1, 2) # HWC -> NCHW
|
213 |
x = x.repeat(cfg.batch_size, 1, 1, 1)
|
@@ -298,8 +304,8 @@ with gr.Blocks() as demo:
|
|
298 |
|
299 |
with gr.Column():
|
300 |
result0 = gr.HTML() #gr.Image(type="filepath", label="Initial Word",height=333)
|
301 |
-
result1 = gr.Image(type="filepath", label="Optimization Process",height=100)
|
302 |
-
result2 = gr.HTML(
|
303 |
|
304 |
|
305 |
with gr.Row():
|
|
|
152 |
preprocess(cfg.font, cfg.word, cfg.optimized_letter, cfg.level_of_cc)
|
153 |
filename_init = os.path.join("code/data/init/", f"{cfg.font}_{cfg.word}_scaled.svg").replace(" ", "_")
|
154 |
if not example:
|
155 |
+
with open(filename_init, "r") as f0:
|
156 |
+
svg_content_init = f0.read()
|
157 |
+
# yield gr.update(value=filename_init,visible=True),gr.update(visible=False),gr.update(visible=False)
|
158 |
+
yield gr.update(value=f'<div>{svg_content_init}</div>',label="Initial Word",visible=True),gr.update(visible=False),gr.update(visible=False)
|
159 |
|
160 |
sds_loss = SDSLoss(cfg, device, model)
|
161 |
|
|
|
210 |
check_and_create_dir(filename)
|
211 |
save_svg.save_svg(filename, w, h, shapes, shape_groups)
|
212 |
if not example:
|
213 |
+
# yield gr.update(visible=True),gr.update(value=filename, label=f'iters: {step} / {num_iter}', visible=True),gr.update(visible=False)
|
214 |
+
with open(filename, "r") as f:
|
215 |
+
svg_content = f.read()
|
216 |
+
yield gr.update(visible=True), gr.update(value=f'<div>{svg_content}</div>',label=f'iters: {step} / {num_iter}',visible=True),gr.update(visible=False)
|
217 |
|
218 |
x = img.unsqueeze(0).permute(0, 3, 1, 2) # HWC -> NCHW
|
219 |
x = x.repeat(cfg.batch_size, 1, 1, 1)
|
|
|
304 |
|
305 |
with gr.Column():
|
306 |
result0 = gr.HTML() #gr.Image(type="filepath", label="Initial Word",height=333)
|
307 |
+
result1 = gr.HTML() #gr.Image(type="filepath", label="Optimization Process",height=100)
|
308 |
+
result2 = gr.HTML() #gr.Image(type="filepath", label="Final Result",visible=False,height=333)
|
309 |
|
310 |
|
311 |
with gr.Row():
|