Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ForgeTube Final Compilation #3

Merged
merged 66 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
db2e732
Video Assembler Prototype + Sample Images and Audio Added
BrataBuilds Jan 27, 2025
e30db73
Added Sample Video File
BrataBuilds Jan 31, 2025
0f1b9f0
Update README.md
BrataBuilds Feb 1, 2025
cfd6899
Update README.md
BrataBuilds Feb 1, 2025
6c42974
Added Sample Data
BrataBuilds Feb 1, 2025
0e21ea8
Merge branch 'main' of https://github.com/BrataBuilds/ForgeTube
BrataBuilds Feb 1, 2025
002d659
Added Audio, Image, Subtitles Samples + Moviepy Showcase
BrataBuilds Feb 4, 2025
c78a0b1
Added proper README and fixed project structure
BrataBuilds Feb 5, 2025
2b142f7
initial commit
Kartikeya-trivedi Feb 5, 2025
1ea5738
Add function for extracting feature from JSON file
rahul-sutradhar Feb 5, 2025
f96e43d
Merge branch 'main' of https://github.com/BrataBuilds/ForgeTube
rahul-sutradhar Feb 5, 2025
23bd6e3
Added function for extracting feature from JSON file
rahul-sutradhar Feb 5, 2025
16c1c8f
Added function for extracting feature from JSON file
rahul-sutradhar Feb 5, 2025
0aa12bd
made a modal version of code
Kartikeya-trivedi Feb 6, 2025
cbd7596
made some changes
Kartikeya-trivedi Feb 6, 2025
4d0abd1
Add script to extract audio and visual parameters from JSON
rahul-sutradhar Feb 6, 2025
210710d
Merge pull request #2 from rahul-sutradhar/main
rahul-sutradhar Feb 6, 2025
4ce1ebd
feature/random video transition
ShopnoBanerjee Feb 7, 2025
777b0b5
feature/random video transition
ShopnoBanerjee Feb 7, 2025
a2490ce
hugging face transformers code
Kartikeya-trivedi Feb 8, 2025
fbd52aa
Added Subtitle Implementation
BrataBuilds Feb 9, 2025
6ae8376
Merge branch 'main' of https://github.com/BrataBuilds/ForgeTube
BrataBuilds Feb 9, 2025
a74b488
modified: Video Assembly/assembly_video v2.py
BrataBuilds Feb 9, 2025
8e48246
Added json_extract function to extract text-to-speech and topic of th…
rahul-sutradhar Feb 9, 2025
bf037f7
working scripts
Kartikeya-trivedi Feb 10, 2025
506d468
made some changes
Kartikeya-trivedi Feb 10, 2025
578bc0a
Merge branch 'main' of https://github.com/BrataBuilds/ForgeTube
ShopnoBanerjee Feb 10, 2025
7bba714
Merge pull request #3 from rahul-sutradhar/rahul
rahul-sutradhar Feb 10, 2025
26fb840
Merge branch 'main' of https://github.com/BrataBuilds/ForgeTube
ShopnoBanerjee Feb 10, 2025
9476cbe
new file: Samples/videos/Cats1.mp4
BrataBuilds Feb 10, 2025
a59315a
Merge branch 'main' of https://github.com/BrataBuilds/ForgeTube
ShopnoBanerjee Feb 10, 2025
bef93c6
feature : video transitions
ShopnoBanerjee Feb 10, 2025
4a38409
feature : intro and outro clip
ShopnoBanerjee Feb 10, 2025
eba8da4
Fixed issues with create_video not working with
BrataBuilds Feb 10, 2025
a98104e
feature: transitions + intro/outro clip
ShopnoBanerjee Feb 11, 2025
393dc7a
Fixed create_complete_srt function
BrataBuilds Feb 11, 2025
7b2d5b2
Updated README.
BrataBuilds Feb 11, 2025
6839844
Added brand new Samples
BrataBuilds Feb 11, 2025
08ee9c0
new version of code with rag
Kartikeya-trivedi Feb 18, 2025
6360b65
Fixing Merge Conflicts
BrataBuilds Feb 18, 2025
fecf107
Merge branch 'Final_Assembly' into kartikeya
BrataBuilds Feb 18, 2025
a0a78c1
Merge pull request #4 from aharshit123456/kartikeya
BrataBuilds Feb 18, 2025
2597614
Stop tracking .gitignore
BrataBuilds Feb 20, 2025
52f84ca
Stop tracking .gitignore
BrataBuilds Feb 20, 2025
1acb19e
Stop tracking Samples/
BrataBuilds Feb 20, 2025
3e9a064
Stop tracking Moviepy Showcase/
BrataBuilds Feb 20, 2025
87dc957
Fixed the project directory, updated README.md and Added main.py, pyp…
BrataBuilds Feb 20, 2025
668b1a1
Updated a lot of stuff
BrataBuilds Feb 21, 2025
af633a8
Update
rahul-sutradhar Feb 21, 2025
64f9b73
Updated a lot of stuff
BrataBuilds Feb 21, 2025
15424c1
Updated a lot of stuff
BrataBuilds Feb 21, 2025
fb15631
update
rahul-sutradhar Feb 21, 2025
838c9ad
Merge branch 'Final_Assembly' of https://github.com/BrataBuilds/Forge…
rahul-sutradhar Feb 21, 2025
f2f6357
Added support for local generation
BrataBuilds Feb 22, 2025
2334280
Added main.py
BrataBuilds Feb 22, 2025
e00985e
Changed Guidance Scale to 9
BrataBuilds Feb 22, 2025
64be178
Fixed Guidance Scaling to 9
BrataBuilds Feb 22, 2025
938fedb
removed Samples
BrataBuilds Feb 22, 2025
18270b1
Updated
BrataBuilds Feb 22, 2025
89fef26
Update file paths
BrataBuilds Feb 22, 2025
07a422e
Clean up
BrataBuilds Feb 23, 2025
9e7780f
Modified README and Prepare for Final Push
BrataBuilds Feb 23, 2025
58778f1
Preparing for Final Push
BrataBuilds Feb 23, 2025
51073eb
ensured main and local_main were same
BrataBuilds Feb 23, 2025
da63eff
Update a small typo
BrataBuilds Feb 23, 2025
ec10b56
Update
BrataBuilds Feb 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .gitignore

