Mileena awacke1 commited on
Commit
f8d4e15
β€’
0 Parent(s):

Duplicate from awacke1/AI-MovieMaker-Comedy

Browse files

Co-authored-by: Aaron C Wacker <awacke1@users.noreply.huggingface.co>

Files changed (5) hide show
  1. .gitattributes +27 -0
  2. README.md +14 -0
  3. app.py +74 -0
  4. packages.txt +1 -0
  5. requirements.txt +5 -0
.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ftz filter=lfs diff=lfs merge=lfs -text
6
+ *.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.h5 filter=lfs diff=lfs merge=lfs -text
8
+ *.joblib filter=lfs diff=lfs merge=lfs -text
9
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
10
+ *.model filter=lfs diff=lfs merge=lfs -text
11
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
12
+ *.onnx filter=lfs diff=lfs merge=lfs -text
13
+ *.ot filter=lfs diff=lfs merge=lfs -text
14
+ *.parquet filter=lfs diff=lfs merge=lfs -text
15
+ *.pb filter=lfs diff=lfs merge=lfs -text
16
+ *.pt filter=lfs diff=lfs merge=lfs -text
17
+ *.pth filter=lfs diff=lfs merge=lfs -text
18
+ *.rar filter=lfs diff=lfs merge=lfs -text
19
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
20
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
21
+ *.tflite filter=lfs diff=lfs merge=lfs -text
22
+ *.tgz filter=lfs diff=lfs merge=lfs -text
23
+ *.wasm filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: AI Movie Maker 🎞️🍿🎬 Comedy Gradio
3
+ emoji: 🎞️🍿🎬
4
+ colorFrom: gray
5
+ colorTo: green
6
+ sdk: gradio
7
+ sdk_version: 2.9.4
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ duplicated_from: awacke1/AI-MovieMaker-Comedy
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
app.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import moviepy.video.io.ImageSequenceClip
3
+ from PIL import Image
4
+ from pydub import AudioSegment
5
+ from moviepy.editor import *
6
+ import numpy as np
7
+ import mutagen
8
+ from mutagen.mp3 import MP3
9
+ import cv2
10
+
11
+ HF_TOKEN = os.environ.get("HF_TOKEN")
12
+
13
+
14
+ def resize(img_list):
15
+ resize_img_list = []
16
+ for item in img_list:
17
+ im = Image.open(item)
18
+ imResize = im.resize((256,256), Image.ANTIALIAS)
19
+ resize_img_list.append(np.array(imResize))
20
+ return resize_img_list
21
+
22
+
23
+ def merge_audio_video(entities_num, resize_img_list, text_input):
24
+ speech = text2speech(text_input)
25
+ wav_audio = AudioSegment.from_file(speech, "flac") #("/content/gdrive/My Drive/AI/audio1.flac", "flac")
26
+ wav_audio.export("audio.mp3", format="mp3") #("/content/gdrive/My Drive/AI/audio1.mp3", format="mp3")
27
+ audio_length = int(MP3("audio.mp3").info.length)
28
+ fps= entities_num / audio_length #length of audio file
29
+ fps = float(format(fps, '.5f'))
30
+ clip = moviepy.video.io.ImageSequenceClip.ImageSequenceClip(resize_img_list, fps=fps)
31
+ clip.write_videofile('my_vid_tmp.mp4')
32
+ videoclip = VideoFileClip('my_vid_tmp.mp4') #("/content/gdrive/My Drive/AI/my_video1.mp4")
33
+ audioclip = AudioFileClip('audio.mp3') #.subclip(0, 15)
34
+ mergedclip = videoclip.set_audio(audioclip)
35
+ duration = mergedclip.duration
36
+ frame_count = mergedclip.fps
37
+ return mergedclip
38
+
39
+ fastspeech = gr.Interface.load("huggingface/facebook/fastspeech2-en-ljspeech", api_key=HF_TOKEN)
40
+
41
+ def text2speech(text):
42
+ speech = fastspeech(text)
43
+ return speech
44
+
45
+ def engine(text_input):
46
+ ner = gr.Interface.load("huggingface/flair/ner-english-ontonotes-large", api_key=HF_TOKEN)
47
+ entities = ner(text_input)
48
+ entities = [tupl for tupl in entities if None not in tupl]
49
+ entities_num = len(entities)
50
+ img_list = []
51
+ for ent in entities:
52
+ img = gr.Interface.load("spaces/multimodalart/latentdiffusion, api_key=HF_TOKEN")(ent[0],'50','256','256','1',10)[0]
53
+ img_list.append(img)
54
+ resize_img_list = resize(img_list)
55
+ mergedclip = merge_audio_video(entities_num, resize_img_list, text_input)
56
+ mergedclip.to_videofile('mergedvideo.mp4')
57
+ return 'mergedvideo.mp4'
58
+
59
+ app = gr.Interface(engine,
60
+ gr.inputs.Textbox(lines=5, label="Input Text"),
61
+ gr.outputs.Video(type=None, label='Final Merged video'),
62
+ description="<div>🎭🎞️🍿 AI Movie Maker - Comedy 🎬 🧠 🎨</div>" ,
63
+ examples=
64
+ [
65
+ ["Two space marines take up arms to save the planet from an alien invasion. These two dashing strong men play a comedic role in the science fiction movie of the future where even barnaby bunny is willing to join their wacky gang of space marines to save the planet with good looks and comedy."],
66
+ ["Two space marines take up arms to save the planet from an alien invasion. In each episode they play different roles with the main mission to save Wills girlfriend from alien attack. These two dashing strong men play a comedic role in the science fiction movie of the future, and make their second feature film appearance together in a comedy. In the short-lived TV series The Twilight Space Marines, Two space marines take up arms to save the planet from an alien invasion."],
67
+ ["These two dashing strong men play a comedic role in the science fiction movie of the future but also serve as a bit of sci-fi history lesson the first time we saw them one of them held a gun to the head of another in anger due to a wrestling disagreement about a famous clearwater bar karaoke and wrestling champion. Barnaby bunny is willing to join their wacky gang of space marines for their adventure in the universe. But, its not just any adventure. They have got to survive a dangerous world, find their destiny, and defeat a cosmic villain before These two dashing strong men play a comedic role in the science fiction movie of the future."],
68
+ ["To save the planet with good looks and comedy is not easy and they are both pro expert mobsters and wrestling federation superstars. It is a wonder I have been able to continue working as I have when so many others have given up And here he is, a mere nine years after the film release, interviewed. Two space marines who take up arms and wrestling moves and jokes to save the planet from invading bad guys. it is hilarious. That is why they are so perfect as a comedic double act, so we asked if they will be up for a sequel to charm us once again. Dudes we are ready!"]
69
+ ],
70
+ title="AI Pipeline Multi Model 🎭🎞️🍿 Movie Maker 🎬 🧠 🎨",
71
+ article="<br><div></div>"
72
+
73
+ #).launch(enable_queue=True, debug=True)
74
+ ).launch(debug=True)
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ ffmpeg
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Pillow
2
+ opencv-python-headless
3
+ pydub
4
+ moviepy
5
+ mutagen