vinesmsuic
commited on
Commit
•
f2d9a72
1
Parent(s):
6b98080
stable
Browse files- app.py +4 -5
- app_ip2p.py → app_cosxl.py +5 -4
- black_box_image_edit/cosxl_edit.py +2 -0
- requirements.txt +1 -1
app.py
CHANGED
@@ -14,8 +14,7 @@ from PIL import Image
|
|
14 |
import torch
|
15 |
import numpy as np
|
16 |
|
17 |
-
from black_box_image_edit.
|
18 |
-
#from black_box_image_edit.instructpix2pix import InstructPix2Pix
|
19 |
from prepare_video import crop_and_resize_video
|
20 |
from edit_image import infer_video
|
21 |
|
@@ -41,7 +40,7 @@ demo_examples = [
|
|
41 |
TEMP_DIR = "_demo_temp"
|
42 |
|
43 |
|
44 |
-
image_edit_model =
|
45 |
|
46 |
@torch.no_grad()
|
47 |
@spaces.GPU(duration=30)
|
@@ -316,7 +315,7 @@ with gr.Blocks() as demo:
|
|
316 |
gr.Markdown("Official 🤗 Gradio demo for [AnyV2V: A Plug-and-Play Framework For Any Video-to-Video Editing Tasks](https://tiger-ai-lab.github.io/AnyV2V/)")
|
317 |
|
318 |
with gr.Tabs():
|
319 |
-
with gr.TabItem('AnyV2V(I2VGenXL) +
|
320 |
gr.Markdown("# Preprocessing Video Stage")
|
321 |
gr.Markdown("In this demo, AnyV2V only support video with 2 seconds duration and 8 fps. If your video is not in this format, we will preprocess it for you. Click on the Preprocess video button!")
|
322 |
with gr.Row():
|
@@ -340,7 +339,7 @@ with gr.Blocks() as demo:
|
|
340 |
pv_longest_to_width = gr.Checkbox(label="Resize Longest Dimension to Width")
|
341 |
|
342 |
gr.Markdown("# Image Editing Stage")
|
343 |
-
gr.Markdown("Edit the first frame of the video to your liking! Click on the Edit the first frame button after inputting the editing instruction prompt. This image editing stage is powered by
|
344 |
with gr.Row():
|
345 |
with gr.Column():
|
346 |
src_first_frame = gr.Image(label="First Frame", type="filepath", interactive=False)
|
|
|
14 |
import torch
|
15 |
import numpy as np
|
16 |
|
17 |
+
from black_box_image_edit.instructpix2pix import InstructPix2Pix
|
|
|
18 |
from prepare_video import crop_and_resize_video
|
19 |
from edit_image import infer_video
|
20 |
|
|
|
40 |
TEMP_DIR = "_demo_temp"
|
41 |
|
42 |
|
43 |
+
image_edit_model = InstructPix2Pix()
|
44 |
|
45 |
@torch.no_grad()
|
46 |
@spaces.GPU(duration=30)
|
|
|
315 |
gr.Markdown("Official 🤗 Gradio demo for [AnyV2V: A Plug-and-Play Framework For Any Video-to-Video Editing Tasks](https://tiger-ai-lab.github.io/AnyV2V/)")
|
316 |
|
317 |
with gr.Tabs():
|
318 |
+
with gr.TabItem('AnyV2V(I2VGenXL) + InstructPix2Pix'):
|
319 |
gr.Markdown("# Preprocessing Video Stage")
|
320 |
gr.Markdown("In this demo, AnyV2V only support video with 2 seconds duration and 8 fps. If your video is not in this format, we will preprocess it for you. Click on the Preprocess video button!")
|
321 |
with gr.Row():
|
|
|
339 |
pv_longest_to_width = gr.Checkbox(label="Resize Longest Dimension to Width")
|
340 |
|
341 |
gr.Markdown("# Image Editing Stage")
|
342 |
+
gr.Markdown("Edit the first frame of the video to your liking! Click on the Edit the first frame button after inputting the editing instruction prompt. This image editing stage is powered by InstructPix2Pix. You can try edit the image multiple times until you are happy with the result! You can also choose to download the first frame of the video and edit it with other software (e.g. Photoshop, GIMP, etc.) or use other image editing models to obtain the edited frame and upload it directly.")
|
343 |
with gr.Row():
|
344 |
with gr.Column():
|
345 |
src_first_frame = gr.Image(label="First Frame", type="filepath", interactive=False)
|
app_ip2p.py → app_cosxl.py
RENAMED
@@ -14,7 +14,8 @@ from PIL import Image
|
|
14 |
import torch
|
15 |
import numpy as np
|
16 |
|
17 |
-
from black_box_image_edit.
|
|
|
18 |
from prepare_video import crop_and_resize_video
|
19 |
from edit_image import infer_video
|
20 |
|
@@ -40,7 +41,7 @@ demo_examples = [
|
|
40 |
TEMP_DIR = "_demo_temp"
|
41 |
|
42 |
|
43 |
-
image_edit_model =
|
44 |
|
45 |
@torch.no_grad()
|
46 |
@spaces.GPU(duration=30)
|
@@ -315,7 +316,7 @@ with gr.Blocks() as demo:
|
|
315 |
gr.Markdown("Official 🤗 Gradio demo for [AnyV2V: A Plug-and-Play Framework For Any Video-to-Video Editing Tasks](https://tiger-ai-lab.github.io/AnyV2V/)")
|
316 |
|
317 |
with gr.Tabs():
|
318 |
-
with gr.TabItem('AnyV2V(I2VGenXL) +
|
319 |
gr.Markdown("# Preprocessing Video Stage")
|
320 |
gr.Markdown("In this demo, AnyV2V only support video with 2 seconds duration and 8 fps. If your video is not in this format, we will preprocess it for you. Click on the Preprocess video button!")
|
321 |
with gr.Row():
|
@@ -339,7 +340,7 @@ with gr.Blocks() as demo:
|
|
339 |
pv_longest_to_width = gr.Checkbox(label="Resize Longest Dimension to Width")
|
340 |
|
341 |
gr.Markdown("# Image Editing Stage")
|
342 |
-
gr.Markdown("Edit the first frame of the video to your liking! Click on the Edit the first frame button after inputting the editing instruction prompt. This image editing stage is powered by
|
343 |
with gr.Row():
|
344 |
with gr.Column():
|
345 |
src_first_frame = gr.Image(label="First Frame", type="filepath", interactive=False)
|
|
|
14 |
import torch
|
15 |
import numpy as np
|
16 |
|
17 |
+
from black_box_image_edit.cosxl_edit import CosXLEdit
|
18 |
+
#from black_box_image_edit.instructpix2pix import InstructPix2Pix
|
19 |
from prepare_video import crop_and_resize_video
|
20 |
from edit_image import infer_video
|
21 |
|
|
|
41 |
TEMP_DIR = "_demo_temp"
|
42 |
|
43 |
|
44 |
+
image_edit_model = CosXLEdit()
|
45 |
|
46 |
@torch.no_grad()
|
47 |
@spaces.GPU(duration=30)
|
|
|
316 |
gr.Markdown("Official 🤗 Gradio demo for [AnyV2V: A Plug-and-Play Framework For Any Video-to-Video Editing Tasks](https://tiger-ai-lab.github.io/AnyV2V/)")
|
317 |
|
318 |
with gr.Tabs():
|
319 |
+
with gr.TabItem('AnyV2V(I2VGenXL) + CosXLEdit'):
|
320 |
gr.Markdown("# Preprocessing Video Stage")
|
321 |
gr.Markdown("In this demo, AnyV2V only support video with 2 seconds duration and 8 fps. If your video is not in this format, we will preprocess it for you. Click on the Preprocess video button!")
|
322 |
with gr.Row():
|
|
|
340 |
pv_longest_to_width = gr.Checkbox(label="Resize Longest Dimension to Width")
|
341 |
|
342 |
gr.Markdown("# Image Editing Stage")
|
343 |
+
gr.Markdown("Edit the first frame of the video to your liking! Click on the Edit the first frame button after inputting the editing instruction prompt. This image editing stage is powered by CosXLEdit. You can try edit the image multiple times until you are happy with the result! You can also choose to download the first frame of the video and edit it with other software (e.g. Photoshop, GIMP, etc.) or use other image editing models to obtain the edited frame and upload it directly.")
|
344 |
with gr.Row():
|
345 |
with gr.Column():
|
346 |
src_first_frame = gr.Image(label="First Frame", type="filepath", interactive=False)
|
black_box_image_edit/cosxl_edit.py
CHANGED
@@ -28,6 +28,8 @@ class CosXLEdit():
|
|
28 |
)
|
29 |
self.pipe.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigma_data=1.0, prediction_type="v_prediction")
|
30 |
self.pipe.to(device)
|
|
|
|
|
31 |
|
32 |
def infer_one_image(self, src_image: PIL.Image.Image = None, src_prompt: str = None, target_prompt: str = None, instruct_prompt: str = None, seed: int = 42, negative_prompt=""):
|
33 |
"""
|
|
|
28 |
)
|
29 |
self.pipe.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigma_data=1.0, prediction_type="v_prediction")
|
30 |
self.pipe.to(device)
|
31 |
+
self.pipe.enable_vae_tiling()
|
32 |
+
self.pipe.enable_model_cpu_offload()
|
33 |
|
34 |
def infer_one_image(self, src_image: PIL.Image.Image = None, src_prompt: str = None, target_prompt: str = None, instruct_prompt: str = None, seed: int = 42, negative_prompt=""):
|
35 |
"""
|
requirements.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
torch==2.1.0
|
2 |
torchvision==0.16.0
|
3 |
accelerate
|
4 |
-
diffusers==0.
|
5 |
transformers
|
6 |
omegaconf
|
7 |
opencv-python
|
|
|
1 |
torch==2.1.0
|
2 |
torchvision==0.16.0
|
3 |
accelerate
|
4 |
+
diffusers==0.26.3
|
5 |
transformers
|
6 |
omegaconf
|
7 |
opencv-python
|