This file was deleted.

247 changes: 155 additions & 92 deletions README.md

Large diffs are not rendered by default.

469 changes: 461 additions & 8 deletions assembly/scripts/assembly_video.py

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions diffusion/scripts/Modelfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM llama3.1


PARAMETER temperature 1

SYSTEM """ You are a youtube script writer and content creator your task is to create youtube scripts and to segment it with various parameters in json format"""
118 changes: 110 additions & 8 deletions diffusion/scripts/generate_image.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,112 @@
import modal
import json
import os
import time
from io import BytesIO

def main():
# TODO: 1. Load diffusion pipeline
# TODO: 2. Provide prompt or source text
# TODO: 3. Generate or sample images
# TODO: 4. Save images to ../images
pass
image = modal.Image.debian_slim().pip_install(
"diffusers",
"torch",
"transformers",
"accelerate"
)

if __name__ == "__main__":
main()
app = modal.App(name="ForgeTube_app")

@app.function(image=image, gpu="A10G")
def generate_image(prompt, negative_prompt="", steps=50, guidance_scale=9, width=1920, height=1080, seed=None):
import torch
from diffusers import DiffusionPipeline


# LOADS THE DIFFUSION PIPELINE

pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0",
torch_dtype=torch.float16,
use_safetensors=True,
variant="fp16")
pipe.to("cuda")

generator = torch.Generator(device="cuda").manual_seed(seed) if seed else None

image = pipe(
prompt,
negative_prompt=negative_prompt,
num_inference_steps=steps,
guidance_scale=guidance_scale,
width=width,
height=height,
generator=generator
).images[0]

img_byte_arr = BytesIO()
image.save(img_byte_arr, format="PNG")
img_byte_arr.seek(0)

return img_byte_arr.getvalue()


# PATH TO JSON FILE

script_path = "resources/scripts/script.json"
images_output_path = "resources/images/"
# os.makedirs(output_path, exist_ok=True)


# PROVIDE SOURCE TEXT OR PROMPT IN JSON FILE

