Commit 7d042348 authored by Ranasinghe R.A.P.T's avatar Ranasinghe R.A.P.T

Merge branch 'other/model_separation' into 'dev'

Other/model separation

See merge request !6
parents 98243cc2 138eb974
......@@ -4,8 +4,8 @@ import numpy as np
class AwsOperation:
def __init__(self, bucket_name):
self.bucket_name = bucket_name
def __init__(self):
pass
def s3_connector(self):
......@@ -13,5 +13,5 @@ class AwsOperation:
aws_access_key_id="AKIAWAP4EPNHCC6BXFXV",
aws_secret_access_key="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",
)
s3 = session.resource('s3')
return s3.Bucket(self.bucket_name)
\ No newline at end of file
return session.resource('s3')
# return s3.Bucket(self.bucket_name)
\ No newline at end of file
from .awsOperation import AwsOperation
from moviepy.editor import *
from loguru import logger
import os
import json
import cv2
import numpy as np
import glob
# pamalcodex
class WordMapping:
def __init__(self, filtered_sentence):
self.filtered_sentence = filtered_sentence
def words_map_with_gestures(self):
try:
clip_arr = []
aws = AwsOperation()
s3_session = aws.s3_connector()
bucket = s3_session.Bucket('rpserverone')
extension = ".mp4"
for i in range(0, len(self.filtered_sentence)):
print(type(i))
print(str(self.filtered_sentence[i]) + extension)
bucket.download_file(str(self.filtered_sentence[i])+extension, 'D:/s3_tute/'+str(self.filtered_sentence[i])+extension)
for i in range(0, len(self.filtered_sentence)):
with open('D:/s3_tute/' + str(self.filtered_sentence[i])+extension) as f:
clip = VideoFileClip(f.name)
clip_arr.append(clip)
final = concatenate_videoclips(clip_arr)
final.write_videofile("assets/final_video/final_out.mp4")
s3_session.meta.client.upload_file("assets/final_video/final_out.mp4","pamalcodex", "final_out.mp4")
os.remove(os.path.join("D:/rp_server_one/assets/final_video", "final_out.mp4"))
except Exception as e:
logger.error(str(e))
return json.loads(json.dumps({"message" : str(e)})), 500
\ No newline at end of file
from nltk.tokenize import word_tokenize
from loguru import logger
from .awsOperation import AwsOperation
from .wordsMappingModel import WordMapping
from moviepy.editor import *
import os
import json
import cv2
import numpy as np
import glob
from moviepy.editor import *
class WordModel:
......@@ -39,24 +41,8 @@ class WordModel:
if w not in stop_words:
filtered_sentence.append(w)
aws = AwsOperation('rpserverone')
bucket = aws.s3_connector()
extension = ".mp4"
# sign_names = ["this", "beautiful", "day"]
for i in range(0, len(filtered_sentence)):
print(type(i))
print(str(filtered_sentence[i]) + extension)
bucket.download_file(str(filtered_sentence[i])+extension, 'D:/s3_tute/'+str(filtered_sentence[i])+extension)
for filename in glob.glob('D:/s3_tute/*.mp4'):
clip = VideoFileClip(filename)
clip_arr.append(clip)
final = concatenate_videoclips(clip_arr)
final.write_videofile("final_out.mp4")
word_mapper = WordMapping(filtered_sentence)
word_mapper.words_map_with_gestures()
return json.loads(json.dumps({
"filtered_words" : filtered_sentence,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment