Spaces:
Running
on
Zero
Running
on
Zero
unknown
commited on
Commit
•
e8a0fdf
1
Parent(s):
7c9dc5d
move to gpu
Browse files
app.py
CHANGED
@@ -64,8 +64,6 @@ class FoleyController:
|
|
64 |
self.savedir_sample = os.path.join(self.savedir, "sample")
|
65 |
os.makedirs(self.savedir, exist_ok=True)
|
66 |
|
67 |
-
self.device = "cuda"
|
68 |
-
|
69 |
self.pipeline = None
|
70 |
|
71 |
self.loaded = False
|
@@ -118,13 +116,7 @@ class FoleyController:
|
|
118 |
self.image_processor = CLIPImageProcessor()
|
119 |
self.image_encoder = CLIPVisionModelWithProjection.from_pretrained('h94/IP-Adapter', subfolder='models/image_encoder')
|
120 |
|
121 |
-
self.pipeline.load_ip_adapter(fc_ckpt, subfolder='semantic', weight_name='semantic_adapter.bin', image_encoder_folder=None)
|
122 |
-
|
123 |
-
# move to gpu
|
124 |
-
self.time_detector = self.time_detector.to(self.device)
|
125 |
-
self.pipeline = self.pipeline.to(self.device)
|
126 |
-
self.vocoder = self.vocoder.to(self.device)
|
127 |
-
self.image_encoder = self.image_encoder.to(self.device)
|
128 |
|
129 |
gr.Info("Load Finish!")
|
130 |
print("Load Finish!")
|
@@ -212,8 +204,6 @@ class FoleyController:
|
|
212 |
save_sample_path = os.path.join(self.savedir_sample, f"{name}.mp4")
|
213 |
|
214 |
return save_sample_path
|
215 |
-
|
216 |
-
controller = FoleyController()
|
217 |
|
218 |
def ui():
|
219 |
with gr.Blocks(css=css) as demo:
|
@@ -280,6 +270,15 @@ def ui():
|
|
280 |
return demo
|
281 |
|
282 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
demo = ui()
|
284 |
demo.queue(10)
|
285 |
demo.launch(server_name=args.server_name, server_port=args.port, share=args.share, allowed_paths=["./foleycrafter.png"])
|
|
|
64 |
self.savedir_sample = os.path.join(self.savedir, "sample")
|
65 |
os.makedirs(self.savedir, exist_ok=True)
|
66 |
|
|
|
|
|
67 |
self.pipeline = None
|
68 |
|
69 |
self.loaded = False
|
|
|
116 |
self.image_processor = CLIPImageProcessor()
|
117 |
self.image_encoder = CLIPVisionModelWithProjection.from_pretrained('h94/IP-Adapter', subfolder='models/image_encoder')
|
118 |
|
119 |
+
self.pipeline.load_ip_adapter(fc_ckpt, subfolder='semantic', weight_name='semantic_adapter.bin', image_encoder_folder=None)
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
gr.Info("Load Finish!")
|
122 |
print("Load Finish!")
|
|
|
204 |
save_sample_path = os.path.join(self.savedir_sample, f"{name}.mp4")
|
205 |
|
206 |
return save_sample_path
|
|
|
|
|
207 |
|
208 |
def ui():
|
209 |
with gr.Blocks(css=css) as demo:
|
|
|
270 |
return demo
|
271 |
|
272 |
if __name__ == "__main__":
|
273 |
+
controller = FoleyController()
|
274 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
275 |
+
|
276 |
+
# move to gpu
|
277 |
+
controller.time_detector = controller.time_detector.to(device)
|
278 |
+
controller.pipeline = controller.pipeline.to(device)
|
279 |
+
controller.vocoder = controller.vocoder.to(device)
|
280 |
+
controller.image_encoder = controller.image_encoder.to(device)
|
281 |
+
|
282 |
demo = ui()
|
283 |
demo.queue(10)
|
284 |
demo.launch(server_name=args.server_name, server_port=args.port, share=args.share, allowed_paths=["./foleycrafter.png"])
|