def main_generate_image(script_path,images_output_path):
# JSON Decoding Error Handling
with open(script_path, "r", encoding="utf-8") as file:
try:
data = json.load(file)
except json.JSONDecodeError:
print("Error reading JSON file.")
return
# JSON Key Error Handling
if "visual_script" not in data:
print("Missing key in JSON.")
return


# GENERATING THE IMAGES
with modal.enable_output():
with app.run():
# Looping Through the Scenes
for idx, scene in enumerate(data["visual_script"]):
try:
prompt = scene["prompt"]
timestamp = scene.get("timestamp", f"{idx:03d}")
negative_prompt = scene.get("negative_prompt", "")
steps = scene.get("steps", 50)
# guidance_scale = scene.get("guidance_scale", 12)
guidance_scale = 9

# width = scene.get("width", 1024)
width = 1920
# height = scene.get("height", 576)
height = 1080
seed = scene.get("seed", None)

scene_id = timestamp.replace(":", "-")

image_data = generate_image.remote(prompt, negative_prompt, steps, guidance_scale, width, height, seed)


# SAVING THE IMAGES IN THE OUTPUT DIRECTORY

file_path = os.path.join(images_output_path, f"scene_{scene_id}.png")
with open(file_path, "wb") as f:
f.write(image_data)

print(f"Saved: {file_path}")

time.sleep(2)

except Exception as e:
print(f"Error processing scene {idx}: {e}")

print("Done.")

# if __name__ == "__main__":
# main_generate_image(script_path=script_path,images_output_path=images_output_path)
92 changes: 92 additions & 0 deletions diffusion/scripts/generate_image_local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# import modal
import json
import os
import time
from io import BytesIO


def generate_image(prompt, negative_prompt="", steps=50, guidance_scale=9, width=1920, height=1080, seed=None):
import torch
from diffusers import DiffusionPipeline


# LOADS THE DIFFUSION PIPELINE

pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0",
torch_dtype=torch.float16,
use_safetensors=True,
variant="fp16")

pipe.to("cuda" if torch.cuda.is_available() else "cpu")

generator = torch.Generator(device="cuda" if torch.cuda.is_available() else "cpu").manual_seed(seed) if seed else None

image = pipe(
prompt,
negative_prompt=negative_prompt,
num_inference_steps=steps,
guidance_scale=guidance_scale,
width=width,
height=height,
generator=generator
).images[0]

img_byte_arr = BytesIO()
image.save(img_byte_arr, format="PNG")
img_byte_arr.seek(0)

return img_byte_arr.getvalue()

# PROVIDE SOURCE TEXT OR PROMPT IN JSON FILE

def main_generate_image(script_path,images_output_path):
# JSON Decoding Error Handling
with open(script_path, "r", encoding="utf-8") as file:
try:
data = json.load(file)
except json.JSONDecodeError:
print("Error reading JSON file.")
return
# JSON Key Error Handling
if "visual_script" not in data:
print("Missing key in JSON.")
return


# GENERATING THE IMAGES

# Looping Through the Scenes
for idx, scene in enumerate(data["visual_script"]):
try:
prompt = scene["prompt"]
timestamp = scene.get("timestamp", f"{idx:03d}")
negative_prompt = scene.get("negative_prompt", "")
steps = scene.get("steps", 50)
# guidance_scale = scene.get("guidance_scale", 12)
guidance_scale = 9 # Set to 9 to allow for some room of filling missing elements.
width = 1920
height = 1080
seed = scene.get("seed", None)

scene_id = timestamp.replace(":", "-")

image_data = generate_image(prompt, negative_prompt, steps, guidance_scale, width, height, seed)


# SAVING THE IMAGES IN THE OUTPUT DIRECTORY

file_path = os.path.join(images_output_path, f"scene_{scene_id}.png")
with open(file_path, "wb") as f:
f.write(image_data)

print(f"Saved: {file_path}")

time.sleep(2)

except Exception as e:
print(f"Error processing scene {idx}: {e}")

print("Image Generation is Done.")

# if __name__ == "__main__":
# main_generate_image(script_path=script_path,images_output_path=images_output_path)
Loading