Code Monkey home page Code Monkey logo

video2scenario's Introduction

video2scenario

Forms a tree-like folder dataset with L parts at the lowest level.

Then recursively writes descriptions of scenes with Large Language Models and Image Captioning Models.

The lowest level clips are captioned with VideoLLaVA.

The descriptions are gathered in a list and then the LLM is asked to describe the overall scene. Then the process continutes until the top level.

Any OpenAI-like text completion model can be used for this. In my tests Oobabooga's text generation webui is used as the API endpoint.

User can also provide the master prompt to help the model and edit the resulting descriptions with a Gradio demo interface.

There is also an option to store the resulting corrected output for better fine-tuning the models, for example, using a LoRA.

The Gradio interface has a dropdown to select each description - clip pair, on each level.


The goal of this subproject is to make a DiffusionOverDiffusion dataset to train InfiNet and the future complex script-based text2video models with minimal human labeling efforts.

video2scenario's People

Contributors

camenduru avatar kabachuha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

video2scenario's Issues

fh = logging.FileHandler(f'logs/{timestring}.log')

Traceback (most recent call last):
  File "/content/video2scenario/app.py", line 24, in <module>
    fh = logging.FileHandler(f'logs/{timestring}.log')
  File "/usr/lib/python3.10/logging/__init__.py", line 1169, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python3.10/logging/__init__.py", line 1201, in _open
    return open_func(self.baseFilename, self.mode,
FileNotFoundError: [Errno 2] No such file or directory: '/content/video2scenario/logs/20230614202501.log'

chop video

2023-06-14 20:26:45 b29127431c32 numexpr.utils[4014] INFO NumExpr defaulting to 2 threads.
INFO - Processing video at textbox
2023-06-14 20:26:46 b29127431c32 __main__[4014] INFO Processing video at textbox
Traceback (most recent call last):
  File "/content/video2scenario/app.py", line 477, in <module>
    do_btn.click(process_video, inputs=[process_video(do_chop, do_clear, do_caption, do_textgen, do_export, do_delete, chop_whole_vid_path, chop_split_path, chop_trg_path, autocap_beam_amount, autocap_min_words, autocap_max_words, textgen_url, textgen_key, textgen_new_words, textgen_temperature, textgen_top_p, textgen_typical_p, textgen_top_k, textgen_repetition_penalty, textgen_encoder_repetition_penalty, textgen_length_penalty, master_scene, master_synopsis, exp_overwrite_dims, exp_w, exp_h, exp_overwrite_fps, exp_fps)])
  File "/content/video2scenario/app.py", line 124, in process_video
    if os.path.exists(split_video_path):
  File "/usr/lib/python3.10/genericpath.py", line 19, in exists
    os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not Textbox

video2scenario/app.py

Lines 122 to 129 in de7fd1a

#chop video
if do_chop:
if os.path.exists(split_video_path):
shutil.rmtree(split_video_path)
chop_video(input_video_path, split_video_path, L)
max_d, L = calculate_depth(input_video_path)
max_d = max_d - 1

Unable to run app.py. Directories expected.

python app.py
INFO - Processing video at
2023-09-13 17:48:19 MacBook-Pro main[93014] INFO Processing video at
Traceback (most recent call last):
File "/Users/home/Github/video2scenario/app.py", line 497, in
do_btn.click(process_video, inputs=[process_video(do_chop, do_clear, do_caption, do_textgen, do_export, do_delete, chop_whole_vid_path, chop_split_path, chop_trg_path, autocap_beam_amount, autocap_min_words, autocap_max_words, textgen_url, textgen_key, textgen_new_words, textgen_temperature, textgen_top_p, textgen_typical_p, textgen_top_k, textgen_repetition_penalty, textgen_encoder_repetition_penalty, textgen_length_penalty, master_scene, master_synopsis, exp_overwrite_dims, exp_w, exp_h, exp_overwrite_fps, exp_fps)])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/home/Github/video2scenario/app.py", line 142, in process_video
max_d, L = calculate_depth(input_video_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/home/Github/video2scenario/chops_to_folder_dataset.py", line 69, in calculate_depth
L = len(os.listdir(os.path.join(init_path, 'depth_0', 'depth_1', 'depth_2', 'part_0'))) // 2
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'depth_0/depth_1/depth_2/part_0'

video_chop.py missing arguments

I was getting this error...
video_chop.py", line 112, in main chop_video(args.video_file, int(args.L)) TypeError: chop_video() missing 1 required positional argument: 'L'

In order to make video_chop.py work, I had change the chop_video() and main() to get the program to work. I don't know if someone already wrote a fix for it, but if not, this will allow it to work, just replace the two functions with these functions.


def chop_video(video_path: str, outpath: str, L: int,start_frame=0):

    only_once = True

    if not os.path.exists(video_path):
        raise FileNotFoundError(f"Video file '{video_path}' not found.")

    video = cv2.VideoCapture(video_path)

    total_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
    video.release()
    if not os.path.exists(os.path.join(os.getcwd(),outpath)):
        os.makedirs(outpath)
    chop_video_inner(video_path, outpath, L, start_frame)


def main():
    parser = argparse.ArgumentParser(description="Chop a video file into subsets of frames.")
    parser.add_argument("-video_file", help="Path to the video file.")
    parser.add_argument("-output_folder", help="Num of splits on each level.")
    parser.add_argument("--L", help="Num of splits on each level.")
    
    args = parser.parse_args()
    chop_video(args.video_file, args.output_folder, int(args.L))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.