Toggle navigation
Toggle navigation
This project
Loading...
Sign in
lizhengwei
/
aigc-embedding-service
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
lizhengwei
2026-05-15 15:44:17 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a2bc9a48a3a3ef99b109a676d00f2c2c32f934d2
a2bc9a48
1 parent
18a7ad89
jira:NYJ-1540 desc: update api.py
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
27 additions
and
22 deletions
src/football_replay_match/cfg/config.prod.yaml
src/football_replay_match/cfg/config.yaml
src/football_replay_match/core/api.py
src/football_replay_match/core/llm_image.py
src/football_replay_match/util/football_replay_match_live.py
src/football_replay_match/util/football_replay_video_event_by_llm.py
src/football_replay_match/util/match_live_test.py
src/football_replay_match/util/replay_event_test.py
src/football_replay_match/util/z_sport_json_to_txt.py
src/football_replay_match/cfg/config.prod.yaml
View file @
a2bc9a4
...
...
@@ -10,6 +10,6 @@ output_kafka:
topic
:
football_replay_match_resp
cache_dir
:
/data/cache
llm_base_url
:
http://prod-llm:11434
llm_model
:
qwen3.6:35b-a3b-q8_0
llm_base_url
:
http://prod-llm:11434/v1
llm_model
:
Qwen3.6-35B-A3B-UD-Q8_K_XL.gguf
llm_temperature
:
0.7
...
...
src/football_replay_match/cfg/config.yaml
View file @
a2bc9a4
...
...
@@ -11,8 +11,8 @@ output_kafka:
llm
:
base_url
:
http://192.168.1.59:11434
model_name
:
qwen3.6:35b-a3b-q8_0
base_url
:
http://192.168.1.59:11434/v1
model_name
:
Qwen3.6-35B-A3B-UD-Q8_K_XL.gguf
temperature
:
0.7
common
:
...
...
src/football_replay_match/core/api.py
View file @
a2bc9a4
...
...
@@ -44,7 +44,7 @@ def replay_match_event(data: dict) -> dict:
events : list 赛事事件片段(直播候选)
|- id : str 事件id
|- type : str 事件类型(1:进球)
|- url : str
事件片段
url(m3u8)
|- url : str
完整视频
url(m3u8)
|- event_utc : int 事件发生的utc时间点
响应参数:
...
...
@@ -82,20 +82,23 @@ def replay_match_event(data: dict) -> dict:
raise
RuntimeError
(
f
"回看视频处理失败: {e}"
)
# 2. 为每个 event(直播候选)提取帧并构建 LLM content
# event 的 url
本身已是视频片段,直接处理完整
片段
# event 的 url
为完整视频,通过 event_utc 向前延长10秒、向后延长5秒截取
片段
live_videos
=
[]
for
event
in
events
:
event_id
=
event
.
get
(
"id"
)
event_url
=
event
.
get
(
"url"
)
event_utc
=
event
.
get
(
"event_utc"
)
if
not
event_url
:
if
not
event_url
or
event_utc
is
None
:
continue
try
:
event_start
=
event_utc
-
10
event_end
=
event_utc
+
5
event_frames
=
v2f
.
to_frames
(
url
=
event_url
,
start_utc
=
0
,
end_utc
=
999999
,
# 传极大值,实际以视频真实长度为准
start_utc
=
event_start
,
end_utc
=
event_end
,
fps
=
2
,
)
event_contents
=
frames2content
(
event_frames
)
...
...
src/football_replay_match/core/llm_image.py
View file @
a2bc9a4
...
...
@@ -357,8 +357,8 @@ if __name__ == "__main__":
from
util.football_replay_video_event_by_llm
import
FootballReplayVideoEvent
fbrv
=
FootballReplayVideoEvent
(
base_url
=
"http://192.168.1.59:11434"
,
model
=
"qwen3.6:35b-a3b-q8_0"
,
base_url
=
"http://192.168.1.59:11434/v1"
,
model
=
"Qwen3.6-35B-A3B-UD-Q8_K_XL.gguf"
,
temperature
=
0.7
,
)
event_json
=
fbrv
.
video_event_for_contents
(
content
,
None
)
...
...
src/football_replay_match/util/football_replay_match_live.py
View file @
a2bc9a4
...
...
@@ -3,7 +3,7 @@ import os.path
from
pathlib
import
Path
from
langchain_core.messages
import
SystemMessage
,
HumanMessage
from
langchain_o
llama
import
ChatOllama
from
langchain_o
penai
import
ChatOpenAI
try
:
from
.llm_video_content
import
contents
as
video_contents
...
...
@@ -79,7 +79,8 @@ class FootballReplayMatchLive:
# keep_alive=-1, reasoning=False)
# self.model = ChatOpenAI(base_url="http://192.168.1.59:11434/v1", model="qwen3.6:35b-a3b-q8_0", temperature=0.7,
# api_key='no_key')
self
.
model
=
ChatOllama
(
base_url
=
base_url
,
model
=
model
,
temperature
=
temperature
,
keep_alive
=-
1
,
reasoning
=
False
)
self
.
model
=
ChatOpenAI
(
base_url
=
base_url
,
model
=
model
,
temperature
=
temperature
,
api_key
=
api_key
,
extra_body
=
{
"chat_template_kwargs"
:
{
"enable_thinking"
:
False
}})
def
_match_once
(
self
,
replay_video_contents
:
list
,
live_videos
:
list
[
dict
],
cache_path
=
None
,
record
:
list
=
None
):
...
...
src/football_replay_match/util/football_replay_video_event_by_llm.py
View file @
a2bc9a4
...
...
@@ -3,7 +3,7 @@ import os.path
from
pathlib
import
Path
from
langchain_core.messages
import
SystemMessage
,
HumanMessage
from
langchain_o
llama
import
ChatOllama
from
langchain_o
penai
import
ChatOpenAI
try
:
from
.llm_video_content
import
contents
as
video_contents
...
...
@@ -74,7 +74,8 @@ class FootballReplayVideoEvent:
# keep_alive=-1, reasoning=False)
# self.model = ChatOpenAI(base_url="http://192.168.1.59:11434/v1", model="qwen3.6:35b-a3b-q8_0", temperature=0.7,
# api_key='no_key')
self
.
model
=
ChatOllama
(
base_url
=
base_url
,
model
=
model
,
temperature
=
temperature
,
keep_alive
=-
1
,
reasoning
=
False
)
self
.
model
=
ChatOpenAI
(
base_url
=
base_url
,
model
=
model
,
temperature
=
temperature
,
api_key
=
api_key
,
extra_body
=
{
"chat_template_kwargs"
:
{
"enable_thinking"
:
False
}})
def
video_event
(
self
,
video_path
:
str
,
asr_text
:
str
=
'无'
,
cache_path
=
None
):
if
cache_path
is
not
None
and
os
.
path
.
exists
(
cache_path
):
...
...
src/football_replay_match/util/match_live_test.py
View file @
a2bc9a4
...
...
@@ -6,9 +6,9 @@ import json
def
batch_match
():
replay_match_live
=
FootballReplayMatchLive
(
base_url
=
"http://192.168.1.59:11434
"
,
model
=
"qwen3.6:35b-a3b-q8_0
"
)
replay_match_live
=
FootballReplayMatchLive
(
base_url
=
"http://192.168.1.59:11434
/v1"
,
model
=
"Qwen3.6-35B-A3B-UD-Q8_K_XL.gguf
"
)
qwen_asr
=
QwenAsr
(
base_url
=
"http://192.168.1.59:8101/v1"
,
model
=
"Qwen/Qwen3-ASR-1.7B"
)
fbrv
=
FootballReplayVideoEvent
(
base_url
=
"http://192.168.1.59:11434
"
,
model
=
"qwen3.6:35b-a3b-q8_0
"
,
temperature
=
0.7
)
fbrv
=
FootballReplayVideoEvent
(
base_url
=
"http://192.168.1.59:11434
/v1"
,
model
=
"Qwen3.6-35B-A3B-UD-Q8_K_XL.gguf
"
,
temperature
=
0.7
)
videos_dir
=
rf
"R:
\
wdx
\202
604
\202
60420_download_football_video
\f
inished"
for
video_name
in
sorted
(
os
.
listdir
(
videos_dir
)):
...
...
src/football_replay_match/util/replay_event_test.py
View file @
a2bc9a4
...
...
@@ -4,7 +4,7 @@ import os
from
football_replay_video_event_by_llm
import
FootballReplayVideoEvent
from
qwen_asr_util
import
QwenAsr
def
batch_with_asr
():
fbrv
=
FootballReplayVideoEvent
(
base_url
=
"http://192.168.1.59:11434
"
,
model
=
"qwen3.6:35b-a3b-q8_0
"
,
temperature
=
0.7
)
fbrv
=
FootballReplayVideoEvent
(
base_url
=
"http://192.168.1.59:11434
/v1"
,
model
=
"Qwen3.6-35B-A3B-UD-Q8_K_XL.gguf
"
,
temperature
=
0.7
)
qwen_asr
=
QwenAsr
(
base_url
=
"http://192.168.1.59:8101/v1"
,
model
=
"Qwen/Qwen3-ASR-1.7B"
,
temperature
=
0.7
,
api_key
=
'no_key'
)
...
...
@@ -27,7 +27,7 @@ def batch_with_asr():
print
(
event_json
)
def
batch_without_asr
():
fbrv
=
FootballReplayVideoEvent
(
base_url
=
"http://192.168.1.59:11434
"
,
model
=
"qwen3.6:35b-a3b-q8_0
"
,
temperature
=
0.7
)
fbrv
=
FootballReplayVideoEvent
(
base_url
=
"http://192.168.1.59:11434
/v1"
,
model
=
"Qwen3.6-35B-A3B-UD-Q8_K_XL.gguf
"
,
temperature
=
0.7
)
# qwen_asr = QwenAsr(base_url="http://192.168.1.59:8101/v1", model="Qwen/Qwen3-ASR-1.7B", temperature=0.7,
# api_key='no_key')
...
...
@@ -51,7 +51,7 @@ def batch_without_asr():
print
(
event_json
)
def
one_video_test
(
video_path
):
fbrv
=
FootballReplayVideoEvent
(
base_url
=
"http://192.168.1.59:11434
"
,
model
=
"qwen3.6:35b-a3b-q8_0
"
,
temperature
=
0.7
)
fbrv
=
FootballReplayVideoEvent
(
base_url
=
"http://192.168.1.59:11434
/v1"
,
model
=
"Qwen3.6-35B-A3B-UD-Q8_K_XL.gguf
"
,
temperature
=
0.7
)
event_json
=
fbrv
.
video_event
(
video_path
,
None
)
print
(
event_json
)
...
...
src/football_replay_match/util/z_sport_json_to_txt.py
View file @
a2bc9a4
...
...
@@ -3,7 +3,7 @@ import json
from
pathlib
import
Path
from
aabd.base.time_util
import
vms2str_auto
from
langchain_o
llama
import
ChatOllama
from
langchain_o
penai
import
ChatOpenAI
class
ClipByEvent
:
...
...
@@ -19,7 +19,7 @@ class ClipByEvent:
# keep_alive=-1, reasoning=False)
# self.model = ChatOpenAI(base_url="http://192.168.1.59:11434/v1", model="qwen3.6:35b-a3b-q8_0", temperature=0.7,
# api_key='no_key')
self
.
model
=
ChatO
llama
(
base_url
=
base_url
,
model
=
model
,
temperature
=
temperature
,
keep_alive
=-
1
,
reasoning
=
False
)
self
.
model
=
ChatO
penAI
(
base_url
=
base_url
,
model
=
model
,
temperature
=
temperature
,
api_key
=
api_key
)
def
get_video_match_time
(
self
,
video_path
,
video_time
):
import
cv2
...
...
Please
register
or
login
to post a comment