Spaces:
Runtime error
Runtime error
Xu Ma
commited on
Commit
•
647fcfd
1
Parent(s):
2790694
update
Browse files- app.py +3 -0
- config/base.yaml +8 -1
- main.py +5 -4
app.py
CHANGED
@@ -95,6 +95,8 @@ def parse_args():
|
|
95 |
|
96 |
|
97 |
def app_experiment_change(experiment_id):
|
|
|
|
|
98 |
if experiment_id == "add [1, 1, 1, 1, 1] total 5 paths one by one":
|
99 |
return "experiment_5x1"
|
100 |
elif experiment_id == "add [1, 1, 1, 1, 1, 1, 1, 1] total 8 paths one by one":
|
@@ -293,6 +295,7 @@ def main(args):
|
|
293 |
inputs_img = gr.inputs.Image(type="pil", label="Input Image")
|
294 |
experiment_id = gr.inputs.Radio(
|
295 |
choices=[
|
|
|
296 |
"add [1, 1, 1, 1, 1] total 5 paths one by one",
|
297 |
"add [1, 1, 1, 1, 1, 1, 1, 1] total 8 paths one by one",
|
298 |
"add [1,2,4,8,16,32, ...] total 128 paths",
|
|
|
95 |
|
96 |
|
97 |
def app_experiment_change(experiment_id):
|
98 |
+
if experiment_id == "add [1] total 1 path for demonstration":
|
99 |
+
return "experiment_1x1"
|
100 |
if experiment_id == "add [1, 1, 1, 1, 1] total 5 paths one by one":
|
101 |
return "experiment_5x1"
|
102 |
elif experiment_id == "add [1, 1, 1, 1, 1, 1, 1, 1] total 8 paths one by one":
|
|
|
295 |
inputs_img = gr.inputs.Image(type="pil", label="Input Image")
|
296 |
experiment_id = gr.inputs.Radio(
|
297 |
choices=[
|
298 |
+
"add [1] total 1 path for demonstration",
|
299 |
"add [1, 1, 1, 1, 1] total 5 paths one by one",
|
300 |
"add [1, 1, 1, 1, 1, 1, 1, 1] total 8 paths one by one",
|
301 |
"add [1,2,4,8,16,32, ...] total 128 paths",
|
config/base.yaml
CHANGED
@@ -31,12 +31,19 @@ default:
|
|
31 |
xing_loss_weight: 0.01
|
32 |
bis_loss_weight: null
|
33 |
|
34 |
-
|
|
|
35 |
path_schedule:
|
36 |
type: repeat
|
37 |
max_path: 1
|
38 |
schedule_each: 1
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
experiment_5x1:
|
41 |
path_schedule:
|
42 |
type: repeat
|
|
|
31 |
xing_loss_weight: 0.01
|
32 |
bis_loss_weight: null
|
33 |
|
34 |
+
|
35 |
+
experiment_1x1:
|
36 |
path_schedule:
|
37 |
type: repeat
|
38 |
max_path: 1
|
39 |
schedule_each: 1
|
40 |
|
41 |
+
experiment_4x1:
|
42 |
+
path_schedule:
|
43 |
+
type: repeat
|
44 |
+
max_path: 4
|
45 |
+
schedule_each: 1
|
46 |
+
|
47 |
experiment_5x1:
|
48 |
path_schedule:
|
49 |
type: repeat
|
main.py
CHANGED
@@ -520,10 +520,10 @@ def main_func(target, experiment, num_iter, cfg_arg):
|
|
520 |
imshow = img.detach().cpu()
|
521 |
pydiffvg.imwrite(imshow, filename, gamma=gamma)
|
522 |
|
523 |
-
### added for app
|
524 |
-
if t%30==0 and t !=0 :
|
525 |
-
|
526 |
-
|
527 |
|
528 |
x = img.unsqueeze(0).permute(0, 3, 1, 2) # HWC -> NCHW
|
529 |
|
@@ -693,6 +693,7 @@ def main_func(target, experiment, num_iter, cfg_arg):
|
|
693 |
# shutil.rmtree(os.path.join(cfg.experiment_dir, "video-png"))
|
694 |
|
695 |
print("The last loss is: {}".format(loss.item()))
|
|
|
696 |
|
697 |
|
698 |
if __name__ == "__main__":
|
|
|
520 |
imshow = img.detach().cpu()
|
521 |
pydiffvg.imwrite(imshow, filename, gamma=gamma)
|
522 |
|
523 |
+
# ### added for app
|
524 |
+
# if t%30==0 and t !=0 :
|
525 |
+
# # print(f"debug: {t}, {filename} {img.size()}")
|
526 |
+
# return img.detach().cpu().numpy(), t
|
527 |
|
528 |
x = img.unsqueeze(0).permute(0, 3, 1, 2) # HWC -> NCHW
|
529 |
|
|
|
693 |
# shutil.rmtree(os.path.join(cfg.experiment_dir, "video-png"))
|
694 |
|
695 |
print("The last loss is: {}".format(loss.item()))
|
696 |
+
return img.detach().cpu().numpy(), t
|
697 |
|
698 |
|
699 |
if __name__ == "__main__":
|