johnowhitaker commited on
Commit
2e6d026
1 Parent(s): bfe9ff5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -65,7 +65,7 @@ def to_frames(video_file):
65
  os.system('rm -r guide_frames;mkdir guide_frames')
66
  os.system(f"ffmpeg -i {video_file} guide_frames/%04d.jpg")
67
 
68
- def update(preset, enhance, video_file):
69
 
70
  # Load presets
71
  ca = RuleCA(hidden_n=32, rule_channels=3)
@@ -91,6 +91,8 @@ def update(preset, enhance, video_file):
91
  size = (256, int(256*(vid_size[1]/vid_size[0])))
92
  else:
93
  size = (int(256*(vid_size[0]/vid_size[1])), 256)
 
 
94
 
95
  # Starting grid
96
  x = torch.zeros(1, 4, size[1], size[0]).to(ca.device)
@@ -123,11 +125,13 @@ with demo:
123
  gr.Markdown("Choose a preset below, upload a video and then click **Run** to see the output. Read [this report](https://wandb.ai/johnowhitaker/nca/reports/Fun-with-Neural-Cellular-Automata--VmlldzoyMDQ5Mjg0) for background on this project, or check out my [AI art course](https://github.com/johnowhitaker/aiaiart) for an in-depth lesson on Neural Cellular Automata like this.")
124
  with gr.Row():
125
  preset = gr.Dropdown(['Glowing Crystals', 'Rainbow Diamonds', 'Dark Diamonds', 'Dragon Scales'], label='Preset')
126
- enhance = gr.Checkbox(label='Rescale inputs (more extreme results)')
 
 
127
  with gr.Row():
128
  inp = gr.Video(format='mp4', source='upload', label="Input video (ideally <30s)")
129
  out = gr.Video(label="Output")
130
  btn = gr.Button("Run")
131
- btn.click(fn=update, inputs=[preset, enhance, inp], outputs=out)
132
 
133
  demo.launch(enable_queue=True)
 
65
  os.system('rm -r guide_frames;mkdir guide_frames')
66
  os.system(f"ffmpeg -i {video_file} guide_frames/%04d.jpg")
67
 
68
+ def update(preset, enhance, scale2x, video_file):
69
 
70
  # Load presets
71
  ca = RuleCA(hidden_n=32, rule_channels=3)
 
91
  size = (256, int(256*(vid_size[1]/vid_size[0])))
92
  else:
93
  size = (int(256*(vid_size[0]/vid_size[1])), 256)
94
+ if scale2x:
95
+ size = (size[0]*2, size[1]*2)
96
 
97
  # Starting grid
98
  x = torch.zeros(1, 4, size[1], size[0]).to(ca.device)
 
125
  gr.Markdown("Choose a preset below, upload a video and then click **Run** to see the output. Read [this report](https://wandb.ai/johnowhitaker/nca/reports/Fun-with-Neural-Cellular-Automata--VmlldzoyMDQ5Mjg0) for background on this project, or check out my [AI art course](https://github.com/johnowhitaker/aiaiart) for an in-depth lesson on Neural Cellular Automata like this.")
126
  with gr.Row():
127
  preset = gr.Dropdown(['Glowing Crystals', 'Rainbow Diamonds', 'Dark Diamonds', 'Dragon Scales'], label='Preset')
128
+ with gr.Column():
129
+ enhance = gr.Checkbox(label='Rescale inputs (more extreme results)')
130
+ scale2x = gr.Checkbox(label='Larger output (slower)')
131
  with gr.Row():
132
  inp = gr.Video(format='mp4', source='upload', label="Input video (ideally <30s)")
133
  out = gr.Video(label="Output")
134
  btn = gr.Button("Run")
135
+ btn.click(fn=update, inputs=[preset, enhance, scale2x, inp], outputs=out)
136
 
137
  demo.launch(enable_queue=True)