영상 자막 분석 진행하면서 겪은 점.

2025. 4. 4. 23:56기록

1. 영상 다운로드
 
2. 해당 영상의 자막 TTS로 얻기.
미국식 발음이 기준이라서, 영국식 발음인 경우, base 모델이거나, 언어를 따로 지정하지 않으면 성능이 안좋음.

25
00:02:17.619 --> 00:02:23.759
 Aillwn giddau enc norvaethidiolょ y gynhyglidioliwfo annd famous

26
00:02:24.839 --> 00:02:29.259
リgidaethu, gyffyrraeth yn kaed Sabà, diwy, a hungaeth i gallfauаг

27
00:02:29.839 --> 00:02:35.359
 Fang万 perадachio onanddi''u gan y gwyandagiool

28
00:02:35.659 --> 00:02:38.939
 Iegau fy伯ع warenbyddio gyfer yr ydiwyll cyffyrraethno edrystu

29
00:02:39.199 --> 00:02:40.419
 Futanau jawn Sistersnundi quart gallf yw fy模 frança

30
00:02:41.060 --> 00:02:41.799
 Olaf Law erase eol earrings up

31
00:02:41.899 --> 00:02:43.199
 repaired blession👍

> 동양어와 서양어, 심지어 이모지도 나옴.
- (medium), language="en"으로 해결.
 
3. db 생성 및 영상정보와 자막 입력.
 
4. 영상과 자막 합치기.
> 시작점을 00:00:00000으로 보기에, 처음 자막이 영상 시작할 때부터 떠 있음.
- ffmpeg으로 데시벨 일정 이상인 부분을 얻어 그 지점을 시작으로 입력.
 
5. sqlite db에서 자막과 제목 가져옴.
 
6. NER: Bert-NER(dslim/bert-base-NER) + SpaCy
> 전부 토큰화 되어, 나옴.
- LOC, PER, ORG 등 연속된 개체명끼리 묶고, ##이 포함된 단어의 전후를 같이 묶음.

United States, John G . Roberts Jr, Harvard College Harvard Law School, 
Justice Roberts William H . Rhenquist, Supreme Court of the United States, 
Ronald Reagan, Appeals District of Columbia Circuit,
Cardigan Mountain School, Washington DC Cardigan, 
# 두 인원이 하나로 묶임.
George W . Bush Justice Roberts Marion Jane,
# Hallucination
Josie Jack Cynthia, Justice, Quincy Adams, Arizona

> 두 인원이 하나로 묶이거나, 자막에 없는 내용이 추가되는 할루시네이션 생김.
- PER의 경우 단어 길이를 3으로 쪼개 사용하고, 자막 정보도 추가로 보내 내부에 있는 경우에만 사용하도록 함.
> 내가 생각한건 자막에 있는 실제 내용들인데 아웃풋 값들은 계속 할루시네이션으로 만들어짐.
- SpaCy와 교집합.
> 교집합 할 경우 같은 단어여도 분류가 달라 리턴값이 0인 경우 발생.
- 단어 기준으로 교집합 진행.
 
7. Keyword: KeyBERT(all-MiniLM-L6-v2)
 
8. Summary: Pegasus(google/pegasus-cnn_dailymail)

# BART
## With Segments
CNN''s John Sutter offers advice to young men as they prepare to go to school. 
Sutter: Once a week you should write a note to someone, not an email, 
but note on a piece of paper. May you always know the truth and see the light 
surrounding you.

## Without Segments
John G. Roberts Jr. is a graduate of Harvard College and Harvard Law School. 
He served as a law clerk for then Associate Justice William H. Rhenquist of the 
Supreme Court of the United States. Chief Justice Roberts is also the proud parents
of their daughter, Josie.

> 할루시네이션이 심한 BART 모델 포기. 더 정확한 Pegasus로 변경.

# Pegasus
Cardigan Mountain School held its annual commencement on Saturday .<n>
John G. Roberts Jr., Chief Justice of the Supreme Court, was the speaker
.<n>Roberts is a graduate of Harvard College and Harvard Law School .

- 훨씬 정확도가 높아짐. 위의 결과에서 전처리 추가.

""Not only has Harvard given me an extraordinary honor, but the weeks of fear and 
nausea I  have endured at the thought of giving this commencement address have made me 
lose weight,"" she says. ""Now all I have to do is take deep breaths, squint at the 
red banners,  and convince myself that I am at the world''s largest Gryffindor reunion

> 다른 영상을 입력하니 BART가 더 성능이 좋음.
- 두 모델을 모두 돌려 BERTScore가 높은 결과물 선정.
- 정확한 기준점을 얻기 위해 BLEU, ROUGE, BERTScore 사용. 세 지표를 사용해 결과물의 정확도를 객관적으로 판단.


마지막에서 bleu, rouge 지표를 추가하니 병목현상으로 웹 페이지 로드가 안되는 현상 발생.
모델의 종류별로 무게 등을 고려해 모델 로드 순서를 최적화.
무게: 요약모델 > NER > 평가지표 > KeyBERT
 
 

728x90

'기록' 카테고리의 다른 글

프로젝트 하나를 마무리 하긴 했는데 아쉽다.  (0) 2025.04